code-design-guard
Skill2 starsChanged 5 months agoApache-2.0View on GitHub
Pre-implementation design guard for non-trivial code changes. Use before feature work, bug fixes, refactors, compatibility changes, error-handling changes, fallback additions, helper extraction, or any code change where Codex should clarify intent, normal flow, required invariants, failure policy, helper boundaries, and fallback justification before editing.
In this repositoryOne other file it gives its agents.
- code-reviewSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
33 rules. About 0 are common, 29 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈29
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use this skill before making a non-trivial code change.
- Very specific: line 20
After implementation, use code-review to check structural clarity and failure policy.
- Distinctive: line 22
Keep the design note short.
- Distinctive: line 26
Before editing, write a short note covering:
- Distinctive: line 57
Keep acceptance criteria tied to the user's request and repository evidence.
- Distinctive: line 64
Keep the normal path readable near the call site.
- Distinctive: line 65
Keep compatibility branches, guards, optional paths, and exception handling from dominating the main logic.
- Distinctive: line 66
If the normal path is only understandable by opening several helpers, reconsider the structure.
- Distinctive: line 80
Must-stop or must-report failures often include:
- Very specific: line 89
Do not hide must-stop failures with empty strings, empty arrays, null, false, or weak defaults.
- Distinctive: line 93
Use fallback logic for grounded compatibility, legacy data, optional features, external dependency failure, or explicit user requirements.
- Distinctive: line 104
When adding fallback logic, verify:
- Distinctive: line 111
Avoid hiding fallback chains inside vague helpers:
- Very specific: line 117
If resolveValue only contains a chain like this, it is wrapping patchwork:
- Distinctive: line 123
Prefer reducing candidates and making required-value failure visible:
- Distinctive: line 133
If a constant or type-guaranteed value cannot be null by declaration, do not add a defensive null check for it:
- Distinctive: line 139
If a supposedly guaranteed value can break, treat that as an initialization, typing, or configuration-loading problem.
- Distinctive: line 141
When a fallback has three or more candidates, pause and check:
- Distinctive: line 149
After this review, keeping three or more fallback candidates is acceptable when that remains the most accurate behavior.
- Distinctive: line 153
Create helpers when they improve comprehension, isolate change, or make behavior easier to verify.
- Distinctive: line 157
remove meaningful repetition that is complex enough to be worth centralizing.
- Distinctive: line 162
create a valuable unit for focused tests.
- Distinctive: line 165
Use a leading underscore for new internal-only helpers.
- Distinctive: line 167
Treat a helper as suspicious when it:
- Distinctive: line 177
Do not delete suspicious helpers automatically.
- Distinctive: line 181
Prefer preventing the problem at the source over compensating for it later.
- Distinctive: line 182
Keep the implementation grounded in the input class in scope and away from sample identity traits.
- Distinctive: line 183
Prefer explicit required-value failures over broad defaults.
- Distinctive: line 184
Prefer repository evidence over speculative compatibility branches.
- Distinctive: line 185
Prefer a visible priority order over a vague resolver helper.
- Distinctive: line 187
Keep simple repeated logic inline when extraction would add unnecessary indirection.
- Very specific: line 189
Avoid broad catch blocks that convert serious failures into defaults.
- Distinctive: line 190
Keep comments focused on why a branch exists when the code cannot make that reason obvious.
≈ “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 Design Guard
Use this skill before making a non-trivial code change. The goal is to prevent cosmetic abstraction, ungrounded defensive defaults, and silent masking of required failures.
Favor root-cause fixes. When a problem can be prevented through normal design, data flow, validation, typing, initialization, or caller behavior, prefer that prevention over patching over the symptom later. Do not use reward hacking, benchmark-specific shortcuts, or checker-shaped workarounds as substitutes for a real fix.
Design against the task contract and supported input classes. Use examples to identify real input classes, structural patterns, edge cases, and acceptance criteria. Avoid logic that depends on incidental traits that only identify the provided sample. Specialized logic is acceptable when it targets an input class that is actually in scope and is triggered by stable structural evidence.
Workflow
- State the design intent before editing code.
- Inspect the actual repository, call paths, configuration, and tests.
- Revise the design intent based on repository evidence.
- Implement the change.
- After implementation, use
code-reviewto check structural clarity and failure policy.
Keep the design note short. It is a decision aid, not a separate design document.
Pre-change design note
Before editing, write a short note covering:
Goal:
- ...
Normal flow:
- ...
Required invariants:
- ...
Failure policy:
- Safe to continue:
- Must stop or report:
Helper and fallback plan:
- New helpers and why they help:
- New fallbacks and the evidence for them:
- Required values that must not be hidden by defaults:
Verification:
- ...Goal and success condition
Clarify what the change must accomplish.
- Identify the user-visible or caller-visible result.
- Identify the smallest verifiable completion signal: test, build, smoke run, output file, API response, UI behavior, or diff shape.
- Keep acceptance criteria tied to the user's request and repository evidence.
Normal flow first
Identify the expected path before designing defensive branches.
- Name the common input and the intended execution path.
- Keep the normal path readable near the call site.
- Keep compatibility branches, guards, optional paths, and exception handling from dominating the main logic.
- If the normal path is only understandable by opening several helpers, reconsider the structure.
Required invariants and failure policy
Separate values that may be absent from values that must exist.
Safe-to-continue failures often include:
- missing cache entries;
- optional feature failures;
- best-effort logging, analytics, or telemetry failures;
- external service failures where degraded behavior is an explicit product decision.
- values that may exist only in some supported environments, as long as the core operation is still safe without them.
Must-stop or must-report failures often include:
- missing required configuration;
- missing required data;
- failed security validation;
- broken authentication, authorization, billing, deletion, or move preconditions;
- environment-dependent values that are required for the core logic in this task;
- conditions that can corrupt output, persist wrong data, or make later debugging misleading.
Do not hide must-stop failures with empty strings, empty arrays, null, false, or weak defaults.
Fallback criteria
Use fallback logic for grounded compatibility, legacy data, optional features, external dependency failure, or explicit user requirements.
A fallback is well-grounded when at least one of these is true:
- the user requested the fallback behavior;
- existing tests require it;
- real legacy data or existing persisted shape exists;
- runtime, operating-system, browser, library, API, or tool-version differences were confirmed;
- an optional feature can fail while the core operation remains safe;
- degraded behavior after an external-service failure matches product intent.
When adding fallback logic, verify:
- the first candidate is the normal path;
- later candidates have evidence or a clear compatibility reason;
- required values are not being hidden by defaults;
- the fallback can be tested, observed, or explained from repository evidence.
Avoid hiding fallback chains inside vague helpers:
const value = resolveValue(a, b, c, d);If resolveValue only contains a chain like this, it is wrapping patchwork:
return a ?? b ?? c ?? d;Prefer reducing candidates and making required-value failure visible:
const value = explicitValue ?? configValue;
if (value == null) {
throw new Error("Missing required value: ...");
}If a constant or type-guaranteed value cannot be null by declaration, do not add a defensive null check for it:
const value = explicitValue ?? DEFAULT_VALUE;If a supposedly guaranteed value can break, treat that as an initialization, typing, or configuration-loading problem. Do not cover it with a fallback unless repository evidence shows a real compatibility need.
When a fallback has three or more candidates, pause and check:
- whether every candidate has evidence;
- whether priority follows a requirement or existing behavior;
- whether some candidates should be removed;
- whether a required value is being treated as optional;
- whether the priority can stay visible near the use site instead of being hidden in a vague helper.
After this review, keeping three or more fallback candidates is acceptable when that remains the most accurate behavior. Keep the evidence and priority order visible near the code that uses the value.
Helper criteria
Create helpers when they improve comprehension, isolate change, or make behavior easier to verify.
Helpers are useful when they:
- remove meaningful repetition that is complex enough to be worth centralizing;
- name a domain concept;
- isolate file, network, process, environment-variable, time, external API, or similar boundary logic;
- separate a long condition or algorithm step from the main flow;
- match an existing repository pattern;
- create a valuable unit for focused tests.
- centralize a likely future extension point when that extension is credible and keeping the logic in one place clearly reduces future maintenance cost.
Use a leading underscore for new internal-only helpers.
Treat a helper as suspicious when it:
- wraps a one-off simple expression;
- extracts repeated logic that is still simple enough to read inline;
- hides a fallback chain;
- has a vague name such as
resolveValue,getData,handleThing,processInput, ornormalizeInput; - forces readers to open the helper to understand the main flow;
- exists for hypothetical future flexibility without a credible extension path or clear maintenance benefit;
- exists only because the extracted code looked tidier as a separate function.
Do not delete suspicious helpers automatically. First identify their role. Keep helpers with clear value. Inline or rename helpers whose role remains unclear after reading the call site and implementation.
Implementation guardrails
- Prefer preventing the problem at the source over compensating for it later.
- Keep the implementation grounded in the input class in scope and away from sample identity traits.
- Prefer explicit required-value failures over broad defaults.
- Prefer repository evidence over speculative compatibility branches.
- Prefer a visible priority order over a vague resolver helper.
- Preserve necessary fallbacks when tests, legacy data, or compatibility evidence supports them.
- Keep simple repeated logic inline when extraction would add unnecessary indirection.
- Prefix new internal-only helpers with
_. - Avoid broad
catchblocks that convert serious failures into defaults. - Keep comments focused on why a branch exists when the code cannot make that reason obvious.
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.

