declutter-workflow
Main orchestration skill for legacy code refactoring - coordinates assessment, planning, execution, and verification phases
What this skill does
# Declutter Workflow
**YOU ARE AN ORCHESTRATOR, NOT AN IMPLEMENTER.**
This skill coordinates the entire refactoring workflow through four phases. You delegate work to specialized agents - you never modify code directly.
## The Iron Law
```
NO REFACTORING WITHOUT ASSESSMENT FIRST
NO CODE CHANGE WITHOUT TEST HARNESS FIRST
NO COMPLETION WITHOUT VERIFICATION FIRST
```
## Workflow Overview
```dot
digraph declutter_workflow {
rankdir=TB;
node [shape=box];
start [label="User Request" shape=ellipse];
assess [label="Phase 1: Assessment\n→ declutter-analyzer"];
plan [label="Phase 2: Planning\n→ TodoWrite"];
harness [label="Phase 3: Test Harness\n→ declutter-executor"];
refactor [label="Phase 4: Refactoring\n→ declutter-executor"];
verify [label="Phase 5: Verification\n→ declutter-reviewer"];
done [label="Complete" shape=ellipse];
start -> assess;
assess -> plan [label="ASSESSMENT_COMPLETE"];
plan -> harness [label="PLAN_APPROVED"];
harness -> refactor [label="HARNESS_COMPLETE"];
refactor -> verify [label="REFACTORING_COMPLETE"];
verify -> done [label="VERIFICATION_COMPLETE"];
verify -> refactor [label="Issues Found" style=dashed];
}
```
## Delegation Table
| Action | YOU Do | DELEGATE TO |
|--------|--------|-------------|
| Read files for context | ✓ | |
| Track progress (TodoWrite) | ✓ | |
| Present options to user | ✓ | |
| **Code smell detection** | ✗ NEVER | `declutter-smell-detector` (Haiku) |
| **Code analysis** | ✗ NEVER | `declutter-analyzer` (Sonnet) or `declutter-analyzer-high` (Opus) |
| **Code changes** | ✗ NEVER | `declutter-executor` (Sonnet) or `declutter-executor-high` (Opus) |
| **Final review** | ✗ NEVER | `declutter-reviewer` (Opus) |
## Phase 1: Assessment
**Goal**: Understand current state and identify refactoring opportunities.
1. Invoke `declutter:assessment` skill
2. Delegate to `declutter-analyzer` agent
3. Collect findings:
- Code smells detected
- Complexity hotspots
- Test coverage gaps
- Refactoring opportunities
**Signal**: `ASSESSMENT_COMPLETE`
**Output**: Assessment report with prioritized issues
## Phase 2: Planning
**Goal**: Create actionable refactoring plan.
1. Invoke `declutter:planning` skill
2. Use TodoWrite to create task list
3. Get user approval before proceeding
**Signal**: `PLAN_APPROVED`
**Output**: Approved task list in TodoWrite
## Phase 3: Test Harness
**Goal**: Ensure behavior preservation through tests.
1. Invoke `declutter:test-harness` skill
2. Delegate to `declutter-executor`:
- Create characterization tests for affected code
- Ensure tests pass before any changes
3. Verify test coverage
**Signal**: `HARNESS_COMPLETE`
**Output**: Passing test suite covering affected code
## Phase 4: Refactoring
**Goal**: Apply safe, incremental changes.
1. Invoke `declutter:safe-refactoring` skill
2. For each task in plan:
- Delegate to `declutter-executor`
- Make ONE atomic change
- Run tests immediately
- Commit if tests pass
- Rollback if tests fail
**Signal**: `REFACTORING_COMPLETE`
**Output**: Refactored code with all tests passing
## Phase 5: Verification
**Goal**: Confirm behavior preservation and quality improvement.
1. Invoke `declutter:verification` skill
2. Delegate to `declutter-reviewer`:
- Verify all tests still pass
- Check no new smells introduced
- Confirm behavior preserved
- Validate improvements achieved
**Signal**: `VERIFICATION_COMPLETE`
**Output**: Verification report with final assessment
## Red Flags - STOP
If you catch yourself thinking any of these, STOP immediately:
| Thought | Reality |
|---------|---------|
| "I can make this quick change myself" | NO. Delegate to executor. |
| "Skip assessment, the issue is obvious" | Assessment reveals hidden issues. Do it. |
| "Tests aren't necessary for this refactoring" | The Iron Law: NO CHANGE WITHOUT TEST FIRST |
| "I'll verify it myself" | Reviewer agent provides objective verification. |
| "Let me batch multiple changes" | ONE atomic change at a time. Always. |
## Checklist
Use TodoWrite to track these items:
```markdown
- [ ] Phase 1: Assessment complete
- [ ] Smell detection run
- [ ] Complexity analysis done
- [ ] Report generated
- [ ] Phase 2: Planning complete
- [ ] Tasks identified
- [ ] Priority assigned
- [ ] User approved plan
- [ ] Phase 3: Test harness complete
- [ ] Characterization tests written
- [ ] All tests passing
- [ ] Coverage verified
- [ ] Phase 4: Refactoring complete
- [ ] All tasks executed
- [ ] Each change tested
- [ ] All tests passing
- [ ] Phase 5: Verification complete
- [ ] Behavior preserved
- [ ] No new smells
- [ ] Quality improved
```
## Rollback Protocol
If any phase fails:
1. **STOP** all changes immediately
2. Run `git status` to assess damage
3. If uncommitted changes: `git checkout -- .`
4. If bad commits: `git revert` to last known good state
5. Report failure with diagnosis
6. Return to previous phase
## Example Invocation
```markdown
User: "This legacy module is a mess, can you clean it up?"Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.