Skip to content

Instantly share code, notes, and snippets.

@SilenNaihin
Last active February 1, 2026 04:40
Show Gist options
  • Select an option

  • Save SilenNaihin/a75cf56ac7aeae3dbf5c4a0ee754daf4 to your computer and use it in GitHub Desktop.

Select an option

Save SilenNaihin/a75cf56ac7aeae3dbf5c4a0ee754daf4 to your computer and use it in GitHub Desktop.
Claude Code: Lint Quality command

Lint Quality

Run code quality checks to find duplication and dead code.

Detect Project Type

First, determine if this is a JavaScript/TypeScript or Python project:

ls package.json pyproject.toml setup.py 2>/dev/null

JavaScript/TypeScript Projects

Check and Install

Check if jscpd and knip are installed:

cat package.json | grep -E "jscpd|knip"

If not installed:

npm install -D jscpd knip
npx knip init

Add scripts to package.json if missing:

{
  "scripts": {
    "lint:dupes": "jscpd src/",
    "lint:dead": "knip",
    "lint:quality": "npm run lint:dupes && npm run lint:dead"
  }
}

Run Quality Checks

npm run lint:dupes
npm run lint:dead

Review Results

  1. jscpd: Number of duplicate code blocks and duplication percentage
  2. knip: Unused files, unused dependencies, unused exports, unused types

Python Projects

Check and Install

Ensure ruff and vulture are available:

pip install ruff vulture  # or: uv pip install ruff vulture

Run Quality Checks

# Unused imports, variables, redefinitions
ruff check src/ --select=F401,F841,F811 --statistics

# Dead code detection
vulture src/ --min-confidence 80

Auto-fix What's Possible

# Fix unused imports automatically
ruff check src/ --select=F401,F841,F811 --fix

# For remaining issues that need manual review
ruff check src/ --select=F401,F841,F811 --fix --unsafe-fixes

Review Results

  1. ruff F401: Unused imports
  2. ruff F841: Unused variables
  3. ruff F811: Redefined names
  4. vulture: Dead code (unused functions, classes, variables)

Fix Issues (Both Languages)

For each issue found:

  • Duplicate code: Extract to shared utility or module
  • Unused files: Delete them
  • Unused dependencies: Remove from package.json or pyproject.toml
  • Unused exports/imports: Remove the export or delete if truly unused
  • Dead functions/classes: Delete if no longer needed

Commit Cleanup

git add -A
git commit -m "chore: remove dead code and fix lint issues"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment