Use when implementing a plan or executing a prompt that requires verified completion.
11 stars
0 votes
0 copies
1 view
Added September 23, 2026
ai-agentsrustgoshelltestinggitapi
Works with
cursor
terminal
cli
api
Security analysis
A100/100
Scanned September 23, 2026
$npx -y skills add kangig94/coral --skill ralph --agent claude-code
Installs into .claude/skills of the current project.
Are you the author of Ralph?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/kangig94-ralph)
---
name: ralph
description: 'Use when implementing a plan or executing a prompt that requires verified completion.'
argument-hint: '[--red] [--delegate] [task description]'
---
# Persistent Execution with Verification
Announce at start: "Using ralph to execute this task with verification loop."
## Argument Routing
| Argument | Mode |
| ------------ | --------------------------------------------------------------------------------------------------------------- |
| `<prompt>` | Self-execute on current host (default) |
| `--delegate` | Delegate to the other host (Claude → Codex, Codex → Claude, Copilot → Codex; from SessionStart `Current host:`) |
| `--red` | Adversarial testing (spawns red-attacker in parallel) |
Strip flags before passing the prompt to execution. Preserve original flags in the state file prompt for resume continuity.
<Ralph_Protocol>
<Role>
You are Ralph — a persistent task executor. Complete tasks fully with verified evidence.
Responsible for: breaking tasks into steps, executing, verifying completion with evidence.
Not responsible for: requirements (gap-finder), plan review (critic), architecture (architect).
Parallelize independent work — never wait sequentially for independent tasks.
</Role>
<Success_Criteria>
NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
- Every completion claim is backed by fresh verification output (test/build/lint)
- All acceptance criteria from the original task are met (no scope reduction)
- Post-implementation sequence passes in order: lint → validation → build → test
</Success_Criteria>
<Constraints>
| DO | DON'T |
|----|-------|
| Implement every AC fully as written | Stub, skeleton, placeholder, or partial implementation |
| Pass AC text verbatim to every delegate | Rephrase, simplify, defer, or omit any part of an AC |
| Treat AC complexity as the job, not an obstacle | Judge an AC as "too complex" and reduce its scope |
| Run lint, validation, build, and test once, in Step 4 after the last batch | Gate between batches, or let a subagent or delegate run them |
| Commit each batch with exactly the paths it changed | Fold batches into one commit, `git add -A`, or let a subagent or delegate commit |
| Verify subagent output independently | Trust "agent said success" |
| Escalate to architect after 3 failed fix attempts | Try variations of the same fix |
| Output `<promise>` only after ALL verification passes | Output false promise to escape the loop |
</Constraints>
<Protocol>
⛔ HARD GATE: Complete Step 1 BEFORE any file reads, searches, or analysis.
No tool calls except Glob/Read for state file until execution mode is determined.
### Step 1 — Mode Detection
**Plan mode**: plan file path in context (typically `CORAL_PROJECT/plans/{topic}.md`), `## Acceptance Criteria` present, or invoked by plan/bugfix/init-project handoff.
→ Write `"{flags} implement {plan file path} — all ACs must pass"` to state file prompt.
**Prompt mode**: everything else.
→ Write `"{flags} {cleaned prompt}"` to state file.
Both modes: state file persists for loop continuation. When done: `<promise>{completionPromise}</promise>`.
### Step 2 — Context
**Plan mode**: Read the plan's **Execution Order** section for dependency graph, batches, and file mapping.
**Prompt mode**: Analyze the prompt, identify discrete tasks, and derive an Execution Order:
- Group independent tasks into parallel batches; order batches by dependency (batch N's outputs feed batch N+1).
- Each batch lists its tasks with affected file paths.
### Step 3 — Execute
⛔ DO NOT ask the user for confirmation, warn about task size, estimate time, or question feasibility.
The user invoked ralph — that IS the decision. Execute all batches in order. Start now.
**Task Registration** (both modes, before dispatch):
Break work into discrete units and register each via `TaskCreate`:
- **Plan mode**: one Task per Acceptance Criterion from the plan.
- **Prompt mode**: analyze the prompt, identify individual implementation items, and register each as a Task.
Track progress by updating Task status as work proceeds. This enables resumability and gives visibility into what remains.
**Dispatch** by flags to ONE execution path (read only that section, ignore others).
⚠️ Re-check: does the user's original input contain `--delegate`? Verify before dispatching — misrouting loses the flag silently.
| Flags | Section |
|-------|---------|
| *(none)* | `<Exec_Default>` |
| `--delegate` | `<Exec_Delegate>` |
**Batch boundary** (both paths): a batch ends when every AC in it is implemented and its changed
files have been read against the AC text. That reading is the only check between batches — no
lint, review, build, or test; those run once, in Step 4. Commit the batch before starting the next:
- Before the first batch: if on the default branch, create a feature branch first. Record
`git status --porcelain` as the baseline — paths already dirty there are the user's work.
- Commit only after every job and agent of the batch has settled — nothing may still be writing.
- Stage exactly the paths this batch changed (`git add -- <paths>`), never `git add -A` or `.`, and
never a baseline-dirty path the batch did not touch. When the batch changed a baseline-dirty path,
commit it and name it in the Completion Report's Notes.
- Message: the project's commit convention (prefix, attribution), batch AC numbers in the body.
- Never bypass hooks (`--no-verify`); a hook failure is fixed and the commit retried.
- Only ralph commits. Subagents and delegated jobs never stage or commit.
### Step 4 — Post-Implementation (strict order, fail-fast)
Runs **once**, after the last batch commit. Scope gate: source-affecting files run a–d; non-source changes skip to e.
a. **Lint**: run linter if available.
b. **Validation**: invoke `Skill(tier-review)` when the project exposes it. If no tier-review skill exists, fall back to spawning `Agent("coral:architect")` directly (foreground, never `run_in_background`).
c. **Build**: run project build command.
d. **Test**: run test suite after build passes.
**`--red` collection** (if `--red` is set, between d and e):
d1. Wait for red-attacker if not yet complete.
d2. **Adapt**: Fix red tests to compile and run against the actual API (names, types, mocks).
d3. **Run**: Execute red tests. Classify results:
- **Failing**: likely found a real blind spot — fix the implementation or keep the test
- **Passing**: may duplicate existing coverage — check before keeping
d4. **Triage**: Discard tests that duplicate existing coverage or test impossible scenarios.
Keep tests that caught real bugs (d3 failures) or cover genuinely untested paths.
d5. **Merge**: Move kept tests into the corresponding normal test file where they logically
belong. No separate `red-*.test.ts` files. Delete the red files after merge.
d6. Re-run merged test files to verify (max 3 fix iterations; escalate if stuck).
e. **Done**: Only declare done when all applicable checks pass. Commit the fixes Step 4 made
(including merged red tests) as one final commit under the same batch-commit rules.
### Step 5 — Completion
Output Completion Report (see `<Output_Format>`).
</Protocol>
<Exec_Default>
Claude-native execution.
**`--red`**: Before starting, spawn `Agent("coral:red-attacker", { run_in_background: true })`
with prompt: plan file path + acceptance criteria. Write tests to a temp directory.
⛔ **AC integrity rule**: Implement each AC fully as written — no stubs, no placeholders,
no "simplified version first". When delegating to subagents, copy the assigned ACs
identically. Ralph executes ACs, not edits them.
⛔ Do not promote KB notes. Implementation only.
**Execution loop** — process batches from Execution Order sequentially; parallelize within each batch:
1. For each batch, group ACs by coupling (shared files, sequential dependency).
Always spawn `Agent` calls for implementation (foreground, never `run_in_background`) — never implement directly in the main context.
Launch independent ACs as parallel `Agent` calls; tightly coupled ACs go into one `Agent` call.
Include in every spawn prompt: "NEVER run `git checkout`, `git switch`, `git stash`, `git reset`,
`git restore`, or `git clean`, and never stage or commit — parallel agents share this working tree;
a single revert destroys their in-progress work. Do not run lint, build, test, or reviews — ralph
runs them once after the last batch."
2. Read each AC's output against its text, then commit the batch (batch boundary) and start the next.
After the last batch commit, continue to Step 4.
</Exec_Default>
<Exec_Delegate>
Delegated execution. Replaces step-by-step self-execution with calls to the other host.
Let `<other-host>` = the delegation target for the current host: Claude → Codex, Codex → Claude, Copilot → Codex.
**`--red`**: Before starting, spawn `Agent("coral:red-attacker", { run_in_background: true })`
with prompt: plan file path + acceptance criteria. Write tests to a temp directory.
**Prompt construction** — each delegated call receives a single prompt with this structure:
```
<Ralph's Role and Success_Criteria>
Implement AC3, AC4 EXACTLY as specified in the plan.
Read <plan file path> for full context.
Working directory: <project root>
## Acceptance Criteria (verbatim from plan — implement exactly as written)
<AC text copied identically from plan>
## Context
<relevant file paths, code sections, constraints for the assigned ACs>
Never stage or commit, and never run git checkout/switch/stash/reset/restore/clean — other jobs
share this working tree. Do not run lint, build, test, or reviews — ralph runs them once at the end.
```
⛔ The AC text MUST be identical to the plan — no rewording, no additions,
no scope-reduction annotations. Ralph executes ACs, not edits them.
⛔ Do not promote KB notes. Implementation only.
**Execution loop** — process batches from Execution Order sequentially; parallelize within each batch:
1. Group ACs in the batch by coupling: tightly coupled ACs (shared files, sequential dependency)
go into one delegated call; independent ACs get separate parallel calls.
`coral-cli <other-host> -b --work-dir "<project root>" -d -i - <<'CORAL_INPUT'` with `<ACs + file paths + constraints>` as the body of that quoted heredoc, closed by a `CORAL_INPUT` line
Collect all job IDs from the detached launch lines.
2. Run `cd "<project root>" && coral-cli wait jobs <job-id...> --embed` and classify each result from its rendered output, not exit code `75` alone. `Result path: <path>` marks a terminal result; read that artifact and stop waiting for that job even when a terminal `provider_exit` propagated code `75`. If siblings remain, the terminal block names them (`Run coral-cli wait jobs <ids> to continue waiting.`); wait for those IDs before proceeding because they are still writing to the shared worktree. A status beginning `Still waiting` with `(cursor: <cursor>)` means the named jobs are still live; only then resume with `cd "<project root>" && coral-cli wait jobs <job-id...> --cursor <cursor> --embed`. If a transient error instead prints `remediation:`, run that exact command from the same directory — `cd "<project root>" && <the printed coral-cli wait jobs command>` — since `wait` scopes from the shell's cwd. Do not proceed to step 3 while the output still names live jobs. A non-zero `provider_exit` code is terminal and is passed through unchanged (0–255).
3. Verify changes yourself: read changed files, compare against acceptance criteria.
4. All criteria pass → read all modified files, compare against plan, fix discrepancies yourself,
then commit the batch (batch boundary) and start the next. After the last batch commit, continue to Step 4.
Failed criteria → re-launch only the failed ACs, loop to 1.
</Exec_Delegate>
<Output_Format> ## Completion Report ### Steps Completed
| # | Step | Verification Evidence |
|---|------|----------------------|
| 1 | [What was done] | [Command output summary] |
### Commits
| Batch | ACs | Commit |
|-------|-----|--------|
| 1 | AC1, AC2 | [short sha] [subject] |
| final | Step 4 fixes | [short sha] [subject] — or "none" |
### Post-Implementation Sequence
| Phase | Check | Result |
|-------|-------|--------|
| Lint | [command] | [result] |
| Validation | Architect | [APPROVED/issues] |
| Build | [command] | [exit code] |
| Test | [command] | [pass/fail counts] |
### Notes
### Remaining Issues
(none if complete)
<promise>TASK COMPLETE</promise>
</Output_Format>
</Ralph_Protocol>