Skip to content
Back to skills

Code Format

ASecurity

Format code using dotnet format, prettier, and other formatting tools. Use when task involves code style fixes, formatting consistency, or preparing code for commit.

  • 666 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 8, 2026
developmentjavascripttypescriptgojavac#bashrailstestingci/cdperformance

Works with

  • cli

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill code-format --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Code Format?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Code Format
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-code-format/badge)](https://www.skillsdirectory.com/skills/majiayu000-code-format)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: code-format
version: 0.1.0
kind: cli
description: Format code using dotnet format, prettier, and other formatting tools. Use when task involves code style fixes, formatting consistency, or preparing code for commit.
inputs:
  target: [dotnet, prettier, all]
  files: string[]
  verify: boolean
contracts:
  success: 'Code formatted successfully; no style violations remaining'
  failure: 'Non-zero exit code or formatting errors'
---

# 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`](references/dotnet-format.md)

- Format C# files (.cs), apply dotnet format rules, fix code style issues

**2. Format with Prettier** → [`references/prettier-format.md`](references/prettier-format.md)

- Format JSON, YAML, Markdown, JavaScript, TypeScript files

**3. Format All Code** → [`references/fix-all.md`](references/fix-all.md)

- Run all formatters in sequence (dotnet + prettier), comprehensive formatting

## Common Patterns

### Quick Format (.NET)

```bash
cd ./dotnet
dotnet format PigeonPea.sln
```

### Quick Format (Prettier)

```bash
npx prettier --write "**/*.{json,yml,yaml,md}"
```

### Format Everything

```bash
./.agent/skills/code-format/scripts/format-all.sh
```

### Verify Only (Check Mode)

```bash
cd ./dotnet
dotnet format PigeonPea.sln --verify-no-changes
```

### Format Specific Files

```bash
# .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`](../../../.editorconfig) - Formatting rules
- [`.prettierrc.json`](../../../.prettierrc.json) - Prettier config
- [`.pre-commit-config.yaml`](../../../.pre-commit-config.yaml) - Pre-commit hooks
- [`setup-pre-commit.sh`](../../../setup-pre-commit.sh) - Pre-commit setup script

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.