speq-code-guardrails
Skill56 starsChanged 2 months agoMITView on GitHub
TDD cycle and code quality guardrails — failing-test-first, evidence, dependency, error-handling, and test-quality rules. Triggered by implementer-agent, implementer-expert-agent, and code-reviewer before any implementation or review work.
In this repository21 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- speq-adr-rulesSkill
- speq-auditSkill
- speq-cliSkill
- speq-code-reviewSkill
- speq-code-toolsSkill
- speq-design-philosophySkill
- speq-ext-researchSkill
- speq-git-disciplineSkill
- speq-git-operationsSkill
- speq-implement-prSkill
- speq-implementSkill
- speq-missionSkill
- speq-planningSkill
- speq-plan-prSkill
- speq-plan-reviewSkill
- speq-planSkill
- speq-recordSkill
- speq-spec-mergeSkill
- speq-writing-guardrailsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 14 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
No production code without a failing test first: Before changing existing code that has no test, add one that captures its current behavior …
- Distinctive: line 16
No claim without evidence: Run command, show output, then claim.
- Distinctive: line 30
Run ONLY the test you created/changed, not the full suite.
- Distinctive: line 40
Test code follows every rule in this document, same as production code.
- Distinctive: line 64
No boolean flags: split into separate methods
- Distinctive: line 65
No selector arguments of any type: an argument that picks a branch means two functions
- Distinctive: line 68
No output parameters: return the value
- Distinctive: line 70
No undocumented ordering contract between calls: if a second call requires a first, make it unreachable without it
- Distinctive: line 76
Every error states what was attempted, the input that failed, and the constraint violated
- Distinctive: line 78
Never discard an error, never catch broadly: handle at one level, let the rest propagate
- Distinctive: line 86
No prefixes or type encodings
- Distinctive: line 90
No role-suffix names that state no responsibility (Manager, Processor, Handler, Data, Info, Util)
- Distinctive: line 98
No inline comments: make the code self-explanatory
- Distinctive: line 99
No work tracking (TODOs, FIXMEs, ticket refs)
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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 Guardrails
TDD workflow and quality guardrails. Draws on established practice, including work by R. Martin, K. Beck, B. Meyer, and Toyota's Five Whys.
Golden Rule
No production code without a failing test first. Before changing existing code that has no test, add one that captures its current behavior first.
Evidence Rule
No claim without evidence. Run command, show output, then claim.
Dependency Rule
No new dependency without confirming the standard library or an already-installed dependency cannot do it first.
TDD Cycle (London School)
RED → Write failing test, run it, show failure
GREEN → Minimal code to pass, run test, show pass
REFACTOR → Clean up, run test + lint, show outputRun ONLY the test you created/changed, not the full suite.
Tests
- Arrange, act, assert. One concept per test.
- The test name states the condition and the expected behavior.
- Independent and repeatable: no shared mutable state, no real clock, network, filesystem, or unseeded randomness.
- Cover every branch and every edge case: empty, single, maximum, off-by-one, transition, and each way the operation can fail.
- Assert observable behavior, never internal state.
- Pure logic is tested without doubles. Orchestration is tested with doubles at its abstractions. Adapters are tested against the real thing.
- Test code follows every rule in this document, same as production code.
- A skipped or ignored test is a defect. Fix it or delete it.
Guiding Principles
| Principle | Meaning |
| KISS | Simplest solution that works |
| YAGNI | Build for now, not hypotheticals |
| DRY | Extract duplication on the third occurrence, not the second (Rule of Three) |
| Single Responsibility (SOLID) | One function = one purpose |
| Boy Scout | Leave code cleaner than you found it |
| Root Cause | Five Whys — fix the source, not the symptom |
Design
- Law of Demeter: talk only to immediate collaborators
- Dependency direction, module depth, and boundary placement: see
/speq-design-philosophy
Functions
- Small and focused
- Few arguments (≤3 ideal)
- No side effects
- No boolean flags: split into separate methods
- No selector arguments of any type: an argument that picks a branch means two functions
- One level of abstraction per function: decide or do the work, not both
- A function either mutates something or answers a question, never both in one call (Command-Query Separation)
- No output parameters: return the value
- Guard clauses first. One unindented main path
- No undocumented ordering contract between calls: if a second call requires a first, make it unreachable without it
Errors
- Failure is signalled by the language's own error mechanism, never a sentinel value, magic number, or in-band absent value
- Absence is explicit: an empty collection or the language's optional type, never a stand-in for a value
- Every error states what was attempted, the input that failed, and the constraint violated
- Translate a third-party error into this module's own error type at the boundary: callers never handle a provider's error taxonomy
- Never discard an error, never catch broadly: handle at one level, let the rest propagate
- Errors signal exceptional conditions, not control flow
- The failure path is written test-first, like any other behavior
Naming
- Descriptive, unambiguous, pronounceable
- Named constants over magic numbers
- No prefixes or type encodings
- Types are nouns, functions are verbs, predicates read as questions
- One word per concept across the codebase
- Name length matches scope: single letters only within a few lines
- No role-suffix names that state no responsibility (Manager, Processor, Handler, Data, Info, Util)
- A name reflects what a thing is for, never how it is built: keep transport, vendor, or storage format out of it
- Domain vocabulary over generic programming vocabulary
Comments
- Public/interface methods: brief doc comment stating what the method promises — purpose, and design intent or rationale when that is not self-evident from the signature
- Private methods: no comments
- No inline comments: make the code self-explanatory
- No work tracking (TODOs, FIXMEs, ticket refs)
YAGNI Checks
- Abstraction (interface, generic type, configuration value) with one implementation/caller? Inline it — unless it is a seam over I/O, nondeterminism, or a third party, or the concrete choice is expected to change. Those seams stay.
- Feature flag or extension point nobody uses? Remove it.
Code Smells
| Smell | Signal |
| Rigidity | Small changes cascade everywhere |
| Fragility | One change breaks unrelated code |
| Immobility | Can't reuse code elsewhere |
| Opacity | Hard to understand at a glance |
Attribution
Draws on established practice, including R. Martin (Clean Code, SOLID, Boy Scout Rule), K. Beck (TDD), and B. Meyer (Command-Query Separation).
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.

