code-discipline
Skill2 starsChanged 5 months agoMITView on GitHub
Coding methodology for production-grade software development. Enforces structured thinking before coding, verifying reality, simplicity, surgical changes, contract awareness, and verifiable success criteria. Use when writing, reviewing, or refactoring code that needs to remain reliable over time, including production code, shared libraries, or code others will maintain. Triggers include "fix a bug", "add a feature", "refactor", "review code", "clean up", or explicit "apply code-discipline". Do NOT use for throwaway scripts, one-off prototypes, or quick demos.
- Commits and pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- EthanSei/skillstheir own version, first seen Feb 28, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- EthanSei/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/code-discipline.mdcCursor rule
The file
Show its rules and text
We split this skill into the rules it gives an agent
37 rules. About 0 are common, 35 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈35
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Not a communication standard.
- Distinctive: line 21
Every technical decision is evaluated in this order:
- Distinctive: line 39
Before writing any code, present all four:
- Distinctive: line 46
If uncertain — ask, don't assume and proceed
- Distinctive: line 47
If multiple interpretations exist — present them, don't pick silently
- Distinctive: line 48
If a simpler approach exists — say so and push back
- Distinctive: line 49
If information is missing — stop and ask.
- Distinctive: line 57
Before writing or changing code:
- Distinctive: line 58
Read the actual files involved.
- Distinctive: line 59
Don't invent APIs, function names, type names, field names, environment variables, configuration keys, or imports.
- Distinctive: line 60
Don't assume a pattern, helper, or utility exists unless you verified it in the repository.
- Distinctive: line 61
Don't assume a third-party library behaves a certain way without checking its documentation or signature.
- Distinctive: line 62
If you cannot find evidence in the codebase, say so explicitly: *"I couldn't find this in the code"* — and stop.
- Very specific: line 66
Evidence standard for claims: When stating that code works, that a test passes, or that a file does something specific, cite file:line and …
- Distinctive: line 74
No features beyond what was asked
- Distinctive: line 75
No abstractions for single-use code
- Distinctive: line 77
No error handling for impossible scenarios
- Distinctive: line 78
If you write 200 lines and it could be 50, rewrite it
- Distinctive: line 80
All code must be modular, readable, testable, and defensible in a code review.
- Distinctive: line 83
Ask: *"Would a senior engineer say this is overcomplicated?"* If yes, simplify.
- Distinctive: line 91
When editing existing code:
- Distinctive: line 92
Don't "improve" adjacent code, comments, or formatting
- Distinctive: line 93
Don't refactor things that aren't broken
- Distinctive: line 95
If you notice unrelated dead code, mention it — don't delete it
- Very specific: line 96
Remove only imports/variables/functions that YOUR changes made unused
- Distinctive: line 100
BEFORE — Read the file completely.
- Distinctive: line 106
AFTER — Run affected tests.
- Distinctive: line 107
Verify tests assert real-world behavior, not just mock matches.
- Distinctive: line 108
Document in changelog with facts, not narrative.
- Distinctive: line 110
BEFORE COMMIT — Get explicit approval.
- Distinctive: line 120
Before changing behavior, identify the contracts your change touches.
- Distinctive: line 131
Don't change a contract silently.
- Distinctive: line 132
If a contract must change, surface the impact: who consumes it, what breaks, what migration looks like.
- Distinctive: line 133
Prefer additive changes (new field, new endpoint, new flag) over breaking changes (rename, remove, restructure).
- Distinctive: line 134
When in doubt about who depends on a surface, search the codebase and ask before changing.
- Distinctive: line 159
Every change must include tests, or a clear explanation of why not
- Distinctive: line 186
Before each step, answer all four:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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.
Files
Code Discipline
A coding methodology for production systems that must last. Not a communication standard. Not an honesty protocol. Purely: how to write code well.
Tradeoff: This discipline biases toward correctness and simplicity over speed and cleverness. For throwaway scripts, apply judgment. For production code — apply everything.
Priority Order
Every technical decision is evaluated in this order:
- Stability
- Reliability
- Readability
- Maintainability
- Scalability
- Performance
- Elegance
The goal is not "it works" — it is "it works correctly and reliably one year from now."
1. Think Before Coding
Don't assume. Surface tradeoffs. Map blast radius.
Before writing any code, present all four:
- Working assumptions — what are you assuming to be true?
- Constraints and risks — what could go wrong?
- Multiple valid solutions? — if yes, stop and present options; do not choose independently
- Dependencies and blast radius — what else is affected by this change?
Rules:
- If uncertain — ask, don't assume and proceed
- If multiple interpretations exist — present them, don't pick silently
- If a simpler approach exists — say so and push back
- If information is missing — stop and ask; do not proceed without answers
2. Verify Reality Before Acting
Don't code from memory. The codebase is the source of truth.
Before writing or changing code:
- Read the actual files involved. Don't work from a remembered shape.
- Don't invent APIs, function names, type names, field names, environment variables, configuration keys, or imports.
- Don't assume a pattern, helper, or utility exists unless you verified it in the repository.
- Don't assume a third-party library behaves a certain way without checking its documentation or signature.
- If you cannot find evidence in the codebase, say so explicitly: "I couldn't find this in the code" — and stop. Do not fill the gap from memory.
The test: Every function call, import, type, and field in your code must trace to a verified source — an actual file, an actual signature, or documentation you read.
Evidence standard for claims: When stating that code works, that a test passes, or that a file does something specific, cite file:line and the quoted code or output. Paste actual command output rather than summarizing it. "It should work" and "I believe" are not evidence.
3. Simplicity First
Minimum code that solves the problem. Nothing speculative.
- No features beyond what was asked
- No abstractions for single-use code
- No "flexibility" or "configurability" that wasn't requested
- No error handling for impossible scenarios
- If you write 200 lines and it could be 50, rewrite it
All code must be modular, readable, testable, and defensible in a code review. There must be no magic numbers, hidden state, overly clever constructs, or silent failures.
Ask: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
4. Surgical Changes
Touch only what you must. Clean up only your own mess.
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting
- Don't refactor things that aren't broken
- Match existing style, even if you'd do it differently
- If you notice unrelated dead code, mention it — don't delete it
- Remove only imports/variables/functions that YOUR changes made unused
Required steps:
BEFORE — Read the file completely. Map dependencies and blast radius. Identify affected tests. Check if a suitable solution already exists in the project.
DURING — Change only what's needed. No unrelated refactoring. Preserve working behavior. No duplication.
AFTER — Run affected tests. Run full test suite. Verify zero regressions. Verify tests assert real-world behavior, not just mock matches. Document in changelog with facts, not narrative.
BEFORE COMMIT — Get explicit approval. Show exactly what's being committed. No hidden files.
The test: Every changed line should trace directly to the request.
5. Respect Existing Contracts
Public surfaces are commitments. Treat them as such.
Before changing behavior, identify the contracts your change touches. Contracts include:
- Function and method signatures (parameters, return types, thrown errors)
- API request and response shapes
- Database schemas and column types
- Event names and payloads
- CLI flags and command names
- Configuration keys and environment variables
- Error codes and error formats
- File formats your code reads or writes
Rules:
- Don't change a contract silently. A silent rename, removal, or reshape is a breaking change disguised as cleanup.
- If a contract must change, surface the impact: who consumes it, what breaks, what migration looks like.
- Prefer additive changes (new field, new endpoint, new flag) over breaking changes (rename, remove, restructure).
- When in doubt about who depends on a surface, search the codebase and ask before changing.
The test: If your change crosses a system boundary, you must name the boundary and the consumers before changing it.
6. Goal-Driven Execution
Define success criteria. Loop until verified.
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a plan:
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]Checkpoint between steps: Complete and verify each step before starting the next. Do not chain steps without confirming the previous one succeeded. Catching divergence at step 2 is much cheaper than catching it at step 5.
Testing principles:
- Every change must include tests, or a clear explanation of why not
- Tests must verify real behavior — not just match mocks
- A passing suite means the tests think it works — verify they test the right thing
- State certainty level explicitly when uncertain about an API or behavior
Strong success criteria let you work independently. Weak criteria ("make it work") require constant clarification.
Mandatory Prohibitions
| Prohibition | Detail |
| ❌ No guessing or inventing | If information is missing — stop and ask. Never fill gaps independently. |
| ❌ No unrequested features | No "we could also" implemented. Any addition requires explicit approval. |
| ❌ No broad refactors | Change only what was requested. No "while I'm here" modifications. |
| ❌ No band-aids | No temporary values without expiry. No hardcoded test values in production. No silent error swallowing. |
| ❌ No claims without evidence | When stating that code works, that a test passes, or that a file does something — cite file:line plus the quoted code or output. Paste actual command output, do not summarize it. "It should work" is not evidence. |
| ❌ No fake completion | Never claim "done" without verification. If something was not verified, say so explicitly: "Implemented, but not verified because..." |
| ❌ No dangerous actions without approval | Explicit approval required before destructive actions: deleting files, dropping schemas, force-pushing, removing tests, disabling checks, large rewrites, or modifying authentication or authorization logic. |
| ❌ No committing without approval | The user must say "commit now" before git commit, "push now" before git push, "deploy now" before deployment. |
Mandatory Review Questions
Before each step, answer all four:
- Is this the most professional and simplest solution?
- Does this change preserve what already works?
- Is this a reasonable production-grade solution?
- Would this pass code review at a top-tier engineering organization?
Only if all four answers are positive — proceed.
These guidelines are working if: changes are smaller and more focused, no unrequested features appear in diffs, every task has a verifiable definition of done before work begins, and contracts are preserved unless an explicit migration is agreed upon.
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
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.

