SuperAPI AI Directory

code-format

General & other

View repository

Updated 10-15 22:16

About this skill

Code Format Skill (Entry Map)

Goal: Guides the agent to find the exact formatting procedure needed.

Quick Start (choose one)

  • .NET code formatting (C#) → references/dotnet-format.md
  • JSON/YAML/Markdown formatting → references/prettier-format.md
  • Format all items → references/fix-all.md

When to Use

  • Fix code style violations (indentation, whitespace, line breaks, etc.)
  • Apply .editorconfig rules consistently
  • Prepare code for commit (pre-commit hook formatting)
  • Comply with team coding standards
  • Format specific files or the entire codebase

Not for: Build (dotnet-build), test (dotnet-test), or linting (code-analyze)

Inputs & Outputs

Inputs: target (dotnet/prettier/all), files (specific file or directory), verify (check-only mode)

Outputs: Formatted files (modified directly in the file), exit code (0=success, non-zero=violations)

Guardrails: Non-destructive method (--verify-no-changes available to check without changes), respects .editorconfig, integrates with pre-commit

Navigation

1. Format .NET Code → references/dotnet-format.md

  • Formatting C# files (.cs), applying dotnet format rules, fixing code style issues

2. Format with Prettier → references/prettier-format.md

  • Formatting JSON, YAML, Markdown, JavaScript, TypeScript files

3. Format All Code → references/fix-all.md

  • Running all formatters (dotnet + prettier) sequentially, performing 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

Formatting failed: Check the error message. For detailed error handling, see the related reference file.

File not formatted: Check the .editorconfig rules, file extension, and ignore patterns.

Pre-commit hook failed: Run the formatter manually first, then commit. references/fix-all.mdSee.

Style conflict: .editorconfig takes precedence. Check the configuration file.

Performance issue: Format specific projects or files instead of the entire solution.

Success Indicators

dotnet format

Format complete in X ms.

If already formatted, there are no changed files, or a list of formatted files is displayed.

prettier

✔ Formatted X files

Or, if all files are already formatted, there is no output.

Integration

Before commit: Automatically format using the pre-commit hook (.pre-commit-config.yamlconfigured in) Manual formatting: Run before pushing code and before creating a PR CI/CD: Verify formatting in CI (using --verify-no-changes / --check mode)

Using with other SKILLs:

  • Previous step: code-analyze (fix style first)
  • Next step: dotnet-build (build clean code)

Configuration Files

  • .editorconfig: Define 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