Core principle
Deliver the smallest clear and reliable implementation that actually meets the requirement. Do not add complexity to defend against imagined problems or keep validating indefinitely just to prove the code is correct.
1. No overdefensive coding
- Do not preemptively introduce elaborate logic for hypothetical, extremely unlikely race conditions, failure paths, or edge cases without concrete evidence.
- If extra defensive handling seems necessary, first explain the actual failure mechanism, triggering conditions, impact, and implementation cost. Do not invent a probability when none is supported.
- Do not silently expand the change scope under vague claims such as “more robust” or “just in case.”
- Do not add another wrapper, check, or fallback for a problem the existing implementation already handles reliably.
2. Avoid repeated validation
- Validate external inputs as needed at the clearly defined trust boundary.
- Do not revalidate already validated internal values of known types and constraints in every function.
- Add another check only when data crosses a new trust boundary, constraints change, or a real risk justifies it.
- Do not write large defensive branches for internal states that the design cannot legitimately reach.
3. Prefer the smallest implementation
- Prefer straightforward, readable code that solves the actual task.
- Do not prematurely extract an abstraction used only once.
- Extract a helper when behavior is reused, genuinely complex, or represents a clear domain concept.
- Do not build speculative frameworks, APIs, or extension layers for possible future requirements.
- Reuse capabilities already provided by the repository instead of duplicating them.
4. Keep the code structure clear
- Make the main function show the normal business flow.
- Put necessary validation, errors, and implementation details into well-named helpers when that genuinely improves clarity.
- Do not bury the happy path under excessive conditional handling and fallback code.
- Do not sacrifice readability merely to shorten the code, or increase complexity to appear architecturally complete.
5. Avoid low-value comments
- Use comments to explain non-obvious constraints, reasons for a design, and counterintuitive behavior.
- Do not comment on every self-evident line.
- Prefer accurate names and clear structure over long explanatory comments.
6. Respect the existing project
- Follow the repository’s established architecture, naming, dependencies, and workflow.
- Do not introduce new tools, frameworks, dependencies, or workflows without authorization.
- Edit source files, then regenerate derived artifacts; do not hand-edit generated output.
- When fixing a problem, change only what the fix requires. Do not casually refactor unrelated areas.
7. Test the real implementation
- Test actual behavior, not a duplicated copy of the implementation inside the test suite.
- Prefer tests that cover meaningful behavior over one test for every imagined branch.
- Minimize mocks; use them when necessary to isolate an external dependency or uncontrollable environment.
- Do not create tests merely to increase test count, code coverage, or a quality metric.
8. No excessive validation cycles
- Set completion criteria before implementing, and validate afterward in proportion to the actual risk.
- Do not rerun the entire test suite or audit every few lines of code.
- Finish a coherent batch of changes, then run the smallest checks that directly establish correctness.
- Do not repeat verification of previously passing areas that subsequent changes did not affect.
- When a failure occurs, investigate and fix the specific cause instead of automatically expanding into a whole-project audit.
- When the core requirement is implemented, necessary checks pass, and no blocker remains, deliver and stop.
- Do not treat repetitive checking as a deliverable or pursue theoretical zero risk through endless verification.
9. Essential safety and correctness boundaries
Reducing complexity does not mean ignoring genuine risks.
Preserve necessary protection and validation for security, access permissions, data loss, untrusted external input, financial operations, and irreversible changes.
Every additional safeguard should have a concrete rationale, rather than being justified solely by “it could theoretically happen.”
Final execution rules
Understand the requirement, implement the smallest sufficient solution, perform necessary checks, and stop when the completion criteria are met.
- Do not accumulate defenses against imagined threats.
- Do not abstract code that is used only once without a clear reason.
- Do not write redundant comments for obvious behavior.
- Do not add unrelated architectural layers for formality.
- Do not test merely to create more tests or prove that testing happened.
- Do not expand the scope without authorization.
Code quality comes from correctness, clarity, reliability, and maintainability—not the number of defensive branches, abstractions, or tests.