Skip to content

abtreeHoping. Behaving.

Treat agent instructions like the software they are. Clear steps, predictable behavior, real answers when something goes wrong.

abtree

One instruction at a time

Agents start guessing when they try to do too much. Hide the full plan, ask for a single instruction, and allow your agent to focus on the present. The agent only ever sees the next step. The plan stays in the tree, not in the prompt.

CLAUDE.md · 487 lines
1. First, check the git status. Confirm a clean tree.
2. Read the existing tests. Note their style.
3. Locate the file containing the function to refactor.
4. Identify single-responsibility violations. Score each.
5. Draft a refactor plan and present to the user.
6. Apply the refactor, splitting concerns into modules.
7. Update the imports across the codebase.
8. Run the test suite. Verify everything stays green.
9. Re-score the codebase against the SRP criteria.
10. Confirm violations resolved. Loop if any remain.
11. Run a multi-agent code review on the diff.
12. Compose a before-vs-after report. Save to disk.
13. ...
abtree next
instruct
Score_SRP
Score the codebase for Single
Responsibility violations. Save
the ranked list to $LOCAL.violations.

Observability built in

Never guess where your agent got stuck. The runtime shows the tree in real time, logging each step. So you can see exactly what ran, what was skipped, and how far it got.

drag to pan · use buttons to zoom

YAML. JSON. TypeScript.

Whether you prefer code first or plain text, the TypeScript DSL gives composability and IDE support; YAML and JSON give a no tooling approach.

AuthoringSame tree. Different surface.
tree.ts01TypeScript
import {
  sequence, selector, action,
  evaluate, instruct,
} from "@abtree/dsl";
 
// Trees are plain nested function calls.
const tree = sequence("Greeting", () => {
  // Action: evaluate (precondition) + instruct.
  action("Detect_Time", () => {
    instruct(`Detect the time of day.`);
  });
 
  // sequence / selector / parallel — three composites.
  selector("Choose_Greeting", () => {
    action("Morning", () => {
      evaluate(`time is morning`);
      instruct(`Say "Good morning".`);
    });
    action("Default", () => {
      instruct(`Say "Hello".`);
    });
  });
});
TREE.yaml02YAML
name: greeting
version: 1.0.0
 
tree:
  type: sequence
  name: Greeting
  children:
    # Action: an evaluate (precondition) + an instruct.
    - type: action
      name: Detect_Time
      steps:
        - instruct: Detect the time of day.
 
    # sequence / selector / parallel — three composites.
    - type: selector
      name: Choose_Greeting
      children:
        - type: action
          name: Morning
          steps:
            - evaluate: time is morning
            - instruct: 'Say "Good morning".'
        - type: action
          name: Default
          steps:
            - instruct: 'Say "Hello".'

Share with the tools you love

Publish to npm, share through GitHub or bring your own tooling.

Hand over to your agent

Claude Code, ChatGPT, or any shell-capable agent, the brief is the same. Paste it. The agent understands and walks the tree until the end.

text
Install the npm package @abtree/srp-refactor, then drive the workflow against this repo:

  abtree --help
  abtree execution create ./node_modules/@abtree/srp-refactor "Refactor the worst SRP violation in src/"

For the long-form walkthrough — install the CLI, add a tree, drive it from your agent — see Get started.

From local to fleet

Whether running locally or with a fleet of agents, the engine, DSL, and protocol stay the same.

  • Core engine — Deterministic execution, one step at a time. Resumable and replayable.
  • DSL — Author workflows in YAML, JSON, or TypeScript that compile to one tree shape.
  • CLI tool — Drive a workflow from any shell or agent with next, eval, and submit.
  • STDIO MCP server — Native protocol for local agents; skip the CLI plumbing.
  • HTTP MCP server — Host central workflows any fleet of agents can reach.

MCP is the Model Context Protocol — the wire format agents already speak.

Dive in

Get started · Discover trees · View on GitHub

MIT licensed