Git workflow, code quality, context management and testing commands: - commit, push, pr, issue - git operations - simplify, refactor, verify, check - code quality - catchup, onboard, save, cleanup - context management - test, format, sync - development utilities Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2.1 KiB
2.1 KiB
description: Run code formatters (prettier, eslint --fix, black, etc.)
argument-hint: [path] - Optional path to format (defaults to .)
Format Code
Pre-computed Context
Package.json Scripts:
!cat package.json 2>/dev/null | grep -E '"(format|lint|prettier)"' | head -5 || echo "No package.json"
Prettier Config:
!ls -la .prettierrc* prettier.config.* 2>/dev/null | head -3 || echo "No Prettier config"
ESLint Config:
!ls -la .eslintrc* eslint.config.* 2>/dev/null | head -3 || echo "No ESLint config"
Python Formatters:
!ls -la pyproject.toml setup.cfg .flake8 2>/dev/null | head -3 || echo "No Python config"
Modified Files:
!git diff --name-only | head -10
Instructions
You are running code formatters on the codebase.
Detect Stack & Run Formatters
JavaScript/TypeScript
Check for and run in order:
- npm scripts (preferred):
npm run format 2>/dev/null || npm run lint:fix 2>/dev/null
- Prettier directly:
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}" 2>/dev/null
- ESLint fix:
npx eslint --fix . 2>/dev/null
Python
- Black:
black . 2>/dev/null || python -m black . 2>/dev/null
- isort (import sorting):
isort . 2>/dev/null || python -m isort . 2>/dev/null
- Ruff (fast linter + formatter):
ruff format . 2>/dev/null
ruff check --fix . 2>/dev/null
Go
go fmt ./... 2>/dev/null
goimports -w . 2>/dev/null
Rust
cargo fmt 2>/dev/null
Path Argument
If a path argument is provided, format only that path:
npx prettier --write "$ARGUMENTS"
Report Changes
After formatting, show what changed:
git diff --stat
Common Issues
Prettier vs ESLint conflicts:
- Use
eslint-config-prettierto disable conflicting rules - Run Prettier first, then ESLint
Format on save not working:
- Check VS Code settings:
editor.formatOnSave - Verify default formatter is set
Some files not formatted:
- Check
.prettierignore/.eslintignore - Verify file extensions in config