一键导入
reuse-rebuild
Enforces disciplined decision-making: prefer reuse, then refactor, then rebuild only with strong justification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Enforces disciplined decision-making: prefer reuse, then refactor, then rebuild only with strong justification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Communicate efficiently without sacrificing clarity - natural, concise, actionable. Global skill loaded for every command and agent.
Use when reviewing or building UI components - ensures keyboard, screen-reader, and visual accessibility (WCAG 2.1 AA) so a11y is built in, not retrofitted.
You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation.
Manages context caching to optimize token usage and cost by creating, incrementally updating, and invalidating caches while verifying integrity before reuse.
Clean code and engineering discipline: modularity, readability, sizing, naming, duplication, separation of concerns, plus the four behavioral principles - think before coding, simplicity first, surgical changes, and goal-driven execution. Global skill applied to all coding work.
Detects and resolves drift between code, documentation, and contextual knowledge, classifying each drift and recommending concrete sync actions to keep artifacts consistent.
| name | reuse-rebuild |
| description | Enforces disciplined decision-making: prefer reuse, then refactor, then rebuild only with strong justification. |
Make evidence-based decisions about whether to reuse existing code, refactor it, or rebuild from scratch.
Prevent wasteful rebuilding by establishing a clear decision framework:
This skill fights the common AI tendency to rebuild everything instead of working with existing code.
This skill is automatically selected by the orchestrator when:
Use existing code as-is when:
Example: Need a date formatter → found lib/formatDate.ts that handles all required cases → use it
Improve existing code when:
Example: Found api/users.ts but needs pagination → add pagination to existing endpoint → refactor
Create new implementation only when:
Requires justification explaining:
Example: Need real-time updates → existing polling approach can't be adapted → rebuild with WebSocket architecture
Before proposing any implementation:
For each piece of existing code found:
Apply the decision framework:
Clearly state:
Search Findings:
🔍 Found existing code:
✓ lib/formatDate.ts - Handles date formatting
✓ hooks/useUser.ts - Fetches user data
✓ components/UserCard.tsx - Displays user info
Evaluation:
📊 Assessment:
lib/formatDate.ts:
- Functionality: ✓ Handles all required formats
- Quality: ✓ Well-tested, clean code
- Performance: ✓ Adequate
- Compatibility: ✓ Fits our patterns
→ DECISION: REUSE
hooks/useUser.ts:
- Functionality: ⚠ Missing error retry logic
- Quality: ✓ Good structure
- Performance: ✓ Adequate
- Compatibility: ✓ Fits our patterns
→ DECISION: REFACTOR (add retry logic)
components/UserCard.tsx:
- Functionality: ✗ Built for different layout
- Quality: ⚠ Tightly coupled to old design
- Performance: ✓ Adequate
- Compatibility: ✗ Doesn't match new design system
→ DECISION: REBUILD (new component with shared logic extracted)
Recommendations:
✅ REUSE:
- lib/formatDate.ts (as-is)
🔧 REFACTOR:
- hooks/useUser.ts
- Add exponential backoff retry logic
- Keep existing API and tests
- Estimated effort: 30 minutes
🏗️ REBUILD:
- components/UserCard.tsx → components/UserProfile.tsx
- Justification: New design system and layout requirements
- Why not refactor: Component structure fundamentally different
- Reuse approach: Extract user data formatting logic to shared utility
- Estimated effort: 2 hours
YAGNI (You Aren't Gonna Need It):
Working Code Bias:
Incremental Improvement:
Watch for these in proposals:
Rebuilds are justified when:
Good Decision Process:
Request: "Add pagination to user list"
Search: Found getUserList() in lib/api.ts
Evaluation:
- Returns all users at once
- Well-tested function
- Used in 3 places
Decision: REFACTOR
- Add limit/offset parameters
- Maintain backward compatibility with default values
- Update call sites as needed
Why not rebuild: Core logic is sound, just needs parameters
Bad Decision Process:
Request: "Add pagination to user list"
Proposal: "Let's rebuild the entire API layer using tRPC"
❌ Problem:
- No search for existing code
- Massive scope creep
- No justification for full rebuild
- Solves problem not asked for
Justified Rebuild:
Request: "Add real-time collaboration"
Search: Found polling-based update system
Evaluation:
- Polls every 5 seconds
- Can't detect conflicts in real-time
- Not scalable to 100+ users
Decision: REBUILD with WebSocket architecture
Justification:
- Polling fundamentally can't provide real-time updates
- Refactoring to reduce polling interval doesn't solve core issue
- WebSocket approach is architectural change, not incremental
- Existing data layer can be reused with new transport