hm-l2-refactor
Decide between surgical and structural refactoring with scope, safety, and rollback planning.
Skill by shynlee04
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/shynlee04-hm-l2-refactor
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Shell scripts
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/hm-l2-refactor
What's inside
- Skill name
hm-l2-refactor- Description
- Decide between surgical and structural refactoring with scope, safety, and rollback planning. Use when cleaning code, restructuring modules, improving architecture, when code has grown organically and needs organization, when technical debt is accumulating, or when the user says "this code is a mess" or "clean this up." Even when they don't explicitly say "refactor." Triggers: "refactor", "clean up code", "restructure", "improve architecture", "technical debt", "code organization", "surgical refactor", "structural refactor". NOT for rewrites that change behavior or for trivial formatting fixes.
- License
- MIT
- Metadata
- role: domain-execution · layer: 2 · pattern: P2 · version: 1.0.0
- Instructions
- 154 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Agent Skills spec issues
- allowed-tools: must be a space-separated string
Files (7)
- SKILL.md
- evals.json · evals/
- rich-gate-scorecard.md · metrics/
- refactor-runbook.md · references/
- refactor-taxonomy.md · references/
- safety-checklist.md · references/
- validate-skill.sh · scripts/
SKILL.md (first lines)
## Overview
Decision framework for choosing between surgical and structural refactoring approaches. Use when cleaning up code, restructuring modules, addressing technical debt, or reorganizing grown-organic codebases. Produces scoped refactoring plans with rollback strategies and safety guardrails.
## The Iron Law
```
Refactoring without tests is restructuring. Restructuring without rollback is reckless.
```
# Refactor Decision Framework
## On Load
1. Read `references/refactor-taxonomy.md` — surgical vs. structural refactor decision tree
2. Read `references/safety-checklist.md` — pre-refactor safety checks
## Refactor Taxonomy
## Gated Refactor Protocol
Adapted from GitHub `awesome-copilot` `refactor-plan`: refactors are planned as deterministic, reversible sequences with verification between changes. Do not start by editing code. First map affected files, dependency direction, test coverage, and rollback.
| Gate | Required output | Stop condition |
|------|-----------------|----------------|
| Scope map | Files/functions/modules touched and why behavior stays unchanged | Unknown callers or side effects |
| Sequence | Ordered steps: types/interfaces first, implementation moves second, tests/fixtures last | Steps cannot be independently verified |
| Safety net | Existing tests or characterization tests before structural moves | No way to detect behavior drift |
| Rollback | Per-step rollback command or commit boundary | Rollback requires blanket reset/clean |
| Verification | Command after each step and final integration command | Verification unavailable or unrelated |
Use `references/refactor-runbook.md` for the execution worksheet.
### Surgical Refactor
| Attribute | Value |
|-----------|-------|
| Scope | Single function, variable rename, inline extraction |
| Risk | Low |
| Tests | Existing tests must pass before and after |
| Rollback | `git checkout -- <file>` |
| Time | Minutes |
**Examples:** Rename variable, extract function, remove dead code.
### Structural Refactor
| Attribute | Value |
|-----------|-------|
| Scope | Module boundaries, dependency direction, file moves |
| Risk | High |
| Tests | Existing + new integration tests required |
| Rollback | `git revert <commit>` or branch delete |
| Time | Hours to days |
**Examples:** Split god object, invert dependency, introduce interface.
## Decision Tree
```
Does the change alter behavior?
├── YES → This is NOT a refactor. Stop. Write spec first.
└── NO → How many files are affected?
├── 1 file, 1 function → Surgical
└── Multiple files or modules → Structural
Structural: Are tests comprehensive?
├── YES → Proceed with branch + incremental commits
└── NO → Write tests FIRST, then refactor
```
## Safety Checklist
- [ ] All existing tests pass before refactor
- [ ] Refactor is on a branch (not main)
- [ ] Each incremental step is committed
- [ ] Tests pass after each commit
- [ ] Rollback plan is known (branch name or commit hash)
- [ ] Affected dependency graph is mapped before moving modules
- [ ] Verification command is attached to every refactor step
## Rollback Protocol
```bash
# If tests fail after refactor:
git diff HEAD~1 # See what changed
git checkout HEAD~1 -- <affected-files> # Revert specific files
```
Avoid blanket reset/clean operations in agent worktrees. Prefer file-specific checkout for files changed in the current refactor step, or revert the step commit when the workflow allows commits.
## RICH Gate Source Decisions
| Source | Decision | Local adaptation |
|--------|----------|------------------|
| `github/awesome-copilot` refactor-plan | ADOPT | Safe sequence, affected-file/dependency map, verification between changes, and rollback worksheet. |
| `addyosmani/agent-skills` incremental implementation | ADAPT | Small reversible steps and characterization tests are used as safety gates. |
| GitHub agent skill resource model | ADAPT | Runbook and evals carry detailed reusable material instead of bloating SKILL.md. |
## Independence Notes
This skill works in any Git-backed end-user project. If no git repository exists, replace commit rollback with copied-file checkpoints and document that rollback is degraded. Do not assume GSD, BMAD, or HiveMind phase state.
## Anti-Patterns
| Anti-Pattern | Detection | Correction |
|-------------|-----------|------------|
| **The Behavior Changer** | Refactor changes output or side effects | Stop. This is a rewrite, not a refactor. Write spec. |
| **The Testless Restructure** | Restructures without running tests | Run tests before EVERY step |
| **The Mega-Commit** | Refactors 20 files in one commit | Commit after each file or logical unit |
| **The No-Rollback** | Works on main without branch | `git checkout -b refactor/<name>` before touching code |
## Reference Map
| File | When to Read |
|------|-------------|
| `references/refactor-taxonomy.md` | Choosing between surgical and structural |
| `references/safety-checklist.md` | Pre-refactor safety verification |
| `references/refactor-runbook.md` | Step worksheet, dependency map, rollback table |From shynlee04/hivemind-plugin, MIT.
More from shynlee04/hivemind-plugin
- 0.578score
hm-l3-synthesis
shynlee04
Compress research findings into actionable artifacts with tiered reduction.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l2-coordinating-loop
shynlee04
Coordinate multi-agent dispatch with validation gates and handoff protocols.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l3-integration-contracts
shynlee04
Formal bidirectional contract authority between skills and agents.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hf-l2-agent-composition
shynlee04
Teaches agents how to compose specialist agents from user intent using XML markup grammar, step protocols, and structured return formats.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hf-l2-skill-synthesis
shynlee04
Use when synthesizing skills from GitHub repos, classifying skill patterns, building template libraries, generating eval frameworks, or creating eval-driven…
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l3-detective
shynlee04
Investigate codebases with SCAN, READ, and DEEP reading modes.
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
hf-l2-command-parser
shynlee04
This skill should be used only when parsing $ARGUMENT propositional commands from OpenCode command strings.
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
hf-l2-skill-router
shynlee04
Maps meta-builder task domains to hf-* skill loading bundles with priority ordering.
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
gate-l3-lifecycle-integration
shynlee04
Internal quality gate that evaluates whether Hivemind harness implementations correctly participate in the runtime lifecycle — covering 9-surface mutation…
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
gate-l3-spec-compliance
shynlee04
Spec compliance gate performing bidirectional traceability, gap detection (4 types), EARS acceptance criteria validation, and anti-pattern scanning.
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
hf-l2-delegation-gates
shynlee04
Enforce pre-delegation authorization gates before agent dispatch.
SkillCFreshness: C★ 51Claude Code +9 - 0.574score
hm-l2-requirements-analysis
shynlee04
Formal requirements diagnosis methodology for detecting gaps, contradictions, missing constraints, and unvalidated assumptions in existing requirements.
SkillCFreshness: C★ 51Claude Code +9
Signals
- Stars
- 51
- Forks
- 16
- Open issues
- 21
- Last commit (this folder)
- May 7, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0.0
- License
- MIT
- Repository
- github.com/shynlee04/hivemind-plugin
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from shynlee04
- 0.578score
hm-l3-detective
shynlee04
Investigate codebases with SCAN, READ, and DEEP reading modes.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l3-integration-contracts
shynlee04
Formal bidirectional contract authority between skills and agents.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hf-l2-skill-synthesis
shynlee04
Use when synthesizing skills from GitHub repos, classifying skill patterns, building template libraries, generating eval frameworks, or creating eval-driven…
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l2-coordinating-loop
shynlee04
Coordinate multi-agent dispatch with validation gates and handoff protocols.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hf-l2-agent-composition
shynlee04
Teaches agents how to compose specialist agents from user intent using XML markup grammar, step protocols, and structured return formats.
SkillCFreshness: C★ 51Claude Code +9 - 0.578score
hm-l3-synthesis
shynlee04
Compress research findings into actionable artifacts with tiered reduction.
SkillCFreshness: C★ 51Claude Code +9
Cite this page
hm-l2-refactor skill. Agent Mart. https://agentmart.dev/skills/shynlee04-hm-l2-refactor (last updated 2026-10-24)