From ak
Improve readability — better names, guard clauses, dead-code removal — without changing behavior or signatures.
How this skill is triggered — by the user, by Claude, or both
Slash command
/ak:code-simplifyThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Improve the readability of existing code without changing what it does or how it's shaped externally. Accept the design; sharpen the expression.
Improve the readability of existing code without changing what it does or how it's shaped externally. Accept the design; sharpen the expression.
Core thesis: every change must earn its rent. A rename that confuses more than it clarifies is worse than the original. An explaining variable used once is overhead without benefit. A constant introduced for a single-use literal adds indirection for no gain. The skill's job is to apply changes that make the next reader's life easier — not to apply changes that look like cleanup.
Simplification is measured by reader effort, not line count. Explicit, debuggable code is often simpler than compact code. A change whose only measurable win is fewer lines fails rent.
The primary failure mode this skill guards against is pattern-matching on hunks. A rule like "rename data to something specific" fires correctly only when you've read the whole file and understand what data holds in context. Reading the diff hunk alone produces confident-looking bad renames.
The secondary failure mode is removing protective awkwardness. Some code looks noisy because it encodes a boundary, a historical bug, a platform quirk, or a debugging affordance. If you cannot explain what the awkwardness protects, do not simplify it yet.
code-refactorThese skills are orthogonal, not a spectrum.
code-simplify works within the current structure. Signatures preserved (external ABI: types, arity, observable side effects, error surface). Call sites untouched.code-refactor works on the current structure. Signatures negotiable, call sites reshape atomically, design premise on the table.If triage reveals that the real improvement requires signature changes, cross-file merges, or reversing a design choice, this skill stops and routes out rather than degrading the change into a within-signature half-measure.
Three things are needed. If invoked directly, request what's missing:
git diff HEAD)..agent-kit/project.md if it exists. Otherwise infer from 2–3 non-modified files in the same module. Conventions matter for naming, constant placement, and import style.If the target is empty, stop and tell the user.
Read each changed file in full before considering any change. The diff hunk is never enough.
For each file, internally answer:
This phase produces no output. Its purpose is to install the context that every later decision depends on. Skipping it is the skill's top failure mode.
For each modified unit, classify what's present. Use these categories — and only flag items that belong to each:
Simplify-in-scope (Phase 3 applies):
console.log not part of intentional logging, logically impossible branches.Simplify-out-of-scope — route to code-refactor:
Accept and skip:
else after an early return that some teams prefer).data in a data-handling function; item in a small loop body).Triage exits:
✓ Code is already clean. No changes needed. Stop.Apply changes in place. Every change must pass two checks before it goes in:
Rent check — ask for each change: is the file actually easier to read after this? If the answer is "same, maybe slightly different," revert the change. Specifically:
'PENDING' in a status assignment does not need a constant.Invariance check — the following must not change:
Parameter names are internal unless a call site uses named arguments. If any call site uses named arguments (Python kwargs, TypeScript destructuring at the call site), the rename is a call-site reshape — route out, do not apply here.
Apply rules:
constants.ts, etc.). Do not invent a new convention.Scope limits:
After all changes are applied, re-read each modified file as if seeing it for the first time. For each change you made, ask:
Revert any change that fails self-review. Reverts tagged [self-review] in the log.
If tests fail after applying changes, that signals a violated invariance check — revert the offending change and log it as [invariance-violation]. The tests are not wrong; the change was.
Produce the log:
## Refactor Log
### Files Modified
- `path/to/file.ts` — N changes applied, M reverted on self-review
- ...
### Changes Applied
- **Rename:** `data` → `bookingPayload` in `createBooking()` — original misled in context (file handles multiple payload types).
- **Guard clause:** early-return for null `userId` in `validateBooking()` — removed one nesting level.
- **Constant reuse:** inline `'PENDING'` → `BOOKING_STATUS.PENDING` — constant already exists in same file (3 other call sites).
- **Dead code:** removed unused `tempResult`, 2 debug `console.log`.
- **Comment hygiene:** deleted 4 "What" comments; kept 1 "Why" comment explaining Twilio retry.
### Changes Reverted on Self-Review
- **[self-review]** Explaining variable `isActiveAdmin` — used once, inlined version reads clearly in context.
### Route-Out to `code-refactor`
- `processOrder()` in `order.service.ts` takes a boolean `isExpress` that splits the function into two different behaviors. This is a signature-level issue — outside simplify's scope.
- `getUserData()` wraps `fetchUser()` with no transformation. Wrapper collapse requires call-site updates.
Run `/code-refactor order.service.ts user.service.ts` to address these.
### Test Status
- Adjacent test files found: `order.service.test.ts`, `booking.service.test.ts`.
- Run them to confirm behavior preservation. No tests found for `date.utils.ts` — behavior-preservation verified by code review only.
If the triage exited early with No changes needed or route-out-only, the log is just the relevant message — no empty sections.
npx claudepluginhub hanh-nd/agent-kit --plugin akCreates bite-sized, testable implementation plans from specs or requirements, with file structure and task decomposition. Activates before coding multi-step tasks.