Skill · Clean code
Loaded by almost every agent. The quality floor for everything AgentHub writes — not a style guide, a set of opinionated choices about what “done” means.
When it activates
Automatically, on every dispatch to backend-specialist, frontend-specialist, debugger, test-engineer, database-architect, and several others. You rarely invoke it yourself.
What it teaches (the short list)
- No premature abstraction. Three similar lines is fine. Don't extract a helper for two.
- No defensive code for impossible inputs. Trust internal boundaries; validate at system boundaries only.
- Comments explain why, not what. Good names replace most comments.
- No backwards-compat shims unless the data on the other side is out of your control.
- No half-finished implementations. Complete the feature or revert it.
- No cleanup you weren't asked for. A bug fix is a bug fix. Not a refactor.
Example: what clean-code refuses
A prompt saying “add a comment explaining this loop” will produce:
// No comment added — the loop's name (chunkByMonth) already describes it.
// Adding "loops through months and chunks entries" restates the code.The agent will write a comment only if the “why” is non-obvious (hidden invariant, workaround for a known bug, surprising behaviour).
Example: what clean-code produces
Asked to fix a pagination bug:
- const pageSize = 50;
- const results = await db.users.findAll();
- return results.slice(0, pageSize);
+ const results = await db.users.findAll({ limit: 50 });
+ return results;No added comment, no renamed vars, no extracted helper, no type annotations added “for consistency.” The bug is fixed. Nothing else changes.
Where it lives
skills/clean-code/SKILL.mdis ~1k tokens of rules. Every agent that loads it reads those rules at dispatch time — they're not baked into the model, they're on-demand context.
Pro tips
- Don't fight it. If an agent refuses to add a comment you asked for, it's not being lazy — it's applying this skill. Rephrase to explain the why.
- Project overrides go in
.hub/instincts.yaml. That's how you encode team-specific rules that should beat this skill.
Next steps
- Systematic debugging — pairs with clean-code for the debugger.
- Approval gate — the other skill every command loads.
- All skills