Agent skill
elon-musk
Delete-first refactoring for legacy systems: remove low-value code early, then re-add only what data proves necessary. Use when: (1) legacy code has obvious bloat/duplication, (2) complexity is blocking delivery, (3) the team can run tests, feature flags, and rollback.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/elon-musk
SKILL.md
Elon Musk
Delete-first refactoring. Shrink the system first, then optimize what survives.
Executive Summary
- Delete aggressively (often 70-90%) behind flags
- Preserve externally required behavior (APIs, SLOs, safety controls)
- Re-add only what measured outcomes require
- Optimize after simplification
- Automate last
Preconditions
Do not run this playbook unless all are true:
- CI is green
- Characterization and contract tests exist for the target area
- Feature flags and rollback path are ready
- Owners for requirements and risk sign off
Operating Order
- Confirm requirement owners and explicit keep-list
- Delete first (if little is deleted, challenge scope)
- Simplify the remaining architecture
- Optimize only measured bottlenecks
- Automate only after process stability
Git Safety Gates (Mandatory)
Before any large deletion:
- Create an isolated branch:
refactor/<area>-delete-first - Start from a clean working tree
- Create a recoverable checkpoint:
- lightweight tag:
pre-delete-<area>-<YYYYMMDD> - optional backup branch:
backup/<area>-pre-delete
- lightweight tag:
- Use small, reviewable commits with intent-first messages, for example:
refactor!: delete deprecated parser pathtest: add characterization coverage for billing flow
- Open small PRs with mandatory reviewers and green CI
Hard rules:
- No deletion rampage on
main - No force-push to shared branches during refactor
- No removal of auth/audit/PII/security controls without explicit review and tests
Workflow
- Baseline
- Capture current behavior, perf, and error metrics
- Write keep-list: public APIs, SLOs, compliance/safety paths
- Delete behind flags
- Remove dead/duplicate/no-owner/untestable code first
- Target large reduction (70-90%) where safe
- Verify
- Run characterization + contract tests
- Enforce CI gates before merge
- Decide with data
- Re-add only if user impact, reliability, or contractual behavior requires it
- Optimize survivors
- Automate stable flow last
Keep vs Delete Heuristic
Keep:
- Public API and compatibility contracts
- Safety/regulatory behavior
- Proven hot paths with measurable value
Delete first:
- Unused code
- Duplicate logic
- Code with no owner
- Code impossible to test or reason about
Rollback and Recovery
- Every risky deletion is flag-guarded
- Canary before full rollout
- Be ready to revert by commit, tag, or backup branch
- Record rollback steps directly in PR description
Communication Contract
Every refactor PR should state:
- Scope
- Owner
- Delete percentage target
- Active flags
- Rollback command/path
- Expected impact (CI time, latency, crash rate, LOC delta)
Estimation Heuristic
Rough planning baseline: 1-3 dev-days per 1k LOC touched (variance up to 2x).
Example Flow
flowchart TD
A[Baseline + keep-list] --> B[Delete + feature flags]
B --> C[CI + characterization tests]
C --> D{Need to re-add?}
D -- Yes --> E[Re-add with data]
D -- No --> F[Ship]
E --> F
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?