Lint and format code. Auto-detects ESLint, Biome, Prettier, or language-native formatters and runs them with auto-fix. Reports remaining issues with actionable suggestions.
git diff --name-only and git diff --cached --name-only)./lint src/utils).--fix: Automatically apply safe fixes. Can be combined with a path (e.g., /lint src/ --fix).--fix without a path: Auto-fix changed files only.Parse the arguments before proceeding. If --fix is present, set fix mode. If a non-flag argument is present, treat it as the target path.
</arguments>
JavaScript/TypeScript Linters:
<execution> </execution>Biome — Look for biome.json or biome.jsonc in the project root.
npx @biomejs/biome check . (or --apply with --fix)npx @biomejs/biome format . (or --write with --fix)ESLint — Look for .eslintrc, .eslintrc.* (js, cjs, json, yml, yaml), eslint.config.* (js, mjs, cjs, ts, mts, cts), or an "eslintConfig" key in package.json.
npx eslint . (or --fix with --fix)package.json for the installed version. ESLint 9+ uses flat config (eslint.config.*).JavaScript/TypeScript Formatters (only if Biome was NOT detected):
.prettierrc, .prettierrc.*, prettier.config.*, or a "prettier" key in package.json.
npx prettier --check .npx prettier --write .Rust:
rustfmt.toml or .rustfmt.toml, or Cargo.toml in the project root.
cargo fmt -- --checkcargo fmtcargo clippy (if available)Go:
go.mod in the project root.
gofmt -l .gofmt -w .golangci-lint run (if installed), otherwise go vet ./...Python:
Ruff — Look for ruff.toml or a [tool.ruff] section in pyproject.toml.
ruff check . (or --fix with --fix)ruff format . (or --check without --fix)Black — Look for a [tool.black] section in pyproject.toml, or black in requirements files.
black --check .black .If no linter or formatter is detected, inform the user and suggest common options for their project type based on the files present. </detection>
Step 1: Determine target files
git diff --name-only
git diff --cached --name-only
Filter to files that still exist on disk. If no files are changed, inform the user and offer to lint the entire project instead.Step 2: Run the detected tools
Run the linter and/or formatter against the target files or directory.
--fix: Run in check/report mode only. Do NOT modify any files.--fix: Run with auto-fix flags enabled.When running formatters without --fix, show a preview of what would change:
--check and list files that would change.check without --apply.--check --diff to show the diff preview.--diff for format and standard output for lint.--check or -l to list files, then show a diff for up to 5 files using diff <(command) file.Step 3: Parse and organize output
Parse the tool output and organize issues:
## Lint Results
### Errors (X issues)
| File | Line | Rule | Message |
|------|------|------|---------|
| ... | ... | ... | ... |
### Warnings (X issues)
| File | Line | Rule | Message |
|------|------|------|---------|
| ... | ... | ... | ... |
### Formatting
- X files would be reformatted
- [list files]
### Summary
- Total issues: X errors, Y warnings, Z formatting
- Auto-fixable: N issues (run `/lint --fix` to apply)
Step 4: Suggest fixes for common issues
For the most frequent issues, provide brief actionable guidance:
--fix will resolve them safely.<critical_rules>
--fix: Default mode is report-only. Respect the user's working tree.npx, cargo, or the project-local binary. Do not use globally installed tools unless no local version exists.npm install --save-dev eslint)..gitignore and ignore patterns: Do not lint node_modules, dist, build, target, .git, or other commonly ignored directories. Most tools handle this automatically; verify they do.</critical_rules>