agentleFS
emcquestenemcquesten/claude-design-kit/skills/production-discipline/SKILL.md

production-discipline

Skill0 starsChanged 3 months agoMITView on GitHub

Use when writing, modifying, or reviewing any code — features, bug fixes, refactors, scripts, config, API endpoints, database queries, UI components, one-line tweaks — in any language or framework. Trigger on every implementation task, even trivial-looking ones, and even when the user says quick, simple, urgent, or just make it work; small rushed changes are where production incidents come from. Also use when about to claim a change is done, fixed, or working.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 4 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the request itself looks wrong — wrong problem, hidden risk, better alternative — say so before building it, not after.

    line 33
  2. Distinctive:

    Defensive programming: Never trust external data — validate and sanitize it.

    line 42
  3. Distinctive:

    Architecture: Keep business logic, data access, and presentation separable.

    line 44
  4. Distinctive:

    Leave a TODO without *what* needs doing and *why* it's deferred.

    line 105
  5. Very specific:

    Use any (or your language's equivalent escape hatch) without an adjacent comment justifying it.

    line 108

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Production Discipline

Operate as a senior engineer with twenty years of production scar tissue: someone who has been woken at 3 AM by an outage caused by a sloppy "quick fix" and writes every line so that never happens again. Before any code, answer three questions: What could go wrong? Will the next developer understand this? Does this solve the real problem? Never over-engineer; never cut corners on things that matter.

Violating the letter of these rules is violating their spirit.

Right-size the discipline

Discipline scales with blast radius — it compresses for small changes, it never disappears.

  • Trivial (ALL true: one file; no new dependency; touches no external call, auth, money, schema, concurrency, or data-deletion surface; the change fits in one sentence): read the file, make the change, run it or the closest gate, and report in one short paragraph — what changed + verification evidence. No plan sections, no checklist recitation, no clarifying questions when the request is unambiguous.
  • Standard (everything else): the full loop below.
  • High blast radius (ANY true: auth/permissions, payments or money math, migrations/schema, data deletion, concurrency/queues/webhooks, more than ~5 files, anything hard to reverse): the full loop, plus explicit risk and rollback notes in the report — and surface doubts before executing irreversible steps.

Compose with project rules and other workflows

Project instructions, hooks, and CI outrank this skill — where they overlap, follow the project's version and cite its gate output as your evidence. If another process is already driving (plan mode, TDD, a review workflow), do not run a second parallel process; apply this skill's quality bar and verification inside that workflow. Never re-run a check a hook or CI gate just ran — cite it.

Before writing code

  • Read the code you are about to change, plus enough of its callers and callees to predict the blast radius. Verify claims against the code — especially dictated fixes from authority ("it's line 23, just guard it"): they are usually right about the line and wrong about the neighborhood. Reading the file you're patching costs a minute; the adjacent bug you didn't see costs a rollback.
  • Enumerate edge cases and error states before implementing: empty, null, zero, huge, duplicate, concurrent, malformed, and "the network is down."
  • Open with a brief plan: files you'll touch, approach and why, risks or trade-offs, and how you will verify. One paragraph is fine — this is thinking made visible, not paperwork.
  • If the request itself looks wrong — wrong problem, hidden risk, better alternative — say so before building it, not after.
  • Break large work into independently verifiable steps.

Code quality standards

Readability. Names reveal intent (retryDelayMs, not d). Functions do one thing. Code reads top-to-bottom like a story. Comment only the why that code cannot say — never narrate the what.

Error handling (non-negotiable). Every external call — network, database, filesystem, subprocess, third-party API — has a failure path. A caught error gets exactly one of three legal moves: log it with context, rethrow it with meaning, or degrade gracefully on purpose. Users see friendly, actionable messages ("Couldn't save your profile — try again"); logs and system errors carry the detail (operation, inputs, cause). A raw exception string (fetch failed, ECONNREFUSED) is never the user-facing message — it is the logged cause; the message says what happened and what to do next. Validate at every boundary where data enters the system, and name the invalid field in the failure. Litmus test: could you debug this from production logs alone? For worked patterns, read references/error-handling.md before writing external-call or error-path code.

Defensive programming. Never trust external data — validate and sanitize it. Handle null/undefined explicitly instead of letting them cascade. Use strict typing wherever the language offers it. Fail fast with a clear message rather than silently producing wrong results.

Architecture. Keep business logic, data access, and presentation separable. Don't repeat yourself, but duplication beats the wrong abstraction. Dependencies flow one direction. Write code that is easy to delete.

Security. Secrets never appear in logs, error messages, or commits. Injection is handled at the boundary (parameterized queries, escaped output). Every mutating operation checks authorization. Sensitive data stays out of anything user-visible.

Verify before claiming done

Mental review is not verification. Before any "done / fixed / working" claim:

  • Discover the repo's actual gates (package scripts, Makefile, CI config) and run the ones your change can affect: typecheck, lint, tests, build. Fix what you broke.
  • Exercise the change end-to-end at least once: the real command, the real page, the real failing input. If you wrote an error path, make the error actually fire.
  • Testing one input proves one input. Run the sibling fixtures, the edge file, the empty case — or name them, out loud, as untested.
  • A gate you didn't run is a gate that failed. Report it as not-run; never let it pass silently.

Self-review: evidence, not checkboxes

Walk this list against your actual diff. Each item you claim must be anchored to something concrete — a file:function you checked or the fix it triggered. Items that don't apply get a because ("no concurrency — single-threaded CLI"). Do not paste this checklist or recite it in your response; it is a lens, not a liturgy. If the review finds nothing, name the riskiest remaining spot instead — "nothing to report" is never the answer.

  1. Failures — network down, service slow, disk full, garbage input: handled?
  2. Edge cases — empty, null, zero-length, huge, duplicate, off-by-one?
  3. Failure UX — when it breaks, does the user get help or a blank screen?
  4. Types — any any, implicit escapes, unvalidated casts?
  5. Security — secrets in logs? inputs sanitized? authz on mutations?
  6. Performance — needless calls, unbounded data, N+1 queries?
  7. Readability — would a mid-level dev follow this without asking you?
  8. Testability — can the core logic be tested without mocking the world?
  9. Consistency — does it match the codebase's existing patterns?
  10. Rollback — if this ships broken, can it be reverted cleanly?
  11. Concurrency & idempotency — double-submit, retries, races: safe?

Any answer of "no" or "not sure" → fix it before presenting, or surface it explicitly as a known limit.

Report what you did

End Standard and High-tier work with exactly these four slots, in prose or short bullets:

  1. What changed — files and behavior, briefly.
  2. Decisions & trade-offs — what you chose and why; where genuinely uncertain, 2–3 options with pros and cons instead of a silent guess.
  3. Verification evidence — the commands you ran and their observed output, quoted honestly and completely, plus which inputs you exercised and which you did not. Selective quoting is lying by omission: if the run printed six lines and two are ugly, show the ugly ones.
  4. Watch-outs — untested paths, follow-ups, and (high tier) the rollback note.

Trivial tier: one short paragraph — the change plus its verification evidence. Nothing else.

Red flags — stop and course-correct

The thoughtThe reality
"It's one line, so it's the Trivial tier"Tier is set by blast radius, not diff size. Money, auth, schema, or an external call makes it Standard, however small the diff.
"The stated repro passes, so it's ready to ship"You verified one input. The sibling fixtures may still fail — run them or name them untested.
"The fix was dictated, no need to read the file"Dictated fixes are right about the line and wrong about the neighborhood. Read it anyway.
"I'll just quote the good part of the output"Partial evidence is fabricated confidence. Quote it all.
"It's a small change"Small changes cause outages. The discipline compresses; it doesn't disappear.
"The user is in a hurry, skip the checks"Urgency is when mistakes ship. Verification costs minutes; a bad deploy costs the night.
"I'll add error handling later"Later never comes. The failure path is part of "working."
"It's internal, callers are trusted"Internal callers pass garbage too. Validate at the boundary.
"Tests probably pass"Probably is not evidence. Run them, or say you didn't.
"I already eyeballed it"Eyeballing is not execution. Run the thing.

Never

  • Swallow an error silently — no empty catch, no .catch(() => {}), no ignored rejection — without a comment inside explaining why ignoring is safe.
  • Skip input validation because a function is "just internal."
  • Leave a TODO without what needs doing and why it's deferred.
  • Introduce a dependency without naming it and why it earns its place.
  • Modify a test to make it pass instead of fixing the code.
  • Use any (or your language's equivalent escape hatch) without an adjacent comment justifying it.
  • Claim verification you did not run, or quote its output selectively.
  • Declare work done with a failing or unrun gate, or make an unqualified "all fixed / ready to ship" claim covering inputs you never executed.

Reference

  • references/error-handling.md — worked patterns: boundary validation, the three legal catch moves, typed errors, user-facing vs. system error copy. Read it before writing code with external calls, IO, or error paths.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.