Format Code
Reformat source code files to match a consistent style guide.
Workflow
- Accept a directory path and optional language filter from the user.
- Use Glob to find source files matching the language filter (e.g.,
**/*.py,**/*.js,**/*.ts). - Use Read to read each file's contents.
- Analyze formatting against these rules:
- Consistent indentation (spaces vs tabs, indent width)
- Trailing whitespace removal
- Consistent line endings
- Blank line normalization (max 2 consecutive)
- Import/require statement ordering
- Use Edit to apply formatting corrections to each file.
- Report a summary of changes made.
Rules
- Only modify formatting — never change logic, variable names, or functionality.
- Work across the project directory as specified by the user.
- Process user-provided style preferences (indent width, tab vs space) when given.
- All changes are in git-tracked files and can be reverted with
git checkout.