Skip to content

Commit 9998902

Browse files
committed
feat: Add typed-holes-refactor skill for systematic TDD refactoring
Add comprehensive typed-holes-refactor skill for systematic codebase refactoring using Design by Typed Holes methodology: - New skill directory: skills/typed-holes-refactor/ - SKILL.md: Main documentation (~350 lines) with workflows and principles - README.md: Overview and quick start guide (~197 lines) - references/: Comprehensive pattern catalogs - HOLE_TYPES.md: Complete taxonomy of refactoring holes - CONSTRAINT_RULES.md: Constraint propagation patterns - VALIDATION_PATTERNS.md: Test patterns for validation - scripts/: Python automation tools (~3000 total lines) - discover_holes.py: Analyze codebase and generate REFACTOR_IR.md - next_hole.py: Show next resolvable holes based on dependencies - validate_resolution.py: Check if hole resolution satisfies constraints - propagate.py: Update dependent holes after resolution - generate_report.py: Create comprehensive delta report - Updated skills/_INDEX.md: - Added to "Workflow & Task Management" category (5 → 6 skills) - Added to discovery patterns by technology/task/domain - Added "Systematic Codebase Refactoring" workflow example - Added to quick reference table - Updated total skills count: 133 → 134 - Updated last modified date: 2025-10-23 - Updated CLAUDE.md: - Added typed-holes-refactor to skills catalog (133 → 134 total) - Updated "Workflow & Tasks" category (5 → 6 skills) - Added to quick category reference - Updated quality standards count Key features: - Test-driven refactoring: Write validation tests BEFORE implementing - Safe by construction: Works in branches, preserves main and .beads/ - Systematic hole resolution with dependency tracking - Continuous validation against characterization tests - Comprehensive tooling for discovery, validation, and reporting - Formal completeness gates ensure refactoring quality Use when: Architecture refactoring, code consolidation, technical debt reduction, complexity reduction, or quality improvement projects requiring systematic, validated changes.
1 parent befc299 commit 9998902

12 files changed

Lines changed: 3053 additions & 11 deletions

File tree

CLAUDE.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ open https://ui.shadcn.com/themes
494494
**New approach**: Atomic, composable skills (~300 lines avg, <500 line guideline)
495495

496496
### Quality Standards (as of 2025-10-23)
497-
- ✅ **133 skills** with YAML frontmatter (agent_skills_spec.md compliant)
497+
- ✅ **134 skills** with YAML frontmatter (agent_skills_spec.md compliant)
498498
- ✅ **0 future dates** - all dates validated by CI
499499
- ✅ **Automated testing** - code syntax validation in CI
500500
- 🔄 **Size optimization** - 89 skills >500 lines identified for splitting
@@ -531,15 +531,15 @@ Read zig-memory-management.md, zig-testing-patterns.md
531531
Read beads-workflow.md + beads-context-strategies.md + beads-multi-session-patterns.md
532532
```
533533

534-
### Skills Catalog (133 Total)
534+
### Skills Catalog (134 Total)
535535

536-
**Core Categories** (75 skills):
536+
**Core Categories** (76 skills):
537537
- **API Design** (7): REST, GraphQL, auth/authz, rate limiting, versioning, error handling
538538
- **Testing** (6): Unit, integration, e2e, TDD, coverage, performance testing
539539
- **Containers** (5): Dockerfile optimization, Compose, security, networking, registries
540540
- **Frontend** (8): React patterns, Next.js App Router, state/data/forms, a11y, performance, SEO
541541
- **Database** (11): Postgres (optimization, migrations, schema), MongoDB, Redis, Redpanda/Kafka streaming, Apache Iceberg, DuckDB analytics, pooling, ORMs, selection
542-
- **Workflow & Tasks** (5): Beads workflow, context strategies, multi-session, dependency management
542+
- **Workflow & Tasks** (6): Beads workflow, context strategies, multi-session, dependency management, typed-holes refactoring
543543
- **Quality & Content Review** (1): Anti-slop detection and cleanup (text, code, design)
544544
- **Meta Skills** (4): Skill discovery and planning for repositories and prompts
545545
- Discovery: `skill-repo-discovery.md` (analyze repos), `skill-prompt-discovery.md` (analyze prompts)
@@ -578,7 +578,7 @@ Frontend: react-*.md (5) | nextjs-*.md (2) | web-*.md, frontend-*.md (3)
578578
DevOps/Infra: cicd/ (5) | infrastructure/ (6) | observability/ (5)
579579
Data: data/ (5) | realtime/ (4)
580580
Specialized: modal-*.md (8) | swiftui-*.md, swift-*.md, ios-*.md (6) | zig-*.md (6)
581-
Workflow: beads-*.md (4) | tui-*.md (5) | network-*.md (5)
581+
Workflow: beads-*.md (4) | typed-holes-refactor/ (1 skill + 3 refs + 5 scripts) | tui-*.md (5) | network-*.md (5)
582582
Quality: anti-slop/ (1 skill + 3 reference guides + 2 scripts)
583583
Meta: skill-*.md (5 including skill-creation.md)
584584
Formal: formal/z3-*.md, formal/sat-*.md, formal/smt-*.md (3) | formal/lean-*.md (4) | formal/csp-*.md (3)
@@ -603,7 +603,7 @@ Mobile: mobile/react-native-*.md (4)
603603
4. **Deep dive?** Search `skills/_INDEX.md` by technology/task/problem domain
604604
5. **Emergency?** Read relevant skill directly: `skills/api-*.md`, `skills/cicd/*.md`
605605

606-
**Full catalog**: `skills/_INDEX.md` (133 skills, workflows, search patterns, combinations)
606+
**Full catalog**: `skills/_INDEX.md` (134 skills, workflows, search patterns, combinations)
607607

608608
### Skill Quality Assurance
609609
All skills now include:

skills/_INDEX.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,21 @@ This index catalogs all atomic skills available in the skills system, organized
110110

111111
---
112112

113-
### Workflow & Task Management (5 skills)
113+
### Workflow & Task Management (6 skills)
114114

115115
| Skill | Use When | Lines |
116116
|-------|----------|-------|
117117
| `beads-workflow.md` | Starting sessions, running bd commands, managing issue workflow | ~350 |
118118
| `beads-dependency-management.md` | Creating issue relationships, managing blockers, organizing work hierarchies | ~450 |
119119
| `beads-context-strategies.md` | Managing Claude context, preventing bloat, preserving workflow state | ~400 |
120120
| `beads-multi-session-patterns.md` | Complex multi-session tasks, long-horizon work chains, parallel streams | ~350 |
121+
| `typed-holes-refactor/SKILL.md` | Systematic codebase refactoring using Design by Typed Holes - iterative, test-driven with formal validation | ~350 |
121122
| `skill-creation.md` | Creating new atomic skills, maintaining skills system, CLAUDE.md integration | ~400 |
122123

123124
**Common workflows:**
124125
- New session: `beads-workflow.md``beads-context-strategies.md`
125126
- Complex task: `beads-workflow.md``beads-dependency-management.md``beads-multi-session-patterns.md`
127+
- Systematic refactoring: `typed-holes-refactor/SKILL.md` → Test-driven hole resolution → Constraint propagation
126128
- Context management: `beads-context-strategies.md` (throughout session)
127129
- Create new skill: `skill-creation.md` → Update _INDEX.md → Update CLAUDE.md
128130

@@ -508,6 +510,7 @@ This index catalogs all atomic skills available in the skills system, organized
508510
**TUI (Rust):** Search `ratatui-*.md`, `tui-*.md`
509511
**Zig:** Search `zig-*.md`
510512
**Beads:** Search `beads-*.md`
513+
**Refactoring:** `typed-holes-refactor/SKILL.md` (systematic TDD refactoring)
511514
**Quality & Content:** `anti-slop/SKILL.md`, `anti-slop/references/*.md`
512515
**Meta Skills:** Search `skill-*.md`
513516
**CI/CD:** Search `cicd/*.md`, `github-*.md`, `ci-*.md`, `cd-*.md`
@@ -554,6 +557,12 @@ This index catalogs all atomic skills available in the skills system, organized
554557
- Code patterns: `anti-slop/references/code-patterns.md`
555558
- Design patterns: `anti-slop/references/design-patterns.md`
556559

560+
**Refactoring:**
561+
- Systematic refactoring: `typed-holes-refactor/SKILL.md`
562+
- Hole discovery: `typed-holes-refactor/scripts/discover_holes.py`
563+
- Constraint propagation: `typed-holes-refactor/references/CONSTRAINT_RULES.md`
564+
- Validation patterns: `typed-holes-refactor/references/VALIDATION_PATTERNS.md`
565+
557566
**Networking:**
558567
- iOS: `ios-networking.md`
559568
- Secure: `mtls-implementation.md`, `tailscale-vpn.md`
@@ -598,6 +607,7 @@ This index catalogs all atomic skills available in the skills system, organized
598607
**DevOps/SRE:** `cicd/*.md`, `infrastructure/*.md`, `observability/*.md`, `cost-optimization.md`, `heroku-*.md`, `netlify-*.md`
599608
**Data Engineering:** `data/*.md`, `stream-processing.md`, `batch-processing.md`, `data-validation.md`
600609
**Content Quality:** `anti-slop/SKILL.md` (text, code, design quality review and cleanup)
610+
**Refactoring:** `typed-holes-refactor/SKILL.md` (systematic test-driven refactoring with hole resolution)
601611
**Real-time Systems:** `realtime/*.md`, `websocket-implementation.md`, `server-sent-events.md`, `pubsub-patterns.md`
602612
**Formal Methods:** `formal/z3-*.md`, `formal/lean-*.md`, `formal/sat-*.md`, `formal/smt-*.md`, `formal/csp-*.md`
603613
**Machine Learning:** `ml/unsloth-*.md`, `ml/diffusion-*.md`, `ml/llm-*.md`, `ml/stable-diffusion-*.md`
@@ -702,6 +712,14 @@ This index catalogs all atomic skills available in the skills system, organized
702712
3. `beads-multi-session-patterns.md` - Long-horizon patterns
703713
4. `beads-context-strategies.md` - Context preservation (throughout)
704714

715+
### Systematic Codebase Refactoring
716+
1. `typed-holes-refactor/SKILL.md` - Design by Typed Holes methodology
717+
2. Create characterization tests - Capture current behavior
718+
3. Discover holes - Identify architectural unknowns
719+
4. Resolve holes iteratively - Test-driven development
720+
5. Propagate constraints - Update dependent holes
721+
6. Generate report - Comprehensive delta analysis
722+
705723
### SAT/SMT-based Verification
706724
1. `z3-solver-basics.md` - Z3 fundamentals
707725
2. `sat-solving-strategies.md` - SAT encoding
@@ -823,24 +841,25 @@ This index catalogs all atomic skills available in the skills system, organized
823841
| Review content for AI slop | anti-slop/SKILL.md | 1 |
824842
| Clean up generic code | anti-slop/references/code-patterns.md | 1 |
825843
| Review design quality | anti-slop/references/design-patterns.md | 1 |
844+
| Refactor codebase systematically | typed-holes-refactor/SKILL.md | 1 |
826845

827846
---
828847

829848
## Total Skills Count
830849

831-
- **133 atomic skills** across 28 categories
850+
- **134 atomic skills** across 28 categories
832851
- **Average 310 lines** per skill
833852
- **100% focused** - each skill has single clear purpose
834853
- **Cross-referenced** - related skills linked for discoverability
835854

836855
### By Category Breakdown
837-
**Core Foundation** (75 skills):
856+
**Core Foundation** (76 skills):
838857
- API Design: 7 skills
839858
- Testing: 6 skills
840859
- Containers: 5 skills
841860
- Frontend: 8 skills
842861
- Database: 11 skills
843-
- Workflow & Task Management: 5 skills
862+
- Workflow & Task Management: 6 skills (including typed-holes refactoring)
844863
- Quality & Content Review: 1 skill (anti-slop detection and cleanup)
845864
- Meta Skills: 4 skills (skill discovery and planning)
846865
- iOS/Swift: 6 skills
@@ -888,5 +907,5 @@ See `MIGRATION_GUIDE.md` for detailed mapping.
888907
---
889908

890909
**Last Updated:** 2025-10-23
891-
**Total Skills:** 133
910+
**Total Skills:** 134
892911
**Format Version:** 1.0 (Atomic)
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
# Typed Holes Refactor - Claude Code Skill
2+
3+
A comprehensive skill for systematically refactoring codebases using the Design by Typed Holes methodology - iterative, test-driven refactoring with formal hole resolution, constraint propagation, and continuous validation.
4+
5+
## What This Skill Does
6+
7+
This skill helps you refactor codebases by:
8+
9+
1. **Discovering architectural unknowns** ("holes") in your codebase
10+
2. **Resolving holes systematically** using test-driven development
11+
3. **Propagating constraints** through dependency graphs
12+
4. **Validating continuously** to prevent regressions
13+
5. **Generating comprehensive reports** comparing old vs new
14+
15+
## Key Features
16+
17+
-**Test-Driven**: Write validation tests BEFORE refactoring
18+
-**Safe**: Works in branches, preserves main and .beads/
19+
-**Systematic**: Formal hole resolution with dependency tracking
20+
-**Validated**: Continuous validation against characterization tests
21+
-**Comprehensive**: Complete tooling for discovery, validation, and reporting
22+
23+
## Installation
24+
25+
### Option 1: Claude Desktop/Web (Recommended)
26+
27+
1. Download `typed-holes-refactor.skill`
28+
2. In Claude, go to Settings → Skills
29+
3. Click "Add Skill" and upload the .skill file
30+
4. The skill is now available for use!
31+
32+
### Option 2: Manual Installation (Claude Code)
33+
34+
```bash
35+
# Copy skill to your skills directory
36+
mkdir -p ~/.claude/skills
37+
unzip typed-holes-refactor.skill -d ~/.claude/skills/
38+
```
39+
40+
## Quick Start
41+
42+
### Step 1: Install the Skill
43+
44+
Follow installation instructions above.
45+
46+
### Step 2: Start Claude Code in Your Project
47+
48+
```bash
49+
cd your-project
50+
claude-code
51+
```
52+
53+
### Step 3: Use the Initial Prompt
54+
55+
Copy and paste this into Claude Code:
56+
57+
```
58+
I want to refactor this codebase using the typed-holes-refactor skill. Here's the context:
59+
60+
Repository: [describe your repo]
61+
Goal: [what you want to achieve]
62+
Constraints: [any specific constraints]
63+
64+
Please:
65+
1. Read the typed-holes-refactor skill
66+
2. Create a safe refactor branch
67+
3. Run discover_holes.py to analyze the codebase
68+
4. Create baseline characterization tests
69+
5. Help me resolve holes one by one using test-driven development
70+
71+
Let's start with the discovery phase.
72+
```
73+
74+
### Step 4: Follow the Process
75+
76+
The skill will guide you through:
77+
78+
1. **Discovery**: Analyze codebase and identify holes
79+
2. **Characterization**: Write tests capturing current behavior
80+
3. **Resolution**: Resolve holes one by one with TDD
81+
4. **Validation**: Continuous validation at each step
82+
5. **Reporting**: Generate comprehensive delta report
83+
84+
## Workflow Overview
85+
86+
```
87+
┌─────────────────────────────────────────────────────────┐
88+
│ 1. DISCOVERY │
89+
│ git checkout -b refactor/typed-holes-v1 │
90+
│ python scripts/discover_holes.py │
91+
│ → Creates REFACTOR_IR.md with hole catalog │
92+
└─────────────────────────────────────────────────────────┘
93+
94+
┌─────────────────────────────────────────────────────────┐
95+
│ 2. CHARACTERIZATION │
96+
│ Create tests/characterization/test_*.py │
97+
│ → Captures exact current behavior │
98+
│ → Safety net for refactoring │
99+
└─────────────────────────────────────────────────────────┘
100+
101+
┌─────────────────────────────────────────────────────────┐
102+
│ 3. ITERATIVE RESOLUTION (repeat for each hole) │
103+
│ a. python scripts/next_hole.py │
104+
│ → Shows ready holes │
105+
│ b. Write tests/refactor/test_h{N}_*.py (fails first) │
106+
│ c. Implement resolution │
107+
│ d. python scripts/validate_resolution.py H{N} │
108+
│ e. python scripts/propagate.py H{N} │
109+
│ f. git commit -m "Resolve H{N}: ..." │
110+
└─────────────────────────────────────────────────────────┘
111+
112+
┌─────────────────────────────────────────────────────────┐
113+
│ 4. FINAL REPORT │
114+
│ python scripts/generate_report.py > REFACTOR_REPORT.md│
115+
│ → Comprehensive delta analysis │
116+
│ → Ready for merge │
117+
└─────────────────────────────────────────────────────────┘
118+
```
119+
120+
## Scripts Included
121+
122+
The skill includes these automation scripts:
123+
124+
- **`discover_holes.py`** - Analyze codebase and generate REFACTOR_IR.md
125+
- **`next_hole.py`** - Show next resolvable holes based on dependencies
126+
- **`validate_resolution.py`** - Check if hole resolution satisfies constraints
127+
- **`propagate.py`** - Update dependent holes after resolution
128+
- **`generate_report.py`** - Create comprehensive delta report
129+
130+
All scripts include `--help` for detailed usage.
131+
132+
## Reference Documentation
133+
134+
The skill includes comprehensive references:
135+
136+
- **`HOLE_TYPES.md`** - Complete taxonomy of refactoring holes
137+
- **`CONSTRAINT_RULES.md`** - Constraint propagation patterns
138+
- **`VALIDATION_PATTERNS.md`** - Test patterns for validation
139+
140+
Claude will read these as needed during the refactoring process.
141+
142+
## Example Usage
143+
144+
See `USAGE_PROMPT.md` for:
145+
- Complete example prompts
146+
- Troubleshooting guides
147+
- Advanced usage patterns
148+
- Best practices
149+
150+
## When to Use This Skill
151+
152+
Perfect for:
153+
- 🏗️ **Architecture refactoring** - Reorganizing code structure
154+
- 🔄 **Code consolidation** - Merging duplicate implementations
155+
- 🧹 **Technical debt reduction** - Systematic cleanup
156+
- 📈 **Complexity reduction** - Simplifying convoluted code
157+
-**Quality improvement** - Improving test coverage and code quality
158+
159+
Not ideal for:
160+
- Small, localized changes (overkill)
161+
- Exploratory refactoring (too structured)
162+
- Breaking changes without compatibility needs (use simpler approach)
163+
164+
## Key Principles
165+
166+
1. **Test-Driven Everything** - Write tests before refactoring
167+
2. **Hole-Driven Progress** - Resolve unknowns systematically
168+
3. **Continuous Validation** - Never break characterization tests
169+
4. **Safe by Construction** - Work in branches, preserve history
170+
5. **Formal Completeness** - All holes resolved = refactoring complete
171+
172+
## Compatibility
173+
174+
- **Works with**: Python, JavaScript, TypeScript, Go, Rust, and other languages
175+
- **Requires**: Git repository with branch support
176+
- **Optional**: pytest (for Python), radon (for complexity analysis)
177+
178+
## Support
179+
180+
If you encounter issues:
181+
182+
1. Check `USAGE_PROMPT.md` for troubleshooting prompts
183+
2. Review the reference documentation in the skill
184+
3. Ask Claude Code for help - it has access to all skill documentation
185+
186+
## Meta-Consistency
187+
188+
This skill practices what it preaches: it uses the typed holes methodology to refactor codebases, and can even use itself to improve itself! 🤯
189+
190+
## License
191+
192+
See LICENSE.txt in the skill package.
193+
194+
---
195+
196+
**Ready to refactor systematically? Install the skill and start with the prompts in USAGE_PROMPT.md!**

0 commit comments

Comments
 (0)