agentleFS
leodavinci1leodavinci1/kanbots/docs/agents.md

kanbots

AGENTS.md609 starsChanged 6 months agoMITView on GitHub

kanbots dispatches one agent run per issue, in an isolated git worktree, backed by either Claude Code (claude -p) or Codex (codex exec). This page describes that lifecycle in detail. Two CLI agents are supported, behind a single AgentCliAdapter interface (packages/dispatcher/src/). The adapter encapsulates argument construction, stream parsing, and decision plumbing — the rest of the dispatcher doesn't care which CLI is underneath. You pick which one to use per dispatch from the AI providers modal: Settings → AI providers…

  • Reads credentials
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

The file

We split this agents.md into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    When the run ends, the worktree stays on disk until you promote it, discard it, or run another action that removes it.

    line 60
  2. Very specific:

    When the agent emits a decision event, the dispatcher:

    line 91
  3. Distinctive:

    If you close the app mid-decision, the state is on the card — reopen and respond.

    line 101
  4. Very specific:

    Every result event carries a USD cost (both CLIs report it).

    line 122
  5. Distinctive:

    When a run finishes you have three ways to land its work:

    line 160

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
agents.md

Agents

kanbots dispatches one agent run per issue, in an isolated git worktree, backed by either Claude Code (claude -p) or Codex (codex exec). This page describes that lifecycle in detail.

What runs

Two CLI agents are supported, behind a single AgentCliAdapter interface (packages/dispatcher/src/). The adapter encapsulates argument construction, stream parsing, and decision plumbing — the rest of the dispatcher doesn't care which CLI is underneath.

AgentInvocationNotes
Claude Codeclaude -pReuses your claude /login credentials. Best default.
Codexcodex execRequires codex on PATH. Sign in via "Sign in with codex" or OPENAI_API_KEY. Issue drafting and Sentry analysis still run on Claude.

You pick which one to use per dispatch from the AI providers modal:

Image: AI providers modal showing Claude Code and Codex CLI

Settings → AI providers also sets the workspace default — claude (auto) uses whichever CLI is enabled and signed in.

The Claude flags used are roughly:

claude -p \
  --output-format stream-json \
  --verbose \
  --permission-mode bypassPermissions \
  --append-system-prompt "<issue context>" \
  --model <chosen model> \
  [--resume <sessionId>] \
  [--mcp-config <path>]

--permission-mode bypassPermissions is what makes runs hands-off — the agent is allowed to use any tool without prompting per call. Containment is enforced separately (see below) and a pre-push hook in the worktree prevents network pushes regardless. Codex's equivalent flags are configured by its adapter in the same place.

Worktree lifecycle

For each run kanbots:

  1. Creates a worktree at .kanbots/worktrees/issue-<n>-<runId>/.
  2. Branches from the repo's default branch as kanbots/issue-<n>-<runId>.
  3. Stamps an identity file (.kanbots-identity.json) used to recover orphaned runs.
  4. Installs a pre-push hook that exits non-zero — any push attempted from inside the worktree fails.
  5. Spawns the Claude process as a detached process group leader (POSIX) so it can be killed cleanly with SIGTERM → SIGKILL escalation.

When the run ends, the worktree stays on disk until you promote it, discard it, or run another action that removes it. Worktrees and their branches are first-class kanbots state — you can have many parked runs across many issues.

The stream

Both CLIs emit one JSON object per line (Claude's stream-json and Codex's equivalent). The dispatcher's stream-parser classifies each line into one of:

EventMeaning
textAssistant message text
tool_useTool call (Read, Edit, Bash, …)
tool_resultTool result body
sessionSession id (used to resume runs)
decisionPending decision prompt — the run pauses
resultEnd of run, with success/failure and cost
rate_limitProvider rate-limit signal — see cooldown
parse_errorA line we couldn't parse

Events are persisted into the agent_events table and broadcast over the agent-runs:events:subscribe IPC channel. The UI replays from the table on reconnect, so the live thread survives a renderer reload.

Decision prompts

Image: Awaiting decision prompt with four numbered options

When the agent emits a decision event, the dispatcher:

  1. Marks the run's card as awaiting_input.
  2. Stores the question and option list on the card.
  3. Stops feeding stdin — the agent process waits.
  4. Pushes a DecisionPayload ({ question, options: [{ value, label }] }) to the UI.

You answer it in the issue detail modal. The handler cards:resolve writes the choice back into the agent's stdin and the run continues. If you close the app mid-decision, the state is on the card — reopen and respond.

Containment

Either CLI can technically Edit or Write to any path the user can access. kanbots watches every tool_use and compares the target path to the worktree root. Behaviour is governed by containment mode:

ModeEffect on out-of-worktree edits
offAllowed, no surface
warn (default)Logged as a warning event in the thread
pauseRun pauses with a decision; you choose to allow or stop

Set it per-workspace with containmentMode in .kanbots/config.json, or per-process via KANBOTS_CONTAINMENT_MODE=pause (etc.) in the environment.

Cost budgets

Every result event carries a USD cost (both CLIs report it). The dispatcher accumulates it into:

  • Per-run cost — visible on the run card.
  • Per-session cost — when run under autopilot.

Two budgets, both optional:

// .kanbots/config.json
{
  "defaults": {
    "runCostBudgetUsd": 2.50,        // single run cap
    "sessionCostBudgetUsd": 25.00    // autopilot session cap
  }
}

Setting either to null (or omitting it) disables that cap. When a cap is hit the run is stopped with stopReason: 'cost-budget'.

Rate limits

The streams surface rate-limit hits explicitly. When the dispatcher detects one it broadcasts a cooldown:changed event with the resume time. The UI shows a banner and queues new dispatches until the cooldown clears.

Resuming a run

Each invocation produces a session id (in the session event). The dispatcher persists it on the run row; on resume, the next process is spawned with the CLI's resume flag (--resume <sessionId> for Claude; the Codex equivalent for Codex) so context is reused without re-sending the full history.

Promotion

When a run finishes you have three ways to land its work:

ActionWhat it does
Promote commitStages the tip of the worktree's branch and merges/cherry-picks onto the active branch in your main checkout. Worktree is removed.
Open draft PR(GitHub mode only) Pushes the branch to origin and opens a draft PR via Octokit. Worktree stays.
Reveal worktreeOpens the worktree path in your file manager so you can inspect or hand-edit before promoting.
DiscardStops the run if active, removes the worktree, deletes the branch.

Promotion is the only path through which agent commits reach your real branches. Even with bypassPermissions, the pre-push hook guarantees the agent itself never publishes anything.

Autopilot

Autopilot is the higher-level orchestrator: instead of one click → one run, you set a goal and a budget and walk away. Two kinds:

feature-dev — self-evolving, parallel

Image: Start an autopilot — Feature dev with personas

The signature mode. You pick a roster of personas (e.g. product author, engineer, reviewer, tester) and a parallelism count (1–4). The orchestrator:

  1. Spawns up to N parallel slots (capped at 4 by MAX_PARALLELISM).
  2. Each slot atomically claims the next persona from a round-robin counter (cycle_index).
  3. Each persona's child run is dispatched against the parent issue inside its own worktree.
  4. Personas can split the issue into subtasks as they go — splitIssue creates child cards on the board, and later cycles pick them up.
  5. The loop continues until you stop it, the session cost budget is hit, or a persona signals completion.

This is what "self-evolving with parallel task creation and execution" means in practice: agents discover what's missing, file new cards for it, and other slots execute those new cards in parallel — the backlog grows and shrinks under the orchestrator without you intervening.

qa — autonomous fix loop

Configurable check commands plus optional dev-server watching:

  • Runs each AutopilotCheckCommand (typecheck / tests / lint / build / e2e) in the worktree.
  • Optionally starts your dev server and watches for live-UI failures.
  • For every failing check, dispatches a fix run on a derived child issue.
  • Re-runs checks until everything passes or the budget is hit.

Configuration

type AutopilotKind = 'feature-dev' | 'qa';
type AutopilotEffort = 'low' | 'medium' | 'high' | 'xhigh' | 'max';

interface FeatureDevConfig {
  kind: 'feature-dev';
  personas: AutopilotPersonaSnapshot[];
  model?: string;
  effort?: AutopilotEffort;
  parallelism?: number;            // 1–4; clamped, default 1
  sessionCostBudgetUsd?: number;
}

interface QaConfig {
  kind: 'qa';
  checks: AutopilotCheckCommand[];
  liveUi: boolean;
  devServer?: { command: string; args: string[] };
  sessionCostBudgetUsd?: number;
}

Effort maps to model selection and tool budget — low keeps to cheap models with tight context; max lets the run think for a long time.

Sessions, child runs, and cycle bookkeeping all live in the autopilot_sessions table. Stopping the parent stops all children; in-flight children finish their current iteration but no new child runs are started.

Personas

A persona is a named system prompt snippet. Each one biases the agent toward a particular lens (Product Manager, Senior Engineer, UX Designer, Growth Lead, Reliability Engineer, …) — feature suggestions, code reviews, and split decisions shift accordingly.

Image: Pick a perspective modal showing persona tiles

Personas are stored locally (in the SQLite db). Built-in ones ship with kanbots; New persona lets you write your own — define the prompt, save, reuse forever. Custom personas never leave your machine.

In one-off dispatches the chosen persona is applied via --append-system-prompt; in an autopilot feature-dev session the roster is the round-robin source for parallel slots.

Files of interest

  • packages/dispatcher/src/worker.ts — the spawn / stream loop
  • packages/dispatcher/src/stream-parser.ts — line classification
  • packages/dispatcher/src/worktree.ts — git worktree wrapper
  • packages/dispatcher/src/containment.ts — path-scope guard
  • packages/api/src/agent-runs/ — handlers for dispatch/stop/promote
  • packages/api/src/autopilot/ — session orchestration

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.