resources/skills/x-format-code/SKILL.md
Formats source code; first step of the pre-commit chain (format -> lint -> compile).
npx skillsauth add edercnj/claude-environment x-format-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Ensures source code in {{PROJECT_NAME}} follows a consistent style before commits. First step of the pre-commit chain (RULE-007: x-format-code -> x-lint-code -> compile -> commit). Detects {{LANGUAGE}}, selects the appropriate formatter, runs it, and re-stages modified files automatically.
/x-format-code -- format all project files/x-format-code --check -- verify formatting without modifying files (CI mode)/x-format-code --changed-only -- format only modified files (staged + unstaged)| Parameter | Required | Description |
|-----------|----------|-------------|
| --check | No | Dry-run: exit 0 if formatted, exit 1 if not. No files modified. |
| --changed-only | No | Format only files detected via git diff (staged + unstaged). |
--check). Previously-staged files are automatically re-staged after format.0 success / nothing to do; 1 formatter not installed, execution failure, or violations under --check.references/full-protocol.md §1 for the full mapping. Slim summary: spotless (java), prettier (typescript), ruff/black (python), gofmt (go), rustfmt (rust), ktfmt (kotlin).Chain-wide error matrix. Canonical
format -> lint -> compile -> commitrows live in_shared/error-handling-pre-commit.md. Rows below arex-format-code-specific.
| Scenario | Behavior | Exit |
|----------|----------|------|
| Unsupported language ({{LANGUAGE}} not in table) | Report warning, do NOT block chain | 0 |
| No formatter installed (primary + fallback missing) | Report error with install instructions | 1 |
| Formatter execution fails | Report error with stderr output | 1 |
| No files to format | Report "No files to format" | 0 |
| --check finds violations | List files needing formatting | 1 |
| Re-stage failure (git add error) | Report error with git stderr | 1 |
Minimum viable contract above. Detailed language/formatter mapping, the 6-step workflow (detect → select → scope → execute → re-stage → report), build-tool configuration examples (Maven/Gradle/npm/Python/Go/Rust), and per-language file extension lists live in references/full-protocol.md per ADR-0012 (skill body slim-by-default). Happy-path invocation needs only this SKILL.md; full protocol is consulted when a new language or fallback formatter is introduced.
| Skill | Relationship | Context |
|-------|-------------|---------|
| x-lint-code | follows | Second step of the pre-commit chain (after format). |
| x-commit-changes | orchestrator | Invokes this skill as step 3a of its chain. |
| Variable | Description | Example |
|----------|-------------|---------|
| {{LANGUAGE}} | Project language | java |
| {{BUILD_TOOL}} | Project build tool | maven |
| {{PROJECT_NAME}} | Project name | my-java-cli |
tools
Documentation automation v2: stack-aware generation from documentation.targets.
development
Generates or updates CI/CD pipelines per project stack with actionlint validation.
tools
Generates ADRs from architecture-plan mini-ADRs with sequential numbering and index update.
documentation
Reads PR review comments and fixes actionable ones with Conventional Commits.