Advanced Usage

Autonomous workflows, self-correcting callbacks, web research, PDF generation, and tips for getting the most out of Context Pilot.

Autonomous Workflows

Context Pilot can work autonomously — the AI continues working through a todo list without waiting for your input after each step. This is powered by the Spine module.

Setting up autonomous mode

  1. Create a todo list with todo_create — break your task into subtasks
  2. Enable auto-continuation: spine_configure(continue_until_todos_done: true)
  3. Set guard rails to prevent runaway AI:
    spine_configure(
        max_cost: 2.00,           // Stop after $2 spent
        max_messages: 100,        // Stop after 100 messages
        max_duration_secs: 1800,  // Stop after 30 minutes
        max_auto_retries: 20      // Stop after 20 auto-continuations
    )
  4. The AI works through todos, marking them done, until all are complete or a guard rail triggers
⚠️ Always set guard rails Without limits, the AI could loop indefinitely. Start with conservative limits and increase as you build confidence.

Monitoring autonomous work

The Spine panel (P7) shows notifications, auto-continuation count, and guard rail status. Press Esc at any time to stop the AI mid-generation. The Todo panel shows progress in real-time.

File Edit Callbacks

Callbacks are the secret weapon: bash scripts that automatically fire when the AI edits files matching a glob pattern. They create a self-correcting feedback loop.

Creating a callback

Callback_upsert(
    action: "create",
    name: "rust-check",
    pattern: "*.rs",
    script_content: "cargo check 2>&1",
    blocking: true,
    timeout: 30,
    success_message: "Build passed ✓"
)

How it works

  1. AI edits a .rs file via Edit or Write
  2. The rust-check callback fires automatically
  3. In blocking mode, the AI waits for the result
  4. If the check fails, the AI sees the error output and self-corrects
  5. If it passes, the AI sees the success message and continues

Advanced callback features

With API keys configured, the AI can search the web and scrape pages. Tools follow an escalation tier system — start cheap, go deeper only if needed.

Escalation tiers

TierToolWhen to use
1brave_searchQuick facts, snippets — always try first
2brave_llm_contextNeed more depth from search results
3afirecrawl_scrapeFull page from a known URL
3bfirecrawl_searchSearch + scrape in one call
4firecrawl_mapDiscover URLs on a domain

Brave Goggles

Load the built-in "Brave Goggles" skill (skill_load("brave-goggles")) for curated domain re-ranking goggles — tech blogs, HN, academic sources, and more.

PDF Generation

Context Pilot embeds the Typst compiler — create professional PDFs from code without any external tools.

Quick start

# Create a document
Write("report.typ", "#set page(paper: \"a4\")\n= My Report\nHello world")

# Compile to PDF
typst_execute("typst compile report.typ")

# Watch for auto-recompile on edits
typst_execute("typst watch report.typ")

Templates

Reusable templates live in .context-pilot/shared/typst-templates/. Import them in your documents. You can also scaffold from Typst Universe:

typst_execute("typst init @preview/brilliant-cv:2.0.3")

Presets

Presets save and restore your entire working configuration — switch between different project contexts instantly.

Saving a preset

preset_snapshot_myself(
    name: "my-rust-project",
    description: "Rust project with clippy callbacks and web search"
)

Loading a preset

preset_load(name: "my-rust-project")

Presets capture: active agent, modules, disabled tools, todos, scratchpad, callbacks, and panel configurations. Messages are preserved.

Power-User Tips