ralphinator 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "ralphinator",
3
+ "version": "1.0.0",
4
+ "description": "Autonomous AI-driven software development workflow using Claude Code CLI",
5
+ "repository": "https://github.com/willehpeh/ralphinator",
6
+ "author": "William Alexander",
7
+ "type": "module",
8
+ "bin": {
9
+ "ralphinator": "./src/cli.js"
10
+ },
11
+ "files": [
12
+ "src",
13
+ "ralphs"
14
+ ],
15
+ "scripts": {
16
+ "build": "node src/cli.js build",
17
+ "fix": "node src/cli.js fix"
18
+ },
19
+ "dependencies": {
20
+ "@anthropic-ai/claude-code": "^2.1.12",
21
+ "@inquirer/prompts": "^7.0.0"
22
+ },
23
+ "keywords": [
24
+ "ai",
25
+ "claude",
26
+ "automation",
27
+ "software-development",
28
+ "agentic"
29
+ ],
30
+ "license": "MIT"
31
+ }
@@ -0,0 +1,72 @@
1
+ # Step 2: Understand Existing Behavior
2
+
3
+ You are in Step 2 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## Your Task (Execute Now)
6
+
7
+ 1. Read NEXT_TARGET.md to understand which code area to analyze
8
+ 2. Read the actual source code files identified
9
+ 3. Document what the code ACTUALLY DOES (not what it should do)
10
+ 4. Write your findings to BEHAVIOR.md
11
+ 5. Move NEXT_TARGET.md to CURRENT_TARGET.md
12
+
13
+ ## What to Document in BEHAVIOR.md:
14
+
15
+ ### Current Behavior
16
+ - What inputs does this code accept?
17
+ - What outputs does it produce?
18
+ - What side effects does it have? (database writes, file I/O, network calls, global state)
19
+ - What are the edge cases and error conditions?
20
+
21
+ ### Dependencies
22
+ - What does this code depend on? (other classes, globals, external services)
23
+ - What depends on this code?
24
+ - Which dependencies are problematic for testing?
25
+
26
+ ### Observations
27
+ - Code smells present (long methods, feature envy, shotgun surgery, etc.)
28
+ - Hidden assumptions in the code
29
+ - Surprising behaviors discovered
30
+ - Any existing tests (note: these may not cover all behavior)
31
+
32
+ ### UI Behavior (if applicable)
33
+ For UI components, use Playwright MCP to:
34
+ - Observe how the component renders
35
+ - Document user interactions and their effects
36
+ - Capture current visual appearance and behavior
37
+ - Note any error states or edge case handling in the UI
38
+
39
+ ### Characterization Test Candidates
40
+ - List specific behaviors that need characterization tests
41
+ - Prioritize: what behaviors MUST be preserved?
42
+ - Note any behaviors that are likely bugs vs intentional
43
+
44
+ ## Fast Path: Trivial Fixes
45
+
46
+ If you discover the target is a **trivial, zero-risk fix**, skip the test-writing phase:
47
+
48
+ Examples of trivial fixes:
49
+ - Dead code (unreachable, never called)
50
+ - Unused imports or variables
51
+ - Commented-out code blocks
52
+ - Duplicate imports
53
+ - Obviously unused files
54
+
55
+ For trivial fixes:
56
+ 1. Create CURRENT_TARGET.md as normal
57
+ 2. Create TRIVIAL_FIX.md containing:
58
+ - What the trivial issue is
59
+ - Why it's zero-risk to remove
60
+ - The exact change to make
61
+ 3. Delete NEXT_TARGET.md
62
+ 4. Do NOT create BEHAVIOR.md (not needed for trivial fixes)
63
+
64
+ The workflow will skip directly to Surgeon Ralph.
65
+
66
+ ## Important:
67
+ - Be thorough - this documentation guides all subsequent work
68
+ - Document what IS, not what SHOULD BE
69
+ - Don't judge yet - just observe and record
70
+ - Delete NEXT_TARGET.md after creating CURRENT_TARGET.md
71
+ - Do NOT ask for confirmation - execute immediately and create the output files
72
+ - Only use the trivial fix path when you are 100% certain the fix is safe
@@ -0,0 +1,74 @@
1
+ # Step 4.5: Architectural Review
2
+
3
+ You are in Step 4.5 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## Your Task (Execute Now)
6
+
7
+ 1. Read CURRENT_TARGET.md to understand the cleanup target
8
+ 2. Read BEHAVIOR.md to understand current behavior
9
+ 3. Read SEAM_PLAN.md to see the proposed refactoring approach
10
+ 4. Decide: Is this a refactoring job, or does the architecture need to change?
11
+
12
+ ## When to Propose Architectural Change:
13
+
14
+ Consider architectural improvement when you see:
15
+ - **God Class**: A class doing too many things → Extract classes by responsibility
16
+ - **Feature Envy**: Code that uses another class's data more than its own → Move behavior
17
+ - **Circular Dependencies**: A depends on B depends on A → Introduce interfaces or mediator
18
+ - **Missing Abstraction**: Repeated patterns with no common interface → Extract interface/base class
19
+ - **Inappropriate Intimacy**: Classes that know too much about each other → Introduce facade
20
+ - **Shotgun Surgery**: One change requires edits in many places → Consolidate related code
21
+ - **Divergent Change**: One class changed for many different reasons → Split by responsibility
22
+
23
+ ## When to Approve Refactoring Only:
24
+
25
+ Approve the seam plan as-is when:
26
+ - The structure is fundamentally sound
27
+ - Changes are about testability, not design
28
+ - The scope is small and contained
29
+ - Architectural change would be overengineering
30
+
31
+ ## If Approving Refactoring:
32
+
33
+ 1. Create REFACTORING_APPROVED.md (empty file)
34
+ 2. Keep SEAM_PLAN.md as-is
35
+ 3. Surgeon Ralph will proceed with the seam plan
36
+
37
+ ## If Proposing Architectural Change:
38
+
39
+ 1. Create ARCHITECTURE_PLAN.md containing:
40
+
41
+ ### Problem Statement
42
+ - What structural issue exists?
43
+ - Why is this more than a refactoring?
44
+
45
+ ### Target Architecture
46
+ - What should the structure look like after?
47
+ - Which pattern(s) will be introduced? (Repository, Factory, Strategy, etc.)
48
+
49
+ ### Migration Steps
50
+ Each step must be:
51
+ - Small and independently committable
52
+ - Covered by existing characterization tests
53
+ - Safe to stop after (no half-done states)
54
+
55
+ Example steps:
56
+ 1. Extract interface from existing class
57
+ 2. Create new implementation with improved structure
58
+ 3. Update one caller to use interface
59
+ 4. Repeat for remaining callers
60
+ 5. Remove old implementation
61
+
62
+ ### Risk Assessment
63
+ - What could go wrong?
64
+ - How will we know if it's working?
65
+
66
+ 2. Delete SEAM_PLAN.md (architecture plan supersedes it)
67
+
68
+ ## Important:
69
+ - Architectural changes must still be done incrementally by Surgeon Ralph
70
+ - Each step in the plan should be ONE small change
71
+ - Don't propose architecture changes just because they'd be "nice"
72
+ - The goal is sustainable improvement, not perfection
73
+ - When in doubt, approve the simpler refactoring
74
+ - Do NOT ask for confirmation - execute immediately and create the output file
@@ -0,0 +1,56 @@
1
+ # Step 2: Use Case Breakdown (Alistair Cockburn Style)
2
+
3
+ You are in Step 2 of an agentic software development workflow.
4
+
5
+ ## Your Task
6
+
7
+ 1. Read NEXT_STORY.md to understand the user story
8
+ 2. Break it down into BUSINESS-DRIVEN use cases in Alistair Cockburn style
9
+ 3. Write all use cases to NEXT_USE_CASES.md
10
+ 4. Copy the contents of NEXT_STORY.md to CURRENT_STORY.md, and delete NEXT_STORY.md
11
+
12
+ ## Use Case Format (Alistair Cockburn)
13
+
14
+ Each use case MUST include:
15
+
16
+ **Use Case: [Goal-oriented title]**
17
+ - **Primary Actor**: Who wants to achieve this goal
18
+ - **Goal**: What the actor wants to accomplish (business goal, not technical)
19
+ - **Preconditions**: What must be true before this use case starts
20
+ - **Main Success Scenario**:
21
+ 1. Actor does [business action]
22
+ 2. System responds with [business outcome]
23
+ 3. Actor does [next action]
24
+ 4. etc.
25
+ - **Extensions** (alternative flows):
26
+ - 2a. If [condition]: [what happens]
27
+ - **Success Guarantee**: What is true when use case completes successfully
28
+
29
+ ## Critical Rules
30
+
31
+ - Focus on BUSINESS INTERACTIONS, not technical implementation
32
+ - Describe WHAT the user wants to accomplish, not HOW to build it
33
+ - Use business language, not code/database/API terms
34
+ - Each step should be a meaningful business action or system response
35
+ - NO technical details like "create API endpoint" or "design database schema"
36
+
37
+ ## Examples of GOOD vs BAD
38
+
39
+ **BAD (Technical):**
40
+ - "Create REST API for clients"
41
+ - "Design client database schema"
42
+ - "Implement CRUD operations"
43
+
44
+ **GOOD (Business):**
45
+ - "Add a New Client to the System"
46
+ - Primary Actor: Developer/User
47
+ - Goal: Record a new client in the system
48
+ - Main Success Scenario:
49
+ 1. User enters client company name and contact details
50
+ 2. System validates the information
51
+ 3. System saves the client
52
+ 4. System displays confirmation and client details
53
+
54
+ ## Important:
55
+ - Order use cases logically by business flow and dependencies
56
+ - Each use case should be independently valuable to the business
@@ -0,0 +1,28 @@
1
+ # Step 1: Story Generation or Project Completion
2
+
3
+ You are in Step 1 of an agentic software development workflow.
4
+
5
+ ## Your Task
6
+
7
+ 1. Read PROMPT.md to understand the project requirements
8
+ 2. Read IMPLEMENTED_STORIES.md to see what has been completed (if it exists)
9
+ 3. Assess whether the project is complete - have all requirements in PROMPT.md been fulfilled?
10
+
11
+ ## If Project is Complete:
12
+ 1. Create a file called PROJECT_COMPLETE.md containing:
13
+ - A comprehensive summary of the entire project
14
+ - List of all completed user stories
15
+ - Overall accomplishments and project outcomes
16
+ 2. Send a project completion notification using curl
17
+ 3. Do nothing else - the workflow will terminate
18
+
19
+ ## If Project is Not Complete:
20
+ 1. Generate the next logical user story based on:
21
+ - What requirements remain from PROMPT.md
22
+ - What has already been implemented (in IMPLEMENTED_STORIES.md)
23
+ - Logical progression of features
24
+ 2. Write the user story to NEXT_STORY.md in the monorepo root folder.
25
+
26
+ ## Important:
27
+ - You must choose ONE path: either create PROJECT_COMPLETE.md OR create NEXT_STORY.md
28
+ - Do not create both files
@@ -0,0 +1,22 @@
1
+ # Step 7: Document and Notify
2
+
3
+ You are in Step 7 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## Your Task (Execute Now)
6
+
7
+ 1. Read CLEANED_TARGETS.md to see the completed target
8
+ 2. Create NOTIFICATION.md with a summary of the cleanup work (the wrapper script will send this)
9
+ 3. Delete VERIFICATION_COMPLETE.md
10
+ 4. Create CHRONICLE_COMPLETE.md (empty file)
11
+
12
+ ## NOTIFICATION.md Should Include:
13
+
14
+ - Which code area was cleaned
15
+ - Number of characterization tests added
16
+ - Key improvements made
17
+ - Any notable discoveries or issues found
18
+
19
+ ## Important:
20
+ - Keep NOTIFICATION.md concise (will be sent as a push notification)
21
+ - Must create both NOTIFICATION.md and CHRONICLE_COMPLETE.md when done
22
+ - Do NOT ask for confirmation - execute immediately and create the output files
@@ -0,0 +1,24 @@
1
+ # Step 4: Refactoring
2
+
3
+ You are in Step 4 of an agentic software development workflow.
4
+
5
+ ## Your Task
6
+
7
+ 0. If there are any bugs in BUGS.md, fix the first one. Run all lint, unit test, and build tasks to ensure you fixed it. If a new error appears, add it to BUGS.md.
8
+ If you found and fixed a bug, skip step 1, commit all changes, keep REFACTORING.md and end the iteration.
9
+ 1. Examine the codebase for refactoring opportunities
10
+ 2. If you find a USEFUL refactoring (think YAGNI, avoid overengineering):
11
+ - Implement ONE refactoring only
12
+ - Run all lint, unit test, and build tasks
13
+ - If there are any errors, write them to BUGS.md, creating the file if necessary
14
+ - Commit: git add . && git commit -m "refactoring description"
15
+ - Keep REFACTORING.md
16
+ 3. If no more useful refactorings:
17
+ - Push: git push
18
+ - Delete REFACTORING.md
19
+ - Create REFACTORING_COMPLETE.md and leave it empty
20
+
21
+ ## Important:
22
+ - Only ONE refactoring per iteration
23
+ - Only push and delete REFACTORING.md when done
24
+ - Make sure you create REFACTORING_COMPLETE.md when done
@@ -0,0 +1,82 @@
1
+ # Step 3.5: Task Implementation - ONE SMALL ATOMIC TASK ONLY
2
+
3
+ You are in Step 3.5 of an agentic software development workflow.
4
+
5
+ ## CRITICAL: You Must Implement ONLY ONE Task
6
+
7
+ This iteration is for implementing a SINGLE, SMALL, ATOMIC task. Not multiple tasks. Not a large task. ONE small task.
8
+
9
+ ## What is a Task?
10
+
11
+ A task is the SMALLEST meaningful unit of work that:
12
+ - Can be completed in one focused coding session (15-30 minutes)
13
+ - Makes ONE specific change or addition
14
+ - Can be described in a single sentence
15
+ - Results in a single commit
16
+
17
+ ## Examples of GOOD (Atomic) Tasks:
18
+
19
+ ✅ "Create User aggregate root class with create method"
20
+ ✅ "Add UserCreatedDomainEvent with required fields"
21
+ ✅ "Implement CreateUserCommand handler to call aggregate"
22
+ ✅ "Create UserReadModel DTO with basic fields"
23
+ ✅ "Add GET endpoint for retrieving single user"
24
+ ✅ "Write test for UserAggregate.create() method"
25
+
26
+ ## Examples of BAD (Too Large) Tasks:
27
+
28
+ ❌ "Implement complete user management system"
29
+ ❌ "Build user CRUD with all endpoints"
30
+ ❌ "Create user domain, application, and infrastructure layers"
31
+ ❌ "Implement users with authentication and validation"
32
+
33
+ If you find yourself wanting to do any of these, STOP. Break it down into smaller tasks.
34
+
35
+ ## Your Task This Iteration
36
+
37
+ 1. Read CURRENT_USE_CASE.md to understand the use case
38
+ 2. Read the task documentation file to see what's been completed
39
+ 3. Read CLAUDE.md for implementation guidance
40
+ 4. Identify the NEXT SMALLEST task needed
41
+ 5. Implement ONLY that ONE task
42
+ 6. Document it in the task file
43
+ 7. Commit: git add . && git commit -m "descriptive message"
44
+ 8. Assess if the use case is complete
45
+
46
+ ## Task Size Guidelines
47
+
48
+ If your task involves more than ONE of these, it's too big:
49
+ - Creating multiple files
50
+ - Implementing multiple methods
51
+ - Adding multiple endpoints
52
+ - Writing multiple event handlers
53
+ - Creating multiple aggregates
54
+
55
+ Break it down further. Do ONE thing.
56
+
57
+ ## If Use Case is Complete:
58
+
59
+ 1. Push all commits: git push
60
+ 2. Update IMPLEMENTED_CASES.md with the completed use case
61
+ 3. Update IMPLEMENTED_STORIES.md if this completes a story
62
+ 4. Remove this use case from NEXT_USE_CASES.md
63
+ 5. Delete CURRENT_USE_CASE.md
64
+ 6. Keep the task documentation file
65
+
66
+ ## If Use Case is Not Complete:
67
+
68
+ 1. Do NOT push
69
+ 2. Do NOT delete CURRENT_USE_CASE.md
70
+ 3. The next iteration will implement the next task
71
+
72
+ ## Absolutely Critical:
73
+
74
+ - ONE task per iteration - not two, not three, ONE
75
+ - Small and atomic - if it feels large, make it smaller
76
+ - Single responsibility - the task does one thing
77
+ - Quick to implement - should take minutes, not hours
78
+ - Immediately committable - creates a clean, working state
79
+
80
+ Remember: The workflow will loop. You will be called again. There's no rush to do everything now.
81
+ Focus on doing ONE SMALL THING WELL.
82
+ If your task involves the frontend, ensure the interface is modern and professional. Do not be negligent with styling.
@@ -0,0 +1,31 @@
1
+ # Step 3: Use Case Selection
2
+
3
+ You are in Step 3 of an agentic software development workflow.
4
+
5
+ ## Your Task
6
+
7
+ 1. Read NEXT_USE_CASES.md to see all remaining use cases
8
+ 2. Check if there are ANY use cases left in the file
9
+ 3. Take action based on what you find:
10
+
11
+ ## If NO Use Cases Remain (file is empty or only has headers):
12
+ 1. Delete NEXT_USE_CASES.md
13
+ 2. Do NOT create CURRENT_USE_CASE.md
14
+ 3. Create REFACTORING.md and leave it empty.
15
+ 3a. Add the current story from CURRENT_STORY.md to IMPLEMENTED_STORIES.md, and delete CURRENT_STORY.md.
16
+ 4. The workflow will move to refactoring (Step 4)
17
+
18
+ ## If Use Cases Remain:
19
+ 1. Analyze which use case should be implemented next based on:
20
+ - Dependencies (what needs to be built first)
21
+ - Logical implementation order
22
+ - Business priority
23
+ 2. Write the selected use case to CURRENT_USE_CASE.md
24
+ 3. Create an empty task documentation file named descriptively after the use case
25
+ 4. Do NOT modify NEXT_USE_CASES.md (Step 3.5 will remove completed ones)
26
+
27
+ ## Important:
28
+ - Your job is to recognize when all use cases are done
29
+ - If the file is empty, delete it and move on
30
+ - If there are use cases, select the most logical next one
31
+ - Task documentation filename should clearly describe the use case (e.g., "add-client-tasks.md")
@@ -0,0 +1,15 @@
1
+ # Step 5: Story Completion Notification
2
+
3
+ You are in Step 5 of an agentic software development workflow.
4
+
5
+ ## Your Task
6
+
7
+ 1. Read IMPLEMENTED_STORIES.md and IMPLEMENTED_CASES.md
8
+ 2. Create a summary of the completed story
9
+ 3. Send notification using curl, the exact command iscurl -d "$SUMMARY" ntfy.sh/willehpeh-es-crm-ralphinator
10
+ 4. Create STORY_COMPLETE.md
11
+ 5. Delete REFACTORING_COMPLETE.me
12
+
13
+ ## Important:
14
+ - Keep notification concise
15
+ - Must create STORY_COMPLETE.md
@@ -0,0 +1,57 @@
1
+ # Step 4: Find Seams for Safe Changes
2
+
3
+ You are in Step 4 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## What is a Seam?
6
+
7
+ From Michael Feathers: "A seam is a place where you can alter behavior in your program without editing in that place."
8
+
9
+ Seams allow us to break dependencies and make code testable without risky changes.
10
+
11
+ ## Your Task
12
+
13
+ 1. Read CURRENT_TARGET.md to understand the cleanup target
14
+ 2. Read BEHAVIOR.md to understand the code's behavior and dependencies
15
+ 3. Read CHARACTERIZATION_TESTS.md to see what's covered by tests
16
+ 4. Analyze the code for seams and dependency-breaking opportunities
17
+ 5. Create SEAM_PLAN.md with your refactoring strategy
18
+ 6. Delete TESTS_COMPLETE.md
19
+
20
+ ## Types of Seams to Look For:
21
+
22
+ ### Object Seams
23
+ - Can we subclass and override methods?
24
+ - Can we extract an interface?
25
+ - Can we use dependency injection?
26
+
27
+ ### Preprocessing Seams
28
+ - Can we use configuration to swap implementations?
29
+ - Can we use feature flags?
30
+
31
+ ### Link Seams
32
+ - Can we substitute dependencies at build/link time?
33
+
34
+ ## Dependency-Breaking Techniques to Consider:
35
+
36
+ - **Extract Interface**: Create an interface for a dependency
37
+ - **Parameterize Constructor**: Pass dependencies in rather than creating them
38
+ - **Extract and Override Call**: Make a method that can be overridden in tests
39
+ - **Subclass and Override Method**: Create a testing subclass
40
+ - **Replace Global Reference with Getter**: Wrap global access in an overridable method
41
+ - **Introduce Instance Delegator**: Wrap static methods
42
+ - **Skin and Wrap the API**: Create a thin wrapper around external dependencies
43
+
44
+ ## SEAM_PLAN.md Should Include:
45
+
46
+ 1. **Identified Seams**: Where can we alter behavior?
47
+ 2. **Problematic Dependencies**: What makes this code hard to test/change?
48
+ 3. **Recommended Techniques**: Which dependency-breaking techniques to apply
49
+ 4. **Refactoring Order**: Sequence of safe steps (smallest first)
50
+ 5. **Risk Assessment**: What could go wrong?
51
+
52
+ ## Important:
53
+ - Plan small, incremental changes
54
+ - Each planned step should be independently committable
55
+ - Prefer the simplest technique that works
56
+ - The plan guides Surgeon Ralph's work
57
+ - Do NOT ask for confirmation - execute immediately and create the output file
@@ -0,0 +1,78 @@
1
+ # Step 5: Perform Safe Refactoring
2
+
3
+ You are in Step 5 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## CRITICAL: One Refactoring Per Iteration
6
+
7
+ Make ONE small, safe refactoring per iteration. Not multiple changes. ONE change.
8
+
9
+ ## The Refactoring Loop
10
+
11
+ This step may run many times. Each iteration:
12
+ 1. Makes one small change
13
+ 2. Runs tests to verify behavior is preserved
14
+ 3. Commits if tests pass
15
+
16
+ ## Your Task This Iteration
17
+
18
+ 1. Read CURRENT_TARGET.md to understand the cleanup target
19
+ 2. Read the plan file:
20
+ - If TRIVIAL_FIX.md exists, perform the trivial fix described (dead code removal, etc.)
21
+ - If ARCHITECTURE_PLAN.md exists, follow the architectural migration steps
22
+ - Otherwise, read SEAM_PLAN.md for the refactoring strategy
23
+ 3. Read REFACTORING_LOG.md to see what's been done (if it exists)
24
+ 4. Identify the NEXT small change from the plan
25
+ 5. Make ONE change
26
+ 6. Run ALL tests (especially characterization tests)
27
+ 7. If tests pass: commit and log the change
28
+ 8. If tests fail: revert and document the issue
29
+ 9. Assess if the target is sufficiently cleaned
30
+
31
+ ## Safe Refactoring Guidelines:
32
+
33
+ ### Keep Changes Small
34
+ - Rename one thing
35
+ - Extract one method
36
+ - Move one piece of code
37
+ - Introduce one parameter
38
+ - Extract one interface
39
+
40
+ ### Verify After Each Change
41
+ - Run characterization tests
42
+ - Run any existing unit tests
43
+ - Run integration tests if available
44
+ - Check for compilation errors
45
+
46
+ ### If Tests Fail
47
+ 1. REVERT the change immediately
48
+ 2. Document what went wrong in REFACTORING_LOG.md
49
+ 3. Consider a smaller step or different approach
50
+ 4. End this iteration
51
+
52
+ ## Logging Changes
53
+
54
+ Add each successful refactoring to REFACTORING_LOG.md:
55
+ ```
56
+ ## [Timestamp]
57
+ - Change: [what you did]
58
+ - Technique: [which technique from SEAM_PLAN.md]
59
+ - Tests: [all passing]
60
+ ```
61
+
62
+ ## If Target Cleanup is Complete:
63
+ 1. Push: git push
64
+ 2. Delete SEAM_PLAN.md and/or ARCHITECTURE_PLAN.md and/or TRIVIAL_FIX.md
65
+ 3. Delete REFACTORING_APPROVED.md if it exists
66
+ 4. Create TARGET_COMPLETE.md (empty file)
67
+
68
+ ## If More Refactoring Needed:
69
+ 1. Do NOT push
70
+ 2. Do NOT create TARGET_COMPLETE.md
71
+ 3. The next iteration will continue
72
+
73
+ ## Important:
74
+ - ONE refactoring per iteration
75
+ - ALWAYS run tests after changes
76
+ - REVERT if tests fail - don't try to fix forward
77
+ - Small steps are safer than big leaps
78
+ - Do NOT ask for confirmation - execute immediately
@@ -0,0 +1,38 @@
1
+ # Step 1: Survey and Target Selection
2
+
3
+ You are in Step 1 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## Your Task (Execute Now)
6
+
7
+ 1. Read LEGACY_PROMPT.md to understand the cleanup goals
8
+ 2. Read CLEANED_TARGETS.md to see what has already been cleaned (if it exists)
9
+ 3. Assess whether the cleanup goals have been fully achieved
10
+ 4. Create the appropriate output file as described below
11
+
12
+ ## If Cleanup is Complete:
13
+ 1. Create a file called CLEANUP_COMPLETE.md containing:
14
+ - A summary of all cleaned areas
15
+ - Improvements made
16
+ - Test coverage added
17
+ 2. Do nothing else - the workflow will terminate
18
+
19
+ ## If Cleanup is Not Complete:
20
+ 1. Analyze the codebase to identify the next area needing cleanup
21
+ 2. Choose a SMALL, focused target - a single class, function, or tightly-coupled group
22
+ 3. Write the target to NEXT_TARGET.md including:
23
+ - File path(s) involved
24
+ - Why this area needs cleanup
25
+ - What problems exist (tight coupling, no tests, unclear responsibility, etc.)
26
+ - Rough scope estimate
27
+
28
+ ## Target Selection Criteria:
29
+ - Prefer areas with high change frequency (pain points)
30
+ - Start with leaf nodes (fewer dependencies) when possible
31
+ - Choose areas small enough to clean in a few iterations
32
+ - Consider the "strangler fig" pattern - start at edges, work inward
33
+
34
+ ## Important:
35
+ - You must choose ONE path: either create CLEANUP_COMPLETE.md OR create NEXT_TARGET.md
36
+ - Do not create both files
37
+ - Keep targets small and focused
38
+ - Do NOT ask for confirmation - execute immediately and create the output file
@@ -0,0 +1,65 @@
1
+ # Step 3: Write Characterization Tests
2
+
3
+ You are in Step 3 of a legacy code cleanup workflow. Execute this task immediately without asking for confirmation.
4
+
5
+ ## CRITICAL: One Test Per Iteration
6
+
7
+ Write ONE characterization test per iteration. Not multiple tests. ONE test.
8
+
9
+ ## What is a Characterization Test?
10
+
11
+ A characterization test captures what the code ACTUALLY DOES, not what it should do.
12
+ The test documents existing behavior so we can safely refactor without changing it.
13
+
14
+ From Michael Feathers: "A characterization test is a test that characterizes the actual behavior of a piece of code."
15
+
16
+ ## Your Task This Iteration
17
+
18
+ 1. Read CURRENT_TARGET.md to understand the cleanup target
19
+ 2. Read BEHAVIOR.md to see documented behaviors
20
+ 3. Read existing test files to see what's already covered
21
+ 4. Read CHARACTERIZATION_TESTS.md to see which behaviors have been tested (if it exists)
22
+ 5. Identify ONE behavior that needs a characterization test
23
+ 6. Write ONE test that captures that behavior
24
+ 7. Run the test to ensure it passes (it must - we're testing current behavior)
25
+ 8. Document the test in CHARACTERIZATION_TESTS.md
26
+ 9. Commit: git add . && git commit -m "Add characterization test: [behavior]"
27
+ 10. Assess if sufficient test coverage exists
28
+
29
+ ## Writing Good Characterization Tests:
30
+
31
+ 1. Call the code with specific inputs
32
+ 2. Assert on the ACTUAL output (even if it seems wrong)
33
+ 3. Name the test descriptively: `test_[method]_when_[condition]_returns_[result]`
34
+ 4. Include edge cases and error conditions
35
+ 5. Test side effects where possible
36
+
37
+ ## Playwright MCP for E2E Tests
38
+
39
+ For UI components and user flows, use the Playwright MCP to:
40
+ - Navigate to pages and interact with elements
41
+ - Capture current behavior (screenshots, assertions)
42
+ - Test user journeys end-to-end
43
+
44
+ When writing E2E characterization tests:
45
+ 1. Use Playwright MCP to observe current UI behavior
46
+ 2. Write Playwright tests that capture that behavior
47
+ 3. Place tests in appropriate test directory (check existing test structure)
48
+
49
+ Prefer unit tests for pure logic, Playwright tests for UI/integration behavior.
50
+
51
+ ## If Tests Are Sufficient:
52
+ When you have covered the key behaviors in BEHAVIOR.md:
53
+ 1. Create TESTS_COMPLETE.md (empty file)
54
+ 2. Do NOT delete CURRENT_TARGET.md
55
+
56
+ ## If More Tests Needed:
57
+ 1. Do NOT create TESTS_COMPLETE.md
58
+ 2. The next iteration will write another test
59
+
60
+ ## Important:
61
+ - ONE test per iteration
62
+ - Tests must PASS - they capture current behavior
63
+ - Don't fix bugs yet - just document behavior
64
+ - Coverage over risky areas is more important than 100% coverage
65
+ - Do NOT ask for confirmation - execute immediately