---
name: coding-standards-enforcer
description: "Applies one shared floor of naming, structure, error handling, and readability rules to a file or diff and returns the edits that bring it up to standard. Use when a file or diff needs to match a team's naming, structure, error handling, and readability rules before review. Do not use for hunting bugs or judging architecture and performance. Related topics: coding, technical."
---

# Coding Standards Enforcer

Applies one shared floor of naming, structure, error handling, and readability rules to a file or diff and returns the edits that bring it up to standard.

## When to use

Use this skill when a file or diff needs to match a team's naming, structure, error handling, and readability rules before review. Do not use it for hunting bugs or judging architecture and performance.

## Workflow

1. Ask the user for each input listed below in a single message, skipping any they have already given. Where options are listed, offer them, but accept other answers too.
2. Infer the conventions already in use from the code and any stated guide, and write them down as the standard to hold to.
3. Check the code against each selected rule in turn, listing every violation with its location.
4. Apply the fix for each violation at the chosen strictness, leaving behaviour unchanged and flagging any change that could alter output.
5. Re-read the result to confirm the same inputs would still produce the same outputs.
6. Return the cleaned code or edit list with a count of places touched per rule and the items left alone.

## Inputs

- **The code** (longer free text)
- **Language** (free text, e.g. "Language and version")
- **Existing conventions** (longer free text)
- **Rules to enforce** (choose any: Naming, Function size, Error handling, Comments, Dead code, Duplication, Module structure)
- **Strictness** (choose one: Suggest only, Fix obvious issues, Rewrite fully)

## Output

The cleaned code or an edit list, then a short summary table of rules applied with counts and a note on anything deliberately left unchanged.

## Prompt template

Fill the inputs into this template and follow it as the full instruction.

### Coding Standards Enforcer

Bring this code up to our team standard without changing what it does.

- The code: {{The code}}
- Language: {{Language}}
- Existing conventions: {{Existing conventions}}
- Rules to enforce: {{Rules to enforce}}
- Strictness: {{Strictness}}

Start by inferring the conventions the codebase already follows from the pasted code and the stated rules, and treat those as the standard; do not impose a personal style. Go through the selected rules in order. For naming, make names say what a thing is or does. For function size, split only where a block has a clear single purpose. For error handling, make sure failures are handled or passed on with context, never swallowed. Remove dead code and unused imports, but leave comments that explain a reason.

Keep behaviour identical: if a change could alter output, flag it instead of making it. Return the cleaned code (or the list of suggested edits, depending on strictness) and a short list of each rule applied with the number of places it touched. Mention anything you left alone on purpose and why.

## Pitfalls

- Imposing personal style over the conventions the codebase already follows, which makes the diff noisy and invites argument.
- Renaming public identifiers that other files depend on, breaking callers the review never saw.
- Splitting functions into tiny pieces that are harder to follow than the original block.
