cursor/.cursor/skills/abstraction-judgment/SKILL.md
Use when deciding whether to extract a shared utility, create a base class, build a framework layer, or generalize a pattern -- especially when the pattern has fewer than three concrete instances or the abstraction adds cognitive overhead without clear payoff.
npx skillsauth add akshay-na/dotfiles abstraction-judgmentInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Introduce abstractions only when patterns are stable and the payoff is clear. Premature abstraction is more expensive than duplication. Prefer concrete, readable code until repetition proves a pattern is real and worth extracting.
| Competency | Key Question | |---|---| | Stable repetition | Has this pattern appeared 3+ times with minimal variation? | | Premature generalization | Am I guessing future use cases that may never arrive? | | Cognitive cost | Is the abstraction easier to understand than the duplicated code? | | Duplication tolerance | Is this duplication actually harmful, or just aesthetically uncomfortable? | | Extraction timing | Am I extracting after validation, or before the pattern has stabilized? |
Do not abstract until the pattern has appeared at least three times in concrete code.
| Count | Action | |---|---| | 1 occurrence | Write it inline. No abstraction. | | 2 occurrences | Note the duplication. Tolerate it. | | 3 occurrences | Evaluate: is the pattern stable? Are variations minor? Extract if yes. |
Exception: if the duplicated code is a correctness concern (e.g., security validation), extract earlier.
Stop and reconsider if you observe:
| Signal | Root Cause | |---|---| | Over-generalized frameworks | Abstraction built for imagined future use cases | | Hard-to-understand utility layers | Abstraction hides logic that callers need to understand | | Complex configuration logic | Generalization replaced simple code with a configuration surface | | High onboarding friction | New engineers cannot trace behavior through abstraction layers | | Abstraction with one caller | Extracted too early; no reuse materialized | | Parameters that toggle behavior | Abstraction is doing too many things; split or inline |
Abstraction Decision Checklist:
## Before Extracting
- [ ] Pattern has 3+ concrete instances
- [ ] Instances share stable structure with minor variation
- [ ] Abstraction is simpler to understand than the duplicated code
- [ ] Abstraction does not require configuration to handle variation
- [ ] Future callers are real, not hypothetical
## Red Flags (Do NOT Abstract)
- [ ] Only 1-2 instances exist
- [ ] Instances vary significantly in behavior
- [ ] Abstraction requires boolean flags or mode parameters
- [ ] Understanding the abstraction requires reading its source
- [ ] The abstraction is "just in case" for future use
## After Extracting
- [ ] Callers are simpler than before
- [ ] New team members can understand usage without reading internals
- [ ] No configuration explosion
- [ ] Abstraction has a clear, stable interface
| Mistake | Fix | |---|---| | Extracting after two occurrences | Wait for three; tolerate duplication until the pattern stabilizes | | Building for imagined future callers | Abstract for actual use cases, not speculative ones | | Adding parameters to handle variation | If variations diverge, keep them separate; do not merge with flags | | Never revisiting old abstractions | Schedule periodic review; inline or delete abstractions that lost their callers | | Treating all duplication as bad | Some duplication is cheaper than the wrong abstraction | | Abstracting for aesthetics | Abstraction should reduce cognitive load, not just line count |
development
Discovery + naming convention reference for typed dev/SME/QA/devops team members in any workspace folder. Primary consumer: `tech-lead` (org-tier).
devops
Automated task classification, agent selection, and state tracking. Use when routing tasks to agents, selecting pipelines, or managing task state.
testing
Use when designing scalable systems, evaluating consistency models, planning state management, making architectural decisions, or when trade-offs around coupling, failure isolation, and reversibility need explicit reasoning before implementation.
tools
CTO/tech-lead helper — split work into disjoint shard briefs with caps (instance_cap, partition_basis, determinism keys).