Write Coding Standards
Purpose
Give the team a small, enforceable set of conventions that removes recurring debates from code review and makes code look like one team wrote it. Every rule carries its reason, so people can apply it to cases the rule did not foresee.
When to use
- A new team, repository or language needs agreed conventions.
- Reviews repeatedly debate the same topics (naming, error handling, test style, PR size).
- Existing standards are long, outdated, contradicted by the codebase, or not followed.
When not to use
- Reviewing a specific change against clean code principles. Use
clean-code-review or code-review.
- Team working norms beyond code (meetings, availability, on-call). Use
working-agreement.
- A single significant architectural decision. Use
adr.
Inputs
Required:
- The language(s) and scope (repository, service, team), and the pain points or topics the standards must settle.
Optional, improves quality:
- Current standards, linter and formatter configuration, examples of contested review threads.
- Architecture style and layering rules, testing approach, security requirements.
- Team size and experience mix, regulatory or customer constraints.
If the language or scope is missing, ask. Ask at most five focused questions about the contested topics; turn anything unanswered into a proposed rule marked [PROPOSAL] for team discussion.
Process
- Collect the topics: contested review themes, recurring defects, onboarding questions. Rank by how often they cost review time or cause bugs.
- Delegate to tools first: anything a formatter or linter can enforce (formatting, import order, simple naming patterns, complexity limits) becomes a tool rule with a reference to the config, not prose.
- Adopt a widely used community style guide for the language as the baseline instead of re-deriving it; list only the team's deviations and additions.
- Write the remaining rules for judgment topics: naming and domain language, error handling and logging, module boundaries and dependencies, null and optional handling, concurrency, testing conventions, comments and documentation, security-sensitive patterns (input validation, secrets, SQL), PR size and commit conventions.
- Give each rule an ID, a one-line imperative statement, severity (Must: blocks merge / Should: default, deviate with a reason), rationale in one or two sentences, and a bad and a good example in the team's language.
- Define enforcement per rule: formatter, linter rule, static analysis, architecture test, CI check, or review. Rules enforced only by review should be few.
- Check the set for conflicts with each other, with the existing codebase (how much would violate it) and with frameworks in use; add a migration note (new code only, or boy-scout rule on touched code) rather than demanding a mass rewrite.
- Keep it short: aim for a document the team reads in about ten minutes; move rare details to linked pages.
- Define the change process: who can propose changes, how decisions are made, and how exceptions are recorded (inline suppression with reason).
- Mark inferred rules
[PROPOSAL] and list open decisions for the team. If the user continues, suggest working-agreement to adopt the standards formally, clean-code-review to review code against them, or adr for significant decisions within them.
Output format
# Coding Standards: <team / repository>
Scope: <languages, repos> · Baseline: <community style guide> · Owner: <name or [UNKNOWN]> · Version: <n>
## Enforced by Tools
| Area | Tool / config | Notes |
|---|---|---|
## Rules
### <ID> <Imperative rule statement> (Must/Should)
Why: <rationale>
Bad:
<code>
Good:
<code>
Enforced by: <linter rule / architecture test / review>
## Adoption
- Applies to: <new code / touched code> · Exceptions: <how recorded>
## Changing These Standards
- ...
## Open Decisions
- [PROPOSAL] ...
Quality checklist
Common pitfalls
- Writing a long style manual about formatting. Formatters settle that for free; spend words on design and error-handling rules.
- Rules without rationale ("Do not use X"). People follow reasons, and reasons help decide the unforeseen cases.
- Standards that the existing codebase violates everywhere with no adoption plan; they are ignored within weeks.
Example
Input: "Backend team, arguments about exceptions, naming, PR size."
Weak rule: "Handle exceptions properly."
Strong rule:
ERR-2 Do not catch an exception unless you can handle it or add context (Must)
Why: swallowed or re-wrapped-without-context exceptions hide root causes and break alerting.
Bad:
try { charge(order) } catch (e) { log.warn("error") }
Good:
try { charge(order) } catch (e: GatewayTimeout) { throw PaymentFailed(orderId = order.id, cause = e) }
Enforced by: static analysis rule for empty or log-only catch blocks; review for context.
1---2name: coding-standards3description: "Writes or revises a team's coding standards as a short set of numbered rules, each with rationale, a good and a bad example, a severity (must or should) and how it is enforced (formatter, linter, review, test), focusing on decisions that tools cannot settle. Use when a team is forming or merging, reviews keep arguing about the same style or design questions, a new language or framework is adopted, or existing standards are too long, outdated or ignored."4license: MIT5metadata:6 source: https://skillmd.com/skills/muratdincer/coding-standards7 version: "1.0.0"8 language: en9 category: 05-engineering10 role: tech-lead11 area: leadership12 title: "Write coding standards"13 related: "clean-code-review, code-review, review-comment-writing, working-agreement, adr"14 prompt: "Write coding standards for our backend team. We keep arguing in reviews about exception handling, naming and how big a pull request should be."15---1617# Write Coding Standards1819## Purpose20Give the team a small, enforceable set of conventions that removes recurring debates from code review and makes code look like one team wrote it. Every rule carries its reason, so people can apply it to cases the rule did not foresee.2122## When to use23- A new team, repository or language needs agreed conventions.24- Reviews repeatedly debate the same topics (naming, error handling, test style, PR size).25- Existing standards are long, outdated, contradicted by the codebase, or not followed.2627## When not to use28- Reviewing a specific change against clean code principles. Use `clean-code-review` or `code-review`.29- Team working norms beyond code (meetings, availability, on-call). Use `working-agreement`.30- A single significant architectural decision. Use `adr`.3132## Inputs33Required:34- The language(s) and scope (repository, service, team), and the pain points or topics the standards must settle.3536Optional, improves quality:37- Current standards, linter and formatter configuration, examples of contested review threads.38- Architecture style and layering rules, testing approach, security requirements.39- Team size and experience mix, regulatory or customer constraints.4041If the language or scope is missing, ask. Ask at most five focused questions about the contested topics; turn anything unanswered into a proposed rule marked `[PROPOSAL]` for team discussion.4243## Process441. Collect the topics: contested review themes, recurring defects, onboarding questions. Rank by how often they cost review time or cause bugs.452. Delegate to tools first: anything a formatter or linter can enforce (formatting, import order, simple naming patterns, complexity limits) becomes a tool rule with a reference to the config, not prose.463. Adopt a widely used community style guide for the language as the baseline instead of re-deriving it; list only the team's deviations and additions.474. Write the remaining rules for judgment topics: naming and domain language, error handling and logging, module boundaries and dependencies, null and optional handling, concurrency, testing conventions, comments and documentation, security-sensitive patterns (input validation, secrets, SQL), PR size and commit conventions.485. Give each rule an ID, a one-line imperative statement, severity (Must: blocks merge / Should: default, deviate with a reason), rationale in one or two sentences, and a bad and a good example in the team's language.496. Define enforcement per rule: formatter, linter rule, static analysis, architecture test, CI check, or review. Rules enforced only by review should be few.507. Check the set for conflicts with each other, with the existing codebase (how much would violate it) and with frameworks in use; add a migration note (new code only, or boy-scout rule on touched code) rather than demanding a mass rewrite.518. Keep it short: aim for a document the team reads in about ten minutes; move rare details to linked pages.529. Define the change process: who can propose changes, how decisions are made, and how exceptions are recorded (inline suppression with reason).5310. Mark inferred rules `[PROPOSAL]` and list open decisions for the team. If the user continues, suggest `working-agreement` to adopt the standards formally, `clean-code-review` to review code against them, or `adr` for significant decisions within them.5455## Output format56```markdown57# Coding Standards: <team / repository>58Scope: <languages, repos> · Baseline: <community style guide> · Owner: <name or [UNKNOWN]> · Version: <n>5960## Enforced by Tools61| Area | Tool / config | Notes |62|---|---|---|6364## Rules65### <ID> <Imperative rule statement> (Must/Should)66Why: <rationale>67Bad:68 <code>69Good:70 <code>71Enforced by: <linter rule / architecture test / review>7273## Adoption74- Applies to: <new code / touched code> · Exceptions: <how recorded>7576## Changing These Standards77- ...7879## Open Decisions80- [PROPOSAL] ...81```8283## Quality checklist84- [ ] Every rule has an ID, severity, rationale and a bad/good example.85- [ ] Anything a tool can enforce is delegated to a tool, not written as prose.86- [ ] Rules do not contradict each other or the chosen baseline guide.87- [ ] Each Must rule has an enforcement mechanism other than memory.88- [ ] Rules inferred rather than agreed are marked `[PROPOSAL]` and appear in open decisions.89- [ ] The document is short enough to read in about ten minutes.90- [ ] All checks pass; if any fails, revise the output and re-run this checklist before answering.9192## Common pitfalls93- Writing a long style manual about formatting. Formatters settle that for free; spend words on design and error-handling rules.94- Rules without rationale ("Do not use X"). People follow reasons, and reasons help decide the unforeseen cases.95- Standards that the existing codebase violates everywhere with no adoption plan; they are ignored within weeks.9697## Example98Input: "Backend team, arguments about exceptions, naming, PR size."99100Weak rule: "Handle exceptions properly."101102Strong rule:103### ERR-2 Do not catch an exception unless you can handle it or add context (Must)104Why: swallowed or re-wrapped-without-context exceptions hide root causes and break alerting.105Bad:106 try { charge(order) } catch (e) { log.warn("error") }107Good:108 try { charge(order) } catch (e: GatewayTimeout) { throw PaymentFailed(orderId = order.id, cause = e) }109Enforced by: static analysis rule for empty or log-only catch blocks; review for context.