Skip to main content

Agent pipes and loops for Claude Code

Project description

ralphkit

ralphkit

Agent pipes and loops for Claude Code. Inspired by the ralph loop.

  • Loop — plan-driven iteration. Creates a structured plan, then iterates one item at a time until all are complete.
  • Pipe — linear sequence. Each step runs once, passing context forward via handoff files.

Install

pip install ralphkit

With uv:

uv tool install ralphkit

Quick Start

Write a task file that clearly specifies what needs to be done, then run it:

ralphkit build feature.md       # plan-driven loop: plan → build → review
ralphkit fix bug.md             # diagnose → fix → verify
ralphkit research question.md   # explore → synthesize → report
ralphkit plan feature.md        # analyze → design document
ralphkit big-swing epic.md      # research → plan → build → review → fix → verify

Task files should contain a well-specified description of the work to be done: the goal, relevant context, constraints, and acceptance criteria. The built-in workflows own the process. Your task file should describe the work itself, not tell ralphkit how to plan, diagnose, review, or verify it.

Starter task-file templates live in templates/tasks/. Copy the one that matches the command you want to run and fill in the sections.

For custom workflows, use the generic primitives with a YAML config:

ralphkit pipe task.md --config pipe.yaml
ralphkit loop task.md --config loop.yaml

Use ralphkit <command> --help to see all available options.

Task Files

Each built-in command expects a different kind of brief, but they all follow the same rule: describe the task, not the workflow. ralphkit already knows the flow for build, fix, research, plan, and big-swing.

Use the starter templates in templates/tasks/:

In practice, a good task file usually covers:

  • Goal or problem statement
  • Relevant context and existing behavior
  • Constraints and non-goals
  • Acceptance criteria
  • Deliverables or output filename, if you care about a specific artifact name

How It Works

Loop

   Setup             Planning                 Loop (iterate)               Cleanup
┌──────────┐    ┌─────────────────┐    ┌──────────────────────────┐    ┌──────────────┐
│ step 1   │    │ planner         │    │ Read tickets.json        │    │ step 1       │
│ step 2   │    │ → tickets.json  │    │ Work on next item        │    │ ...          │
│ ...      │    └─────────────────┘    │ Update tickets.json      │    └──────────────┘
└──────────┘                           │ All done? → COMPLETE     │
                                       │ More items? → loop       │
                                       └──────────────────────────┘

The planner agent reads the task and breaks it into discrete items in tickets.json. Each loop iteration works on exactly one item, marks it done, and appends learnings to progress.md. Cleanup runs after the loop exits regardless of outcome.

Pipe

┌────────┐    ┌────────┐    ┌────────┐
│ step 1 │───>│ step 2 │───>│ step 3 │──> done
└────────┘    └────────┘    └────────┘
     │             │             │
     └── handoff ──┘── handoff ──┘

Each step runs once. Context flows forward through named handoff files (e.g., handoff__analyze__to__plan.md).

Config

The --config flag is required for pipe and loop primitives. The named subcommands (build, fix, etc.) have built-in configs.

Loop config

max_iterations: 10
default_model: opus
plan_model: sonnet

loop:
  - step_name: worker
    task_prompt: "Read {state_dir}/tickets.json, find the next incomplete item, and implement it."
    system_prompt: "You are a WORKER in a RALPH LOOP..."

Pipe config

default_model: opus

pipe:
  - step_name: analyze
    task_prompt: "Analyze the codebase: {task}"
    system_prompt: "Perform a thorough code analysis."

  - step_name: implement
    task_prompt: "Implement the plan from the analysis."
    system_prompt: "Write the code described in the plan."
    model: sonnet

Each step requires step_name, task_prompt, and system_prompt. Optional: model (per-step override), handoff_prompt (pipe only). See configs/ for complete examples.

Background Jobs

Any command accepts --host to run as a background job via tmux:

ralphkit build task.md --host local   # local tmux session
ralphkit build task.md --host mini    # remote host (SSH config name)
ralphkit big-swing epic.md --host mini --working-dir /path/to/project

The --host flag takes an SSH config name directly — no additional config needed. Remote jobs run via uvx, so ralphkit doesn't need to be pre-installed on the remote host.

ralphkit jobs [--host NAME]             # list active jobs
ralphkit logs JOB_ID [--host NAME]      # view job logs (-F to follow)
ralphkit cancel JOB_ID [--host NAME]    # cancel a running job
ralphkit runs                           # list past completed runs

Requirements

  • Claude Code CLI (claude must be on your PATH)
  • Python 3.10+
  • tmux (for --host background jobs only)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ralphkit-0.1.7.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ralphkit-0.1.7-py3-none-any.whl (44.9 kB view details)

Uploaded Python 3

File details

Details for the file ralphkit-0.1.7.tar.gz.

File metadata

  • Download URL: ralphkit-0.1.7.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ralphkit-0.1.7.tar.gz
Algorithm Hash digest
SHA256 c1b98fe7743c33627ba046b09b98dfc3e20ebc2ddbb29877617bc2d31c271ee0
MD5 25e8665ea416b18b1f228ff552a10395
BLAKE2b-256 92cded51c8e02c2e5dcaf3d1cc1cb859b0c43ff49979069c41e4bc0b0c718557

See more details on using hashes here.

File details

Details for the file ralphkit-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: ralphkit-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 44.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for ralphkit-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b92ed46f0e0060969c1bcb4d98677c090d839c336f26285f0d85e52a10227e
MD5 0a9a25bb0e0685e9a16622235b0cc596
BLAKE2b-256 185df849be644f714946cfde7fba3245b58da3e699012fddc1b78b91e8d1816d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page