← Blog

Graft v5.8: Conditional Routing, Rustc Errors, and Honest Positioning

4 min read
graftcompilerllmclaudeproductization

Graft is a domain-specific language that compiles .gft pipeline definitions into Claude Code harness structures. v5.7 was the first npm publish. v5.8 adds the features that make it feel like a real tool — and the documentation that's honest about what it is and isn't.

What Shipped

Conditional Edge Codegen

The parser has supported conditional routing since v3.9, but codegen silently dropped it. Now it generates real output.

edge RiskAssessor -> {
  when risk_score > 0.7 -> DetailedReviewer
  when risk_score > 0.3 -> StandardReviewer
  else -> AutoApprove
}

This compiles to:

  • Router hook (.claude/hooks/riskassessor-router.js) — reads the source output, evaluates conditions as JavaScript, writes a routing decision to .graft/session/routing/
  • Orchestration step — CLAUDE.md describes the conditional branching with conditions and targets
  • Settings entry — PostToolUse hook registered to fire when the source node writes output
  • Agent input overrides — each conditional target knows where to read from

The conditions are evaluated deterministically in the hook, not by the LLM. Claude Code reads the routing file to decide which branch to take.

Rustc-Style Error Messages

Before:

Error at line 6:11:
    reads: [Inpt]
              ^
    'Inpt' is not declared as a context, produces output, or memory

After:

error[SCOPE_UNDEFINED_REF]: 'Inpt' is not declared as a context, produces output, or memory
  --> pipeline.gft:6:11
   |
 6 |   reads: [Inpt]
   |           ^^^^
   |
   = help: did you mean 'Input'?

Levenshtein-based fuzzy matching for context names, produces names, memory names, and field names. The format follows rustc conventions: error code in brackets, file:line:col pointer, source line with underline, and help suggestions.

graft watch

graft watch pipeline.gft

Auto-recompiles on file changes with 100ms debounce. Also watches .gft imports in the same directory.

graft visualize

graft visualize pipeline.gft

Outputs the pipeline DAG as a Mermaid diagram:

graph TD
    Analyst["Analyst<br/><small>sonnet</small>"]
    Reviewer["Reviewer<br/><small>haiku</small>"]
    Analyst -->|select → compact| Reviewer

Shows nodes with model info, edge transforms, conditional branches, and parallel subgraphs. Paste into GitHub README or Mermaid Live Editor for visualization.

Positioning: What Graft Actually Is

After building v5.8, I stepped back and wrote honest documentation about the execution model.

Graft is a compiler, not a runtime orchestrator. The key distinction:

| | Deterministic | Best-effort | |---|---|---| | Edge transforms (hooks) | Yes | | | Model routing (settings) | Yes | | | Token analysis (compile-time) | Yes | | | Orchestration (CLAUDE.md) | | Yes — LLM prompt |

LangGraph and CrewAI use deterministic state machines to control execution. Graft generates a natural-language execution plan that Claude Code interprets. The data pipeline is deterministic; the orchestration is best-effort.

This is a real tradeoff. The upside: zero runtime dependency, compile-time token analysis, and native Claude Code integration. The downside: you're trusting an LLM to follow instructions.

The new positioning: "Infrastructure as Code for Claude Code multi-agent pipelines." Not competing with general-purpose orchestrators — serving Claude Code users who want structured, token-optimized pipelines without writing .claude/ files by hand.

Numbers

  • 1,614 tests across 104 test files (up from 1,574)
  • 40 new tests: conditional codegen (20), error formatting (13), CLI commands (7)
  • v5.8.0 on npm: 76 kB, 95 files
  • 6 CLI commands: compile, check, run, init, watch, visualize

M2 Status

| Task | Status | |------|--------| | Conditional edge codegen | Done | | Hook auto-execution verification | Done | | Rustc-style errors + did-you-mean | Done | | graft watch | Done | | graft visualize | Done | | Comprehensive user guide | Done | | npm org graft-lang | Pending (manual) | | Example e2e verification | Pending |

What's Next

The remaining M2 items are npm org migration and real-world example validation. Then M3: docs site, playground, GitHub Actions integration, and multi-backend support.

The honest positioning exercise was the most valuable part of this release. Knowing exactly what your tool is — and what it isn't — makes every subsequent decision clearer.