Agent skill
code-format
Format code using dotnet format, prettier, and other formatting tools. Use when task involves code style fixes, formatting consistency, or preparing code for commit.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/development/code-format
SKILL.md
Code Format Skill (Entry Map)
Goal: Guide agent to the exact formatting procedure needed.
Quick Start (Pick One)
- Format .NET code (C#) →
references/dotnet-format.md - Format JSON/YAML/Markdown →
references/prettier-format.md - Format everything →
references/fix-all.md
When to Use
- Fix code style violations (indentation, spacing, line endings)
- Apply .editorconfig rules consistently
- Prepare code for commit (pre-commit hook formatting)
- Enforce team coding standards
- Format specific files or entire codebase
NOT for: building (dotnet-build), testing (dotnet-test), or linting (code-analyze)
Inputs & Outputs
Inputs: target (dotnet/prettier/all), files (specific files or directories), verify (check-only mode)
Outputs: Formatted files (modified in-place), exit code (0=success, non-zero=violations)
Guardrails: Non-destructive (can run with --verify-no-changes), respects .editorconfig, integrates with pre-commit
Navigation
1. Format .NET Code → references/dotnet-format.md
- Format C# files (.cs), apply dotnet format rules, fix code style issues
2. Format with Prettier → references/prettier-format.md
- Format JSON, YAML, Markdown, JavaScript, TypeScript files
3. Format All Code → references/fix-all.md
- Run all formatters in sequence (dotnet + prettier), comprehensive formatting
Common Patterns
Quick Format (.NET)
cd ./dotnet
dotnet format PigeonPea.sln
Quick Format (Prettier)
npx prettier --write "**/*.{json,yml,yaml,md}"
Format Everything
./.agent/skills/code-format/scripts/format-all.sh
Verify Only (Check Mode)
cd ./dotnet
dotnet format PigeonPea.sln --verify-no-changes
Format Specific Files
# .NET
dotnet format --include ./console-app/Program.cs
# Prettier
npx prettier --write ./README.md
Troubleshooting
Format fails: Check error messages. See specific reference files for detailed error handling.
Files not formatted: Check .editorconfig rules, file extensions, ignore patterns.
Pre-commit hook fails: Run formatters manually first, then commit. See references/fix-all.md.
Conflicting styles: .editorconfig takes precedence. Check configuration files.
Performance issues: Format specific projects/files instead of entire solution.
Success Indicators
dotnet format
Format complete in X ms.
No files changed (if already formatted), or list of formatted files.
prettier
✔ Formatted X files
Or no output if all files already formatted.
Integration
Before commit: Use pre-commit hooks to auto-format (configured in .pre-commit-config.yaml)
Manual formatting: Run before pushing code, before PR creation
CI/CD: Verify formatting in CI (use --verify-no-changes / --check mode)
With other skills:
- Before: code-analyze (fix style first)
- After: dotnet-build (build clean code)
Configuration Files
.editorconfig: Defines formatting rules (indent size, line endings, etc.).prettierrc.json: Prettier configuration (print width, quotes, etc.).pre-commit-config.yaml: Pre-commit hook configuration.prettierignore: Files to exclude from prettier formatting
Related
.editorconfig- Formatting rules.prettierrc.json- Prettier config.pre-commit-config.yaml- Pre-commit hookssetup-pre-commit.sh- Pre-commit setup script
Didn't find tool you were looking for?