Systematically simplifies codebases by questioning assumptions and eliminating unnecessary complexity. Use when reviewing, refactoring, or optimizing code.
A methodology for systematically reducing code complexity by questioning every piece of functionality.
For every piece of code, ask: "Is this necessary? What happens if we remove it?"
Most complexity comes from solving problems that don't need solving, or solving them in overly general ways.
Before: Watch parent directory to detect file recreation Question: "When would this actually happen?" Answer: Only when file is deleted and recreated - but periodic sweep catches this After: Remove parent directory watching
Before: Poll every 30s, check if active, return early if not Question: "Why wake up just to do nothing?" After: Sleep until next active period
Before: Reload config from disk every sweep Question: "How often does config actually change?" After: Reload only on explicit signal (SIGHUP) or state transitions
Before: Log "Locked: X" every time lock is applied Question: "Does this log add value?" After: Check if already locked, only log when actually changing state
Before: Same unlock loop in gracefulShutdown() and deactivate() Question: "Why is this duplicated?" After: Extract unlockAll() helper
Before: Complex logic to handle file deletion during watch Question: "How often does this happen? What's the fallback?" After: If periodic sweep handles it anyway, remove the special case
| Red Flag | Question to Ask |
|---|---|
| Code that checks a condition and returns early | "Why are we even here?" |
| Multiple places doing similar things | "Can we extract this?" |
| Watching/polling when nothing should happen | "Can we sleep instead?" |
| Reloading state that rarely changes | "Can we reload on-demand?" |
| Logging that produces noise | "Is this a state change?" |
| Handling edge cases the happy path covers | "What if we remove this?" |