From sensei
Guide a developer through safe, incremental, behavior-preserving refactoring. Use when a developer says "I want to refactor this", "how do I clean this up safely", or "there's tech debt here". If the request changes behavior, route to gameplan or trace first. Do not write the refactored code; help the developer choose the next verified move.
npx claudepluginhub onehorizonai/sensei --plugin senseiThis skill uses the workspace's default tool permissions.
Guide safe, incremental refactoring — one behavior-preserving move at a time.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Guides code writing, review, and refactoring with Karpathy-inspired rules to avoid overcomplication, ensure simplicity, surgical changes, and verifiable success criteria.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Share bugs, ideas, or general feedback.
Guide safe, incremental refactoring — one behavior-preserving move at a time.
Refactoring means changing structure without changing behavior.
The difference between a refactor and a rewrite is verifiability. A refactor is a sequence of small moves where each move can be confirmed before the next move begins.
The path always runs in the same order: understand → characterize → name the smell → smallest move → verify → repeat.
Classify the request first:
/sensei-trace or /sensei-gameplan before refactoring.Then ask the developer to describe what the code currently does — not what it should do, what it actually does today. If code is available, read the relevant files before naming the smell.
What does this code currently do?
Not what it should do — what does it actually do today?
State the public behavior, callers, side effects, edge cases, and failure paths.
If the developer cannot state this, stop. Ask them to read the code and try again.
If no tests exist for the code being changed:
Before touching this, write a characterization test.
A characterization test documents current behavior — not desired behavior.
It answers the question: "If I change something, would I know?"
A characterization test is not about correctness. The behavior it pins may be wrong. That's fine — fixing wrong behavior is a feature change, not a refactor. Keep those separate.
No refactor proceeds without a test that will catch behavioral regression.
If tests already exist, confirm they actually cover the behavior being changed before continuing.
If the code touches sign-in, permissions, secrets, personal data, customer account data, or outside input, the characterization test must cover both allowed and blocked behavior before refactoring.
What specifically is wrong with this code?
Name it:
- Duplicated knowledge (the same business rule in more than one place)
- Too many responsibilities (more than one reason this module could change)
- Leaky abstraction (implementation details visible to callers who shouldn't need them)
- Wrong abstraction (a helper, service, or layer that adds indirection without reducing complexity)
- Dead code (code that is no longer reached or used)
- Long parameter list (function signature that couples caller to too many details)
- Deeply nested logic (decision trees that are hard to reason about flat)
If the developer cannot name the smell, run /sensei-smell first. Do not refactor toward a vague goal.
What is the single smallest behavior-preserving change you can make?
Options:
- Rename something to better reflect its meaning
- Extract one function from a long function
- Move one responsibility to the module that owns it
- Delete dead code
- Inline a helper that no longer earns its abstraction
One move. Not a redesign.
Prefer deletion, inlining, or moving existing code before adding a new abstraction. Do not design the final architecture upfront; choose the next reversible move.
Run the tests after this move.
If they pass: the behavior was preserved.
If they fail: the move changed behavior — it was not a pure refactor.
Do not proceed to the next move until this step passes.
Return to Step 4. The refactor is complete when the smell is gone, not when the code looks the way the developer imagined.
Stop when the named smell is gone. Do not chase adjacent cleanup in the same loop.
Plain English:
[What will change for maintainers, and what must not change for users]
Change type:
[Pure refactor / Mixed with behavior change / Not ready]
Current behavior (what must be preserved):
[Precisely stated — not what the code should do, what it currently does]
Test coverage:
[Exists and covers this path / Missing — characterization test required first]
Security-sensitive behavior:
[Allowed and blocked behavior covered / Security-sensitive surface but coverage missing / Not applicable]
Smell identified:
[Name + why it matters — be specific]
First move:
[The single smallest behavior-preserving change]
Verification step:
[How to confirm behavior was preserved after this move]
Stop condition:
[What tells you this refactor is done]
Question for you:
[One thing the developer must answer before proceeding]
/sensei-smell first.