@the-bearded-bear/claude-craft 3.0.3-next.d0d2746 → 3.1.0-next.a356bbd
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/Dev/i18n/de/Common/agents/ralph-conductor.md +146 -0
- package/Dev/i18n/de/Common/commands/ralph-run.md +171 -0
- package/Dev/i18n/en/Common/agents/ralph-conductor.md +146 -0
- package/Dev/i18n/en/Common/commands/ralph-run.md +171 -0
- package/Dev/i18n/es/Common/agents/ralph-conductor.md +146 -0
- package/Dev/i18n/es/Common/commands/ralph-run.md +171 -0
- package/Dev/i18n/fr/Common/agents/ralph-conductor.md +146 -0
- package/Dev/i18n/fr/Common/commands/ralph-run.md +171 -0
- package/Dev/i18n/pt/Common/agents/ralph-conductor.md +146 -0
- package/Dev/i18n/pt/Common/commands/ralph-run.md +171 -0
- package/Tools/Ralph/README.md +303 -0
- package/Tools/Ralph/lib/checkpoint.sh +238 -0
- package/Tools/Ralph/lib/circuit-breaker.sh +172 -0
- package/Tools/Ralph/lib/dod-validator.sh +306 -0
- package/Tools/Ralph/lib/loop.sh +232 -0
- package/Tools/Ralph/lib/session.sh +234 -0
- package/Tools/Ralph/ralph.sh +491 -0
- package/Tools/Ralph/templates/ralph.yml.template +178 -0
- package/Tools/i18n/ralph/de.sh +147 -0
- package/Tools/i18n/ralph/en.sh +147 -0
- package/Tools/i18n/ralph/es.sh +147 -0
- package/Tools/i18n/ralph/fr.sh +147 -0
- package/Tools/i18n/ralph/pt.sh +147 -0
- package/cli/index.js +90 -0
- package/package.json +1 -1
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ralph-conductor
|
|
3
|
+
description: Orquestra sessoes de loop continuo Ralph Wiggum com validacao DoD
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Agente Ralph Conductor
|
|
7
|
+
|
|
8
|
+
Voce e um agente especializado para orquestrar sessoes de loop continuo Ralph Wiggum. Seu papel e guiar tarefas atraves da execucao iterativa do Claude ate que os criterios de Definition of Done (DoD) sejam atendidos.
|
|
9
|
+
|
|
10
|
+
## Responsabilidades Principais
|
|
11
|
+
|
|
12
|
+
### 1. Gerenciamento de Sessao
|
|
13
|
+
- Inicializar sessoes Ralph com configuracao apropriada
|
|
14
|
+
- Acompanhar progresso de iteracoes e metricas
|
|
15
|
+
- Gerenciar estado de sessao e recuperacao
|
|
16
|
+
|
|
17
|
+
### 2. Validacao Definition of Done
|
|
18
|
+
- Avaliar criterios DoD em cada iteracao
|
|
19
|
+
- Fornecer feedback sobre criterios aprovados/reprovados
|
|
20
|
+
- Sugerir acoes corretivas quando criterios falham
|
|
21
|
+
|
|
22
|
+
### 3. Monitoramento do Disjuntor
|
|
23
|
+
- Monitorar condicoes de estagnacao (sem progresso)
|
|
24
|
+
- Detectar loops de erro e falhas repetidas
|
|
25
|
+
- Recomendar parar quando apropriado
|
|
26
|
+
|
|
27
|
+
### 4. Avaliacao de Progresso
|
|
28
|
+
- Avaliar se progresso significativo esta sendo feito
|
|
29
|
+
- Identificar quando tarefas estao bloqueadas
|
|
30
|
+
- Sugerir abordagens alternativas quando necessario
|
|
31
|
+
|
|
32
|
+
## Modo de Trabalho
|
|
33
|
+
|
|
34
|
+
Ao orquestrar uma sessao Ralph:
|
|
35
|
+
|
|
36
|
+
1. **Avaliacao Inicial**
|
|
37
|
+
- Entender requisitos da tarefa
|
|
38
|
+
- Identificar criterios de sucesso
|
|
39
|
+
- Configurar checklist DoD apropriada
|
|
40
|
+
|
|
41
|
+
2. **Guia de Iteracao**
|
|
42
|
+
- Fornecer prompts claros e acionaveis
|
|
43
|
+
- Focar em um objetivo por vez
|
|
44
|
+
- Construir incrementalmente sobre progresso anterior
|
|
45
|
+
|
|
46
|
+
3. **Portoes de Qualidade**
|
|
47
|
+
- Verificar que testes passam antes de continuar
|
|
48
|
+
- Checar metricas de qualidade de codigo
|
|
49
|
+
- Validar atualizacoes de documentacao
|
|
50
|
+
|
|
51
|
+
4. **Sinais de Conclusao**
|
|
52
|
+
- Indicar claramente quando DoD e atingido
|
|
53
|
+
- Usar marcador de conclusao: `<promise>COMPLETE</promise>`
|
|
54
|
+
- Resumir o que foi realizado
|
|
55
|
+
|
|
56
|
+
## Tipos de Validadores DoD
|
|
57
|
+
|
|
58
|
+
| Tipo | Quando Usar |
|
|
59
|
+
|------|-------------|
|
|
60
|
+
| `command` | Executar testes, linting, build |
|
|
61
|
+
| `output_contains` | Verificar marcadores de conclusao |
|
|
62
|
+
| `file_changed` | Verificar atualizacoes de documentacao |
|
|
63
|
+
| `hook` | Integrar com portoes de qualidade existentes |
|
|
64
|
+
| `human` | Decisoes criticas que requerem aprovacao |
|
|
65
|
+
|
|
66
|
+
## Boas Praticas
|
|
67
|
+
|
|
68
|
+
### Decomposicao de Tarefas
|
|
69
|
+
Decompor tarefas complexas em passos menores e verificaveis:
|
|
70
|
+
1. Escrever teste que falha primeiro (VERMELHO)
|
|
71
|
+
2. Implementar codigo minimo para passar (VERDE)
|
|
72
|
+
3. Refatorar mantendo testes verdes (REFATORAR)
|
|
73
|
+
4. Atualizar documentacao
|
|
74
|
+
5. Sinalizar conclusao
|
|
75
|
+
|
|
76
|
+
### Indicadores de Progresso
|
|
77
|
+
Incluir marcadores de progresso claros na saida:
|
|
78
|
+
- `[PROGRESSO]` - Fazendo progresso
|
|
79
|
+
- `[BLOQUEADO]` - Obstaculo encontrado
|
|
80
|
+
- `[TESTING]` - Executando verificacao
|
|
81
|
+
- `[COMPLETO]` - Tarefa finalizada
|
|
82
|
+
|
|
83
|
+
### Tratamento de Erros
|
|
84
|
+
Ao encontrar erros:
|
|
85
|
+
1. Descrever o erro claramente
|
|
86
|
+
2. Analisar causa raiz
|
|
87
|
+
3. Propor solucao
|
|
88
|
+
4. Implementar correcao
|
|
89
|
+
5. Verificar resolucao
|
|
90
|
+
|
|
91
|
+
## Exemplo de Fluxo de Sessao
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
Sessao: ralph-1704067200-a1b2
|
|
95
|
+
Tarefa: Implementar autenticacao de usuario
|
|
96
|
+
|
|
97
|
+
Iteracao 1:
|
|
98
|
+
[PROGRESSO] Analisando estrutura de codigo existente
|
|
99
|
+
- Entidade User encontrada
|
|
100
|
+
- Servico de autenticacao precisa ser criado
|
|
101
|
+
- Diretorio de testes pronto
|
|
102
|
+
|
|
103
|
+
Iteracao 2:
|
|
104
|
+
[TESTING] Escrevendo testes de autenticacao
|
|
105
|
+
- Criado AuthServiceTest.php
|
|
106
|
+
- 3 casos de teste: login, logout, validateToken
|
|
107
|
+
- Testes atualmente FALHANDO (esperado)
|
|
108
|
+
|
|
109
|
+
Iteracao 3:
|
|
110
|
+
[PROGRESSO] Implementando AuthService
|
|
111
|
+
- Criado AuthService.php
|
|
112
|
+
- Implementada geracao de token JWT
|
|
113
|
+
- Testes agora PASSANDO
|
|
114
|
+
|
|
115
|
+
Iteracao 4:
|
|
116
|
+
[PROGRESSO] Atualizando documentacao
|
|
117
|
+
- Secao de autenticacao adicionada ao README
|
|
118
|
+
- Endpoints de API documentados
|
|
119
|
+
|
|
120
|
+
<promise>COMPLETE</promise>
|
|
121
|
+
|
|
122
|
+
Resumo:
|
|
123
|
+
- AuthService criado com suporte JWT
|
|
124
|
+
- 3 testes passando
|
|
125
|
+
- Documentacao atualizada
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Pontos de Integracao
|
|
129
|
+
|
|
130
|
+
- Funciona com comando `/common:ralph-run`
|
|
131
|
+
- Integra com hooks existentes (quality-gate.sh)
|
|
132
|
+
- Compativel com workflow `/project:sprint-dev`
|
|
133
|
+
- Usa principios do `@tdd-coach`
|
|
134
|
+
|
|
135
|
+
## Quando Parar
|
|
136
|
+
|
|
137
|
+
Sinalizar conclusao e parar iteracoes quando:
|
|
138
|
+
1. Todos os criterios DoD obrigatorios passam
|
|
139
|
+
2. Objetivos da tarefa completamente atingidos
|
|
140
|
+
3. Testes verificam funcionalidade
|
|
141
|
+
4. Documentacao atualizada
|
|
142
|
+
|
|
143
|
+
NAO continuar se:
|
|
144
|
+
- Limites do disjuntor atingidos
|
|
145
|
+
- Falhas repetidas indicam problema fundamental
|
|
146
|
+
- Intervencao humana necessaria
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Executar Claude em loop continuo ate completar tarefa (Ralph Wiggum)
|
|
3
|
+
argument-hint: <descricao-tarefa> [--auto|--full]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Ralph Run - Loop Continuo de Agente IA
|
|
7
|
+
|
|
8
|
+
Executar Claude em loop continuo ate que a tarefa esteja completa ou os criterios de Definition of Done (DoD) sejam atendidos.
|
|
9
|
+
|
|
10
|
+
## Argumentos
|
|
11
|
+
|
|
12
|
+
**$ARGUMENTS**
|
|
13
|
+
|
|
14
|
+
- `<descricao-tarefa>`: A tarefa para Claude completar
|
|
15
|
+
- `--auto`: Deteccao automatica maxima, perguntas minimas
|
|
16
|
+
- `--full`: Modo completo com todas as verificacoes DoD
|
|
17
|
+
|
|
18
|
+
## Processo
|
|
19
|
+
|
|
20
|
+
### 1. Inicializacao de Sessao
|
|
21
|
+
|
|
22
|
+
1. **Verificar pre-requisitos**:
|
|
23
|
+
- Verificar se Claude esta disponivel
|
|
24
|
+
- Procurar configuracao `ralph.yml`
|
|
25
|
+
- Inicializar diretorio de sessao (`.ralph/`)
|
|
26
|
+
|
|
27
|
+
2. **Carregar configuracao**:
|
|
28
|
+
- Ler `ralph.yml` ou `.claude/ralph.yml`
|
|
29
|
+
- Definir iteracoes max, timeouts, criterios DoD
|
|
30
|
+
|
|
31
|
+
### 2. Loop Principal
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
35
|
+
│ LOOP RALPH │
|
|
36
|
+
│ │
|
|
37
|
+
│ while (iteracoes < max && !DoD_aprovado) { │
|
|
38
|
+
│ 1. Verificar disjuntor │
|
|
39
|
+
│ 2. Invocar Claude com prompt atual │
|
|
40
|
+
│ 3. Processar saida │
|
|
41
|
+
│ 4. Validar Definition of Done │
|
|
42
|
+
│ 5. Criar checkpoint (commit git) │
|
|
43
|
+
│ 6. Se DoD nao atendido, usar resposta como prompt │
|
|
44
|
+
│ } │
|
|
45
|
+
└─────────────────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. Validacao Definition of Done
|
|
49
|
+
|
|
50
|
+
O sistema DoD valida conclusao atraves de multiplos criterios:
|
|
51
|
+
|
|
52
|
+
| Validador | Descricao |
|
|
53
|
+
|-----------|-----------|
|
|
54
|
+
| `command` | Executar comando shell (tests, lint, build) |
|
|
55
|
+
| `output_contains` | Verificar padrao na saida do Claude |
|
|
56
|
+
| `file_changed` | Verificar se arquivos foram modificados |
|
|
57
|
+
| `hook` | Executar hook Claude existente |
|
|
58
|
+
| `human` | Validacao humana interativa |
|
|
59
|
+
|
|
60
|
+
Exemplo DoD em `ralph.yml`:
|
|
61
|
+
|
|
62
|
+
```yaml
|
|
63
|
+
definition_of_done:
|
|
64
|
+
checklist:
|
|
65
|
+
- id: tests
|
|
66
|
+
name: "Todos os testes passam"
|
|
67
|
+
type: command
|
|
68
|
+
command: "docker compose exec app npm test"
|
|
69
|
+
required: true
|
|
70
|
+
|
|
71
|
+
- id: completion
|
|
72
|
+
name: "Claude sinaliza conclusao"
|
|
73
|
+
type: output_contains
|
|
74
|
+
pattern: "<promise>COMPLETE</promise>"
|
|
75
|
+
required: true
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 4. Disjuntor (Circuit Breaker)
|
|
79
|
+
|
|
80
|
+
Mecanismo de seguranca para prevenir loops infinitos:
|
|
81
|
+
|
|
82
|
+
| Gatilho | Limite | Acao |
|
|
83
|
+
|---------|--------|------|
|
|
84
|
+
| Sem alteracoes de arquivos | 3 iteracoes | Parar |
|
|
85
|
+
| Erros repetidos | 5 iteracoes | Parar |
|
|
86
|
+
| Declinio de saida | 70% | Parar |
|
|
87
|
+
| Max iteracoes | 25 (padrao) | Parar |
|
|
88
|
+
|
|
89
|
+
### 5. Checkpointing
|
|
90
|
+
|
|
91
|
+
Checkpoints Git sao criados apos cada iteracao para:
|
|
92
|
+
- **Recuperacao**: Restaurar estado anterior se necessario
|
|
93
|
+
- **Historico**: Acompanhar progresso atraves das iteracoes
|
|
94
|
+
- **Revisao**: Inspecionar o que mudou em cada passo
|
|
95
|
+
|
|
96
|
+
## Saida
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
╔════════════════════════════════════════════════════════════╗
|
|
100
|
+
║ 🔁 Ralph Wiggum - Loop Continuo de Agente IA ║
|
|
101
|
+
╚════════════════════════════════════════════════════════════╝
|
|
102
|
+
|
|
103
|
+
✓ Sessao criada: ralph-1704067200-a1b2
|
|
104
|
+
|
|
105
|
+
ℹ Iniciando loop Ralph...
|
|
106
|
+
|
|
107
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
108
|
+
Iteracao 1 de 25
|
|
109
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
110
|
+
|
|
111
|
+
ℹ Invocando Claude...
|
|
112
|
+
ℹ Verificando criterios DoD...
|
|
113
|
+
✓ [tests] Todos os testes passam - OK
|
|
114
|
+
✓ [lint] Sem erros lint - OK
|
|
115
|
+
✓ [completion] Claude sinaliza conclusao - OK
|
|
116
|
+
|
|
117
|
+
Todos os criterios obrigatorios aprovados!
|
|
118
|
+
|
|
119
|
+
✓ DoD APROVADO
|
|
120
|
+
|
|
121
|
+
╔════════════════════════════════════════════════════════════╗
|
|
122
|
+
║ 📊 Resumo da Sessao ║
|
|
123
|
+
╚════════════════════════════════════════════════════════════╝
|
|
124
|
+
|
|
125
|
+
ID da sessao: ralph-1704067200-a1b2
|
|
126
|
+
Total de iteracoes: 3
|
|
127
|
+
Duracao: 45s
|
|
128
|
+
Status DoD: APROVADO
|
|
129
|
+
Motivo de saida: dod_complete
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Configuracao
|
|
133
|
+
|
|
134
|
+
Criar `ralph.yml` na raiz do projeto:
|
|
135
|
+
|
|
136
|
+
```yaml
|
|
137
|
+
version: "1.0"
|
|
138
|
+
|
|
139
|
+
session:
|
|
140
|
+
max_iterations: 25
|
|
141
|
+
timeout: 600000
|
|
142
|
+
|
|
143
|
+
circuit_breaker:
|
|
144
|
+
enabled: true
|
|
145
|
+
no_file_changes_threshold: 3
|
|
146
|
+
|
|
147
|
+
definition_of_done:
|
|
148
|
+
checklist:
|
|
149
|
+
- id: tests
|
|
150
|
+
type: command
|
|
151
|
+
command: "npm test"
|
|
152
|
+
required: true
|
|
153
|
+
- id: completion
|
|
154
|
+
type: output_contains
|
|
155
|
+
pattern: "<promise>COMPLETE</promise>"
|
|
156
|
+
required: true
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Boas Praticas
|
|
160
|
+
|
|
161
|
+
1. **Descricao clara**: Fornecer tarefas especificas e acionaveis
|
|
162
|
+
2. **Configurar DoD**: Definir criterios de conclusao em `ralph.yml`
|
|
163
|
+
3. **Usar TDD**: Escrever testes primeiro, deixar Ralph implementar
|
|
164
|
+
4. **Monitorar progresso**: Observar saidas de iteracao
|
|
165
|
+
5. **Limites razoaveis**: Ajustar max_iterations conforme complexidade
|
|
166
|
+
|
|
167
|
+
## Ver tambem
|
|
168
|
+
|
|
169
|
+
- `@ralph-conductor` - Agente para orquestracao Ralph
|
|
170
|
+
- `/common:fix-bug-tdd` - Correcao de bugs com TDD
|
|
171
|
+
- `/project:sprint-dev` - Desenvolvimento de sprint com TDD
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# Ralph Wiggum - Continuous AI Agent Loop
|
|
2
|
+
|
|
3
|
+
Ralph Wiggum is a methodology and tool for running Claude in a continuous loop until a task is complete. It provides structured completion detection through Definition of Done (DoD) validation, safety mechanisms via circuit breakers, and progress tracking through git checkpoints.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
9
|
+
│ RALPH LOOP │
|
|
10
|
+
│ │
|
|
11
|
+
│ while (iterations < max && !complete) { │
|
|
12
|
+
│ response = claude("--continue", session_id, prompt) │
|
|
13
|
+
│ complete = checkDoD(response) │
|
|
14
|
+
│ if (circuitBreaker.triggered()) break │
|
|
15
|
+
│ createCheckpoint(iteration) │
|
|
16
|
+
│ prompt = response // feedback loop │
|
|
17
|
+
│ } │
|
|
18
|
+
└─────────────────────────────────────────────────────────────┘
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
### Via CLI
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
# Basic usage
|
|
27
|
+
npx @the-bearded-bear/claude-craft ralph "Implement user authentication"
|
|
28
|
+
|
|
29
|
+
# With configuration
|
|
30
|
+
npx @the-bearded-bear/claude-craft ralph --config=ralph.yml "Fix the login bug"
|
|
31
|
+
|
|
32
|
+
# Resume session
|
|
33
|
+
npx @the-bearded-bear/claude-craft ralph --continue=ralph-1704067200-a1b2
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Via Command in Claude Code
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
/common:ralph-run "Implement user authentication"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Direct Script
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
./Tools/Ralph/ralph.sh "Implement user authentication"
|
|
46
|
+
./Tools/Ralph/ralph.sh --lang=fr --verbose "Corriger le bug de connexion"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Configuration
|
|
50
|
+
|
|
51
|
+
Create `ralph.yml` in your project root or `.claude/ralph.yml`:
|
|
52
|
+
|
|
53
|
+
```yaml
|
|
54
|
+
version: "1.0"
|
|
55
|
+
|
|
56
|
+
session:
|
|
57
|
+
max_iterations: 25
|
|
58
|
+
timeout: 600000 # 10 minutes per iteration
|
|
59
|
+
delay_between_iterations: 1000
|
|
60
|
+
|
|
61
|
+
circuit_breaker:
|
|
62
|
+
enabled: true
|
|
63
|
+
no_file_changes_threshold: 3
|
|
64
|
+
repeated_error_threshold: 5
|
|
65
|
+
output_decline_threshold: 70
|
|
66
|
+
|
|
67
|
+
checkpointing:
|
|
68
|
+
enabled: true
|
|
69
|
+
async: true
|
|
70
|
+
branch_prefix: "ralph/"
|
|
71
|
+
|
|
72
|
+
definition_of_done:
|
|
73
|
+
checklist:
|
|
74
|
+
- id: tests
|
|
75
|
+
name: "All tests pass"
|
|
76
|
+
type: command
|
|
77
|
+
command: "docker compose exec app npm test"
|
|
78
|
+
required: true
|
|
79
|
+
|
|
80
|
+
- id: lint
|
|
81
|
+
name: "No lint errors"
|
|
82
|
+
type: command
|
|
83
|
+
command: "docker compose exec app npm run lint"
|
|
84
|
+
required: true
|
|
85
|
+
|
|
86
|
+
- id: completion
|
|
87
|
+
name: "Claude signals completion"
|
|
88
|
+
type: output_contains
|
|
89
|
+
pattern: "<promise>COMPLETE</promise>"
|
|
90
|
+
required: true
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Definition of Done (DoD)
|
|
94
|
+
|
|
95
|
+
The key improvement over simple completion markers. DoD validates task completion through multiple criteria:
|
|
96
|
+
|
|
97
|
+
### Validator Types
|
|
98
|
+
|
|
99
|
+
| Type | Description | Example |
|
|
100
|
+
|------|-------------|---------|
|
|
101
|
+
| `command` | Run shell command, check exit code | `npm test` |
|
|
102
|
+
| `output_contains` | Check Claude output for pattern | `<promise>COMPLETE</promise>` |
|
|
103
|
+
| `file_changed` | Check if files matching pattern changed | `*.md` |
|
|
104
|
+
| `hook` | Run existing Claude hook script | `quality-gate.sh` |
|
|
105
|
+
| `human` | Prompt user for confirmation | Interactive gate |
|
|
106
|
+
|
|
107
|
+
### Example Checklist
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
definition_of_done:
|
|
111
|
+
checklist:
|
|
112
|
+
# Automated tests
|
|
113
|
+
- id: tests
|
|
114
|
+
name: "All tests pass"
|
|
115
|
+
type: command
|
|
116
|
+
command: "docker compose exec app npm test"
|
|
117
|
+
required: true
|
|
118
|
+
|
|
119
|
+
# Code quality
|
|
120
|
+
- id: lint
|
|
121
|
+
name: "No lint errors"
|
|
122
|
+
type: command
|
|
123
|
+
command: "docker compose exec app npm run lint"
|
|
124
|
+
required: true
|
|
125
|
+
|
|
126
|
+
# Completion signal
|
|
127
|
+
- id: completion
|
|
128
|
+
name: "Claude signals completion"
|
|
129
|
+
type: output_contains
|
|
130
|
+
pattern: "<promise>COMPLETE</promise>"
|
|
131
|
+
required: true
|
|
132
|
+
|
|
133
|
+
# Integration with existing hooks
|
|
134
|
+
- id: quality_gate
|
|
135
|
+
name: "Quality gate passes"
|
|
136
|
+
type: hook
|
|
137
|
+
script: ".claude/hooks/quality-gate.sh"
|
|
138
|
+
required: true
|
|
139
|
+
|
|
140
|
+
# Documentation (optional)
|
|
141
|
+
- id: docs
|
|
142
|
+
name: "Documentation updated"
|
|
143
|
+
type: file_changed
|
|
144
|
+
pattern: "*.md"
|
|
145
|
+
required: false
|
|
146
|
+
|
|
147
|
+
# Human approval (optional)
|
|
148
|
+
- id: review
|
|
149
|
+
name: "Manual review approved"
|
|
150
|
+
type: human
|
|
151
|
+
prompt: "Does the implementation look correct? (y/n):"
|
|
152
|
+
required: false
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Circuit Breaker
|
|
156
|
+
|
|
157
|
+
Safety mechanism to prevent infinite loops:
|
|
158
|
+
|
|
159
|
+
| Trigger | Default Threshold | Description |
|
|
160
|
+
|---------|-------------------|-------------|
|
|
161
|
+
| No file changes | 3 iterations | Stops if no files modified |
|
|
162
|
+
| Repeated errors | 5 iterations | Stops on error loops |
|
|
163
|
+
| Output decline | 70% | Stops if output shrinks significantly |
|
|
164
|
+
| Max iterations | 25 | Hard limit |
|
|
165
|
+
|
|
166
|
+
## Git Checkpointing
|
|
167
|
+
|
|
168
|
+
Automatic git commits after each iteration:
|
|
169
|
+
|
|
170
|
+
- **Recovery**: Restore to previous state if needed
|
|
171
|
+
- **History**: Track progress through iterations
|
|
172
|
+
- **Review**: Inspect what changed at each step
|
|
173
|
+
|
|
174
|
+
Configuration:
|
|
175
|
+
|
|
176
|
+
```yaml
|
|
177
|
+
checkpointing:
|
|
178
|
+
enabled: true
|
|
179
|
+
async: true # Non-blocking
|
|
180
|
+
branch_prefix: "ralph/"
|
|
181
|
+
commit_message_template: "checkpoint: Ralph iteration {iteration}"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## File Structure
|
|
185
|
+
|
|
186
|
+
```
|
|
187
|
+
Tools/Ralph/
|
|
188
|
+
├── ralph.sh # Main entry point
|
|
189
|
+
├── lib/
|
|
190
|
+
│ ├── session.sh # Session management
|
|
191
|
+
│ ├── loop.sh # Core iteration loop
|
|
192
|
+
│ ├── dod-validator.sh # DoD validation
|
|
193
|
+
│ ├── circuit-breaker.sh # Safety mechanism
|
|
194
|
+
│ └── checkpoint.sh # Git checkpointing
|
|
195
|
+
├── templates/
|
|
196
|
+
│ └── ralph.yml.template # Default configuration
|
|
197
|
+
└── README.md # This file
|
|
198
|
+
|
|
199
|
+
Tools/i18n/ralph/
|
|
200
|
+
├── en.sh # English messages
|
|
201
|
+
├── fr.sh # French messages
|
|
202
|
+
├── es.sh # Spanish messages
|
|
203
|
+
├── de.sh # German messages
|
|
204
|
+
└── pt.sh # Portuguese messages
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## CLI Options
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
ralph.sh [options] <prompt>
|
|
211
|
+
|
|
212
|
+
Options:
|
|
213
|
+
--config=<file> Path to ralph.yml configuration
|
|
214
|
+
--continue=<id> Resume existing session
|
|
215
|
+
--max-iterations=<n> Maximum iterations (default: 25)
|
|
216
|
+
--timeout=<ms> Timeout per iteration (default: 600000)
|
|
217
|
+
--verbose Enable verbose output
|
|
218
|
+
--dry-run Show what would be done without executing
|
|
219
|
+
--lang=<code> Language (en, fr, es, de, pt)
|
|
220
|
+
--help Show help message
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Integration
|
|
224
|
+
|
|
225
|
+
### With Existing Hooks
|
|
226
|
+
|
|
227
|
+
Ralph can leverage existing Claude hooks:
|
|
228
|
+
|
|
229
|
+
```yaml
|
|
230
|
+
definition_of_done:
|
|
231
|
+
checklist:
|
|
232
|
+
- id: quality_gate
|
|
233
|
+
type: hook
|
|
234
|
+
script: ".claude/hooks/quality-gate.sh"
|
|
235
|
+
required: true
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### With Sprint Development
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# In sprint workflow
|
|
242
|
+
/project:sprint-dev 1
|
|
243
|
+
# Ralph handles each task until DoD passes
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### With TDD Coach
|
|
247
|
+
|
|
248
|
+
Ralph follows TDD principles:
|
|
249
|
+
1. Write failing test (RED)
|
|
250
|
+
2. Implement minimum code to pass (GREEN)
|
|
251
|
+
3. Refactor while keeping tests green (REFACTOR)
|
|
252
|
+
|
|
253
|
+
## Session Files
|
|
254
|
+
|
|
255
|
+
Ralph creates a `.ralph/` directory in your project:
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
.ralph/
|
|
259
|
+
├── sessions/
|
|
260
|
+
│ └── ralph-1704067200-a1b2/
|
|
261
|
+
│ ├── state.json # Session state
|
|
262
|
+
│ ├── metrics.json # Iteration metrics
|
|
263
|
+
│ ├── session.log # Execution log
|
|
264
|
+
│ └── last_output.txt # Last Claude response
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
## Best Practices
|
|
268
|
+
|
|
269
|
+
1. **Clear task description**: Provide specific, actionable tasks
|
|
270
|
+
2. **Configure DoD**: Define completion criteria in `ralph.yml`
|
|
271
|
+
3. **Use TDD**: Write tests first, let Ralph implement
|
|
272
|
+
4. **Monitor progress**: Watch iteration output for issues
|
|
273
|
+
5. **Set reasonable limits**: Adjust max_iterations for task complexity
|
|
274
|
+
6. **Use Docker**: Run commands in Docker for consistency
|
|
275
|
+
|
|
276
|
+
## Troubleshooting
|
|
277
|
+
|
|
278
|
+
### Ralph stops immediately
|
|
279
|
+
- Check if prompt is provided
|
|
280
|
+
- Verify `ralph.yml` is valid YAML
|
|
281
|
+
|
|
282
|
+
### Circuit breaker triggers too early
|
|
283
|
+
- Increase thresholds in configuration
|
|
284
|
+
- Check if task is making actual progress
|
|
285
|
+
|
|
286
|
+
### DoD never passes
|
|
287
|
+
- Verify commands work manually
|
|
288
|
+
- Check required vs optional criteria
|
|
289
|
+
- Ensure completion marker is output by Claude
|
|
290
|
+
|
|
291
|
+
## Related
|
|
292
|
+
|
|
293
|
+
- `/common:ralph-run` - Command to start Ralph from Claude Code
|
|
294
|
+
- `@ralph-conductor` - Agent for Ralph orchestration
|
|
295
|
+
- `/common:fix-bug-tdd` - TDD-based bug fixing
|
|
296
|
+
- `/project:sprint-dev` - Sprint development with TDD
|
|
297
|
+
|
|
298
|
+
## Credits
|
|
299
|
+
|
|
300
|
+
Inspired by:
|
|
301
|
+
- [anthropics/claude-code/plugins/ralph-wiggum](https://github.com/anthropics/claude-code)
|
|
302
|
+
- [frankbria/ralph-claude-code](https://github.com/frankbria/ralph-claude-code)
|
|
303
|
+
- [mikeyobrien/ralph-orchestrator](https://github.com/mikeyobrien/ralph-orchestrator)
|