/code-habits:comment-non-obvious-stepsfrom code-habits
Use when writing or editing code that contains repeated-looking calls on different structures, bitmask/bit-fiddling, ordering-sensitive sequences, or multi-step state mutations across data structures — adds a short inline comment per step explaining WHY each step is distinct, so a reader doesn't stop and ask "wait, why are there three of these?". Does not apply to trivial code with self-explanatory identifiers.
Ships in code-habits. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Default is no comments. The carve-out: when a step's intent isn't obvious from the identifiers — repeated-looking calls on different structures, bit fiddling, ordering-sensitive sequences, or the same field mutated at multiple layers — add a brief inline comment per step explaining WHY this step is distinct.
A future reader (often the same human, a week later) scanning the function shouldn't have to stop and ask "wait, why are there three remove() calls — is one redundant?". One short comment per step turns "I have to reverse-engineer this" into "ah, secondary index, then primary store, then GC". The comment is the difference between a 10-second read and a 5-minute investigation.
This does NOT contradict "no comments by default" — trivial code with self-explanatory names still needs none. The trigger is: a reader will plausibly stop and ask why.
Add a comment when a step is one of:
remove, 2x insert, etc.)x & !FLAG_FOO, bits >> 3)Comment the WHY/WHAT-IS-DIFFERENT, not the what. // remove from cache is noise; // drop cached view so next read repopulates from primary earns its line.
Multi-remove (the live case):
// BEFORE — reader: "why three removes?"
self.by_sender.remove(&sender);
self.orders.remove(id);
self.parents.remove(&group_id);
// AFTER
self.by_sender.remove(&sender); // secondary index
self.orders.remove(id); // primary storage
self.parents.remove(&group_id); // GC empty parent group
Bitmask:
// BEFORE
flags = (flags & !0b0011) | (new & 0b0011);
// AFTER
flags = (flags & !0b0011) | (new & 0b0011); // replace low 2 priority bits, keep upper flags
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub amitkot/claude-code-tools --plugin code-habits7 skills in this plugin
/deliverable-on-diskUse when about to mark a task as complete, done, finished, or shipped — verifies the deliverable actually exists as a file on disk, in a commit, or as a posted artefact. Blocks claiming completion based on chat output alone./ephemeral-state-in-tmpUse when about to write a state, cursor, marker, scratch, or progress file for a cron loop, monitor task, polling job, recurring schedule, or any session-scoped/ephemeral data — directs the file to /tmp/<name>.json instead of ~/.claude/ or other config dirs./evidence-over-speculationUse when about to assert a fact about code behavior, data state, configuration, or system behavior you have not directly verified — requires either reading the source/running the query/checking the log first, or labelling the claim explicitly as a hypothesis. Also covers secondary sources (deepwiki, subagent reports, web search, memory entries): keep the source tag visible and verify cited facts before relaying them as primary-source assertions.