Agent skill

enforcing-code-quality

Behavioral protocol for all code changes. Invoked automatically by develop and test-driven-development. Triggers: 'code quality', 'no shortcuts', 'production quality', 'enforce standards'. NOT for: reviewing others' code (use code-review) or test quality (use fixing-tests).

Stars 5
Forks 2

Install this agent skill to your Project

npx add-skill https://github.com/axiomantic/spellbook/tree/main/skills/enforcing-code-quality

SKILL.md

Code Quality Enforcement

Invariant Principles

  1. Shortcuts compound - Every any type, swallowed error, and skipped test becomes someone's 3am incident.
  2. Pre-existing issues are your issues - Discovering a bug during work means fixing it, not routing around it.
  3. Tests prove behavior - Coverage metrics mean nothing. Assertions that verify actual outcomes mean everything.
  4. Patterns before invention - Read existing code first. Match conventions. Novel approaches require justification.
  5. Production-quality, not "works" - "Technically passes" is not the bar. "Confidently deployable" is.

Inputs

Input Required Description
Code being written Yes Implementation in progress
Existing patterns No Codebase conventions to match
Test requirements No Expected coverage and assertion depth

Outputs

Output Type Description
Compliant code Code Implementation meeting all standards
Issue flags Inline Pre-existing issues discovered
Pattern notes Inline Conventions followed or justified deviations

Reasoning Schema

Prohibitions

Required Behaviors

Behavior Rationale
Read existing patterns FIRST Consistency > cleverness
Understand WHY before fixing Root cause, not symptom
Full assertions in tests Prove behavior, not just execution
Handle all error branches Production sees every edge case

Pre-Existing Issues Protocol

When discovering issues in touched code:

  1. Flag immediately - Note the issue in your response
  2. Ask about fixing - "Found X issue. Fix now or track separately?"
  3. Default to fix - User usually wants it fixed
  4. Never silently ignore - Routing around bugs creates more bugs

Quality Checklist

  • Matches existing codebase patterns
  • No items from FORBIDDEN list
  • Error handling is explicit and complete
  • Tests have meaningful assertions
  • Test assertions are Level 4+ on the Assertion Strength Ladder (patterns/assertion-quality-standard.md)
  • Full Assertion Principle enforced: ALL output tested with exact equality (assert result == expected), never substring checks; for dynamic output, construct full expected value dynamically
  • No bare substring checks on any output (assert "X" in result is BANNED -- static or dynamic)
  • No partial assertions on dynamic output (construct full expected, do not use membership checks)
  • No mock.ANY in call assertions (BANNED -- construct expected argument)
  • Every mock call asserted with ALL args; call count verified
  • No length/existence-only assertions
  • No partial-to-partial upgrades (Pattern 10: replacing one BANNED assertion with another is not a fix)
  • No hallucinated APIs: method calls, imports, and config keys verified against actual library/framework
  • AI-generated code has had API signatures spot-checked against source or documentation
  • Pre-existing issues addressed or explicitly tracked
  • Would confidently deploy this

Self-Check

  • Every error path handled explicitly
  • No any types introduced
  • No try-catch swallowing errors
  • Tests verify behavior, not just run
  • Test assertions are Level 4+ on the Assertion Strength Ladder (patterns/assertion-quality-standard.md)
  • ALL output tested with exact equality (assert result == expected_complete_output); for dynamic output, construct full expected value dynamically
  • No bare substring checks on any output (assert "X" in result is BANNED -- static or dynamic)
  • No mock.ANY in call assertions (BANNED -- construct expected argument dynamically)
  • Every mock call asserted with ALL args; call count verified
  • No length/existence-only assertions
  • No tautological assertions (assert result == func(same_input))
  • Pre-existing issues flagged to user
  • Code matches existing patterns

<FINAL_EMPHASIS> Zero shortcuts. Zero swallowed errors. Zero skipped assertions. Code that ships must be code you would defend at 3am. If any checklist item is unchecked, it is not done. </FINAL_EMPHASIS>

Expand your agent's capabilities with these related and highly-rated skills.

axiomantic/spellbook

spellbook-auditing

Meta-audit skill for spellbook development. Spawns parallel subagents to factcheck docs, optimize instructions, find token savings, and identify MCP candidates. Produces actionable report.

5 2
Explore
axiomantic/spellbook

documentation-updates

Use after modifying library skills, library commands, or agents to ensure CHANGELOG, README, and docs are updated

5 2
Explore
axiomantic/spellbook

project-encyclopedia

[DEPRECATED] Use project-level AGENTS.md files instead. Previously used for first-session codebase onboarding and persistent glossary creation.

5 2
Explore
axiomantic/spellbook

reviewing-impl-plans

Use when reviewing implementation plans before execution. Triggers: 'is this plan solid', 'review the plan', 'check before I start building', 'anything missing from this plan', 'will this plan work', 'audit the implementation plan'. NOT for: reviewing design documents (use reviewing-design-docs) or creating plans (use writing-plans).

5 2
Explore
axiomantic/spellbook

session-resume

Session resume protocol and session repairs handling. Loaded when spellbook_session_init returns resume_available: true, or when session_init returns a repairs array. Triggers: 'resume', 'continue', 'where were we', session resume, session repairs.

5 2
Explore
axiomantic/spellbook

brainstorming

Use when exploring design approaches, generating ideas, or making architectural decisions. Triggers: 'explore options', 'what are the tradeoffs', 'how should I approach', 'let's think through', 'sketch out an approach', 'I need ideas for', 'how would you structure', 'what are my options'. Also invoked by develop when design decisions are needed.

5 2
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results