Execute plans perfectly using Ralph Loop for iterative completion
Executes plans perfectly using Ralph Loop with strict TDD enforcement and quality gates.
/plugin marketplace add settlemint/agent-marketplace/plugin install crew@settlemint[plan slug]<worktree_status>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/worktree-context.sh
</worktree_status>
<stack_context>
!${CLAUDE_PLUGIN_ROOT}/scripts/git/machete-context.sh
</stack_context>
Execute a plan perfectly using Ralph Loop for guaranteed completion. Strictly enforces TDD (Test-Driven Development) - NO implementation code without failing tests first. Parallelizes work, runs CI continuously, uses browser testing for UI, runs quality reviews, and writes all findings back to the plan for the loop to address.
</objective><tdd_enforcement>
MANDATORY: Load and follow devtools:tdd-typescript skill for ALL implementation.
Skill({ skill: "devtools:tdd-typescript" });
This is NON-NEGOTIABLE. Every story MUST:
No exceptions. No shortcuts. Test fails first, then implement.
</tdd_enforcement>
<workflow>// Force load TDD skill - this is non-negotiable
Skill({ skill: "devtools:tdd-typescript" });
branch=$(git branch --show-current)
if [[ "$branch" == "main" || "$branch" == "master" ]]; then
echo "ERROR: Cannot run crew:work on main/master branch"
echo "Create a feature branch first: /crew:git:branch:new <name>"
exit 1
fi
const slug = "$ARGUMENTS".trim() || inferFromBranch();
const planPath = `.claude/plans/${slug}.yaml`;
const plan = Read({ file_path: planPath });
if (plan.open_questions?.length > 0) {
AskUserQuestion({
questions: [
{
question: `Plan has ${plan.open_questions.length} open questions. Resolve first?`,
header: "Questions",
options: [
{ label: "Yes (Recommended)", description: "Run crew:plan:refine" },
{ label: "Continue anyway", description: "Proceed with unknowns" },
],
multiSelect: false,
},
],
});
}
Skill({
skill: "ralph-loop:ralph-loop",
args: `"Execute plan: ${slug}
## Plan Location
.claude/plans/${slug}.yaml
## TDD ENFORCEMENT (MANDATORY)
**At start of EVERY iteration, load the TDD skill:**
Skill({ skill: 'devtools:tdd-typescript' })
Follow it EXACTLY. No implementation without failing test first. No exceptions.
## Execution Loop
1. **Read Plan**: Load .claude/plans/${slug}.yaml
- Check 'findings' section for ALL issues to fix
- Check story statuses (pending/in_progress/complete)
2. **Fix ALL Findings First**:
- Fix EVERY issue in findings (P0, P1, P2, observations)
- No new features until findings empty
- Mark fixed issues as status: fixed
3. **Execute Stories via TDD**:
- P1 stories first, then P2, then P3
- For EACH story: Skill({ skill: 'devtools:tdd-typescript' }) then follow workflow
- Update story status in plan on completion
4. **Run CI** (after each story):
Skill({ skill: 'crew:work:ci', args: '${slug}' })
- Writes failures to plan 'findings' section
- If failures: fix ALL before proceeding
5. **Browser Testing** (for UI stories):
- Load MCPSearch for claude-in-chrome tools
- Take screenshots to verify UI implementation
- Test user flows described in acceptance criteria
6. **Quality Review** (after each phase):
Skill({ skill: 'crew:work:review', args: '${slug}' })
- Writes ALL findings to plan (P0/P1/P2/Obs)
- Fix ALL findings before proceeding
7. **Commit Progress**:
- Conventional commits per story/fix
- Push regularly
8. **Integration Tests** (final validation):
- Run: bun run test:integration (if script exists)
- If failures: add to findings and fix
- This validates the full application works end-to-end
9. **Feature Video** (for UI/frontend work):
- If plan has frontend/UI stories: Skill({ skill: 'crew:work:feature-video' })
- Records browser walkthrough demonstrating the feature
- Uploads video and adds to PR description
10. **Check Completion**:
- All stories status: complete
- ZERO findings in plan (all fixed)
- CI passing (no failures)
- Integration tests passing (if they exist)
- Coverage meets requirements
- Output: <promise>WORK COMPLETE</promise>
11. **Git Action** (after completion):
- Ask user what to do next with AskUserQuestion
- Options: Create PR (recommended), Commit only, Push only, Stop
## Key Rules
- TDD per devtools:tdd-typescript - NO EXCEPTIONS
- Fix ALL findings before new features
- Read plan at START of each iteration
- Only output completion promise when genuinely done
" --completion-promise "WORK COMPLETE" --max-iterations 50`,
});
AskUserQuestion({
questions: [
{
question: "Work complete. What would you like to do?",
header: "Git action",
options: [
{
label: "Create PR (Recommended)",
description: "Commit, push, and create pull request",
},
{
label: "Commit & Push",
description: "Commit changes and push to origin",
},
{ label: "Commit only", description: "Commit changes without pushing" },
{ label: "Stop", description: "Done for now, no git actions" },
],
multiSelect: false,
},
],
});
// Execute based on answer
if (answer === "Create PR (Recommended)") {
Skill({ skill: "crew:git:pr" });
} else if (answer === "Commit & Push") {
Skill({ skill: "crew:git:commit-and-push" });
} else if (answer === "Commit only") {
Skill({ skill: "crew:git:commit" });
}
// "Stop" = do nothing
</workflow>
<plan_findings_format>
The plan file gets a 'findings' section for the loop to track:
findings:
ci:
- id: CI-001
type: test
status: open
file: src/api/users.ts
line: 45
message: "Expected 200, got 404"
added: "2024-01-09T14:30:00Z"
- id: CI-002
type: lint
status: fixed
file: src/utils/format.ts
line: 12
message: "Unused variable 'temp'"
added: "2024-01-09T14:30:00Z"
fixed: "2024-01-09T14:35:00Z"
review:
- id: REV-001
severity: p0
leg: security
status: open
file: src/auth/login.ts
line: 47
message: "SQL injection via username"
fix: "Use parameterized query"
added: "2024-01-09T14:32:00Z"
</plan_findings_format>
<browser_testing>
For UI stories, use Claude-in-Chrome MCP tools:
// Load browser tools
MCPSearch({ query: "select:mcp__claude-in-chrome__navigate" });
MCPSearch({ query: "select:mcp__claude-in-chrome__browser_take_screenshot" });
// Navigate and verify
mcp__claude-in-chrome__navigate({ url: "http://localhost:3000/feature" });
mcp__claude-in-chrome__browser_take_screenshot({ name: "feature-initial" });
// Test acceptance criteria
mcp__claude-in-chrome__browser_click({ selector: "#submit-button" });
mcp__claude-in-chrome__browser_take_screenshot({ name: "feature-after-submit" });
// Read screenshots to verify
Read({ file_path: "/tmp/feature-after-submit.png" });
</browser_testing>
<success_criteria>
TDD Compliance:
Quality Gates:
Output:
<promise>WORK COMPLETE</promise> output when genuinely done</success_criteria>
<notes>Follow these rules: