ralph-start

ralph-start is a command for Claude Code from Peaky8linders/claude-cortex. It costs 31 tokens per session (1,009 once invoked), scanned B, original, MIT.

A command that starts a repeated work loop for Claude. When Claude tries to finish, a stop hook sends the task back for another iteration, with quality checks and optional limits.

In plain words
What is it for?
Use it for autonomous implementation, testing, or repair work, optionally limiting iterations or confining edits to a directory.
Why use it?
It helps continue long-running tasks without manually restarting the agent after each attempt.

Command for Claude Code

Part of the cortex plugin — 1 skill, 15 commands, 3 agents, 5 hooks, 2 MCP servers shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/peaky8linders/claude-cortex/ralph-start
Clone the repo
git clone --depth 1 https://github.com/Peaky8linders/claude-cortex

Made for: Claude Code.

Or install cortex, the plugin that ships this one along with the rest of its 1 skill, 15 commands, 3 agents, 5 hooks, 2 MCP servers.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ralph-start

README.md
[![agentmods](https://agentmods.dev/badge/commands/peaky8linders/claude-cortex/ralph-start.svg)](https://agentmods.dev/commands/peaky8linders/claude-cortex/ralph-start)
Your own site
<a href="https://agentmods.dev/commands/peaky8linders/claude-cortex/ralph-start"><img src="https://agentmods.dev/badge/commands/peaky8linders/claude-cortex/ralph-start.svg" alt="Measured on agentmods" height="20"></a>
Per session 31 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,009 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00031 $0.01009
Opus 5 $0.00015 $0.00504
Sonnet 5 $0.00006 $0.00202
Haiku 4.5 $0.00003 $0.00101

Measured 4d ago against content hash 698cba3fb8fd, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

ralph-start scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

cat > ~/.claude/knowledge/.ralph-active << 'RALPH'
.claude/commands/ralph-start.md · 106 lines

How it starts

The opening of the file, as written. The whole thing — 106 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/ralph-start — Activate Autonomous Loop

You are activating a Ralph Wiggum autonomous loop. When Claude tries to exit, the Stop hook will re-feed the task prompt, creating a continuous work loop that persists across iterations.

Input

The user provides:

  1. Task prompt (required): What to work on autonomously
  2. --max-iterations N (optional): Maximum loop iterations (default: 50)
  3. --scope DIR (optional): Directory to freeze edits to
  4. --reset-strategy compact|reset (optional): Context management strategy (default: compact)
    • compact: Standard — carry forward context with compaction recovery
    • reset: Full context reset each iteration — clean slate with structured handoff artifact. Better for long-running tasks (10+ iterations) where context anxiety degrades quality.

Activation Protocol

Step 1: Parse Arguments

Extract:

  • prompt: The task description (everything that isn't a flag)
  • max_iterations: From --max-iterations N or default 50
  • scope: From --scope DIR or empty
  • reset_strategy: From --reset-strategy or default "compact"

Step 2: Create Loop File

Write the loop configuration to ~/.claude/knowledge/.ralph-active:

cat > ~/.claude/knowledge/.ralph-active << 'RALPH'
{
  "prompt": "THE_TASK_PROMPT",
  "max_iterations": 50,
  "iteration": 0,
  "scope": "DIRECTORY_OR_EMPTY",
  "started_at": "ISO_TIMESTAMP",
  "started_by": "session"
}
RALPH

Use python3 with json.dumps for safe serialization (handles quotes, backslashes, newlines):

python3 << 'PYEOF'
import json, datetime, os
data = {
    "prompt": "THE_PROMPT",
    "max_iterations": MAX_ITER,
    "iteration": 0,
    "scope": "SCOPE_OR_EMPTY",
    "reset_strategy": "RESET_STRATEGY",
    "started_at": datetime.datetime.now().isoformat()
}
ralph_path = os.path.join(os.environ.get("HOME", os.path.expanduser("~")), ".claude", "knowledge", ".ralph-active")
with open(ralph_path, "w") as f:
    json.dump(data, f, indent=2)
PYEOF

Replace THE_PROMPT, MAX_ITER, SCOPE_OR_EMPTY, and RESET_STRATEGY with the actual values. Use a heredoc (<< 'PYEOF') so that the prompt text is never interpolated by the shell — only parsed by Python's JSON serializer.

Read the full file on GitHub · 106 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 106 lines · 31 tokens per session scan B 698cba3fb8fd

Subscribe to this mod's changes

ralph-start is a command published in the GitHub repository Peaky8linders/claude-cortex (11 stars, last pushed 2mo ago), licensed MIT. It adds 31 tokens to every session and 1,009 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.