The local-first safety & cost layer for Claude Code, Codex, and OpenCode.
Same agents. Hard spend caps. Sub-millisecond guardrails. Zero telemetry.
Quickstart • Why Tucana • Safety Cockpit • Architecture • Kill-Switch • Closed-Loop Calibration
Coding agents run real shell commands on your machine and burn real API dollars while you look away.
One hallucinated rm -rf, one leaked .env piped to curl, or one runaway reasoning loop on pay-as-you-go tokens can wipe your morning in seconds.
Tucana Code puts a <1 ms, $0, 100% offline safety & budget gate directly inside Claude Code's PreToolUse hook (and any CLI agent wrapper) — without shipping your prompts, code, or traces to anyone's cloud.
| Capability | Unprotected Agent | Cloud AI Gateways | Tucana Code (v0.1.0) | |---|---|---|---| | Safe read-only checks (git status, tests) | Manual click or YOLO | +150–600 ms network roundtrip | <1 ms System 0, $0, 100% offline | | Destructive / exfil protection | Hope the LLM behaves | Cloud policy / SaaS lock-in | Instant deterministic block + fail-safe | | API spend ceiling & Kill-Switch | Surprise invoice tomorrow | USD-only / proxy account | Real-time USD + 6 LATAM currencies | | Telemetry & cloud accounts | Vendor telemetry | Cloud dashboard + auth | Zero accounts · Zero network · MIT | | Learn from your overrides | Re-prompt forever | Vendor fine-tuning | Human review in tucana-lab → <1 ms rules |
Requires Node.js >=22.16.0. Zero runtime dependencies in the published CLI ( 27.5 kB packed, ~56 ms cold start).
npm install -g tucana-code
tucana-code --help
(Want to try a one-off command first? Run npx tucana-code --help.)
init --dry-run backs up ~/.claude/settings.json with a timestamp, registers PreToolUse idempotently using your resolved binary path (never slow npx in the hot path), and runs in observation mode while writing real traces:
tucana-code init --dry-run --currency MXN
tucana-code doctor
Test all three decision paths immediately:
tucana-code guard check -- git status # System 0 -> ALLOW (<1 ms, $0)
tucana-code guard check -- "rm -rf /" # System 0 -> BLOCK (<1 ms, $0)
tucana-code guard check -- "npm run deploy:staging" # Gray zone -> ESCALATE (ask)
Ready to enforce live blocking? Re-run without --dry-run:
tucana-code init --currency MXN
Using Codex, OpenCode, Gemini CLI, or local scripts? Wrap any command in one line:
tucana-code guard check -- <command>
Run tucana-code locally for an Editorial Instrument workspace built specifically for agent governance and cost control:
- Tucana Light (Paper) & Tucana Space (Dark): Warm paper canvas (
#F4EEE3) as the strict default, paired with dark space mode (#0B101B) via aLight | Spacesegmented toggle. - 44px Top Telemetry Ribbon: Live
System 0mode selector (Active,Strict,Dry-run) and an interactiveBudget Guard popover to switch currencies (USD,MXN,COP,ARS,BRL,CLP,PEN) and update thread/daily caps in~/.tucana-code/budget.json. - Collapsible Editorial Rail & Session Briefing: Numbered session index (
01,02, ...) withWorkspace & Git,System 0 Gate, andBudget Guardcards under the composer. - Clean Offline Resilience: Local WebSocket/network loss renders a clean Tucana reconnecting state with zero cloud dependencies.
Tucana splits decisions between deterministic speed and calibrated escalation so your fast path stays instant and offline:
flowchart LR
Agent["Agent Bash Call<br/>(PreToolUse / CLI)"] --> Budget{"Local Budget<br/>Kill-Switch?"}
Budget -- "Limit Exceeded" --> Deny["DENY<br/>(0 ms, kill_switch)"]
Budget -- "Within Budget" --> Sys0{"System 0<br/>Deterministic + Policy"}
Sys0 -- "Known Safe / Approved" --> Allow["ALLOW<br/>(<1 ms, $0)"]
Sys0 -- "Known Destructive / Exfil" --> Block["BLOCK<br/>(<1 ms, $0)"]
Sys0 -- "Gray Zone" --> Sys1["System 1 (Optional)<br/>Ollama / KEV / Jev / Offline Ask"]
Deny --> Trace["Append-Only<br/>decision-trace.jsonl"]
Allow --> Trace
Block --> Trace
Sys1 --> Trace
Trace --> Lab["Tucana Lab<br/>ECE / Brier + Active Learning"]
Lab -- "policy-calibration.json" --> Sys0
- System 0 (
<1 ms,$0, offline): Fast deterministic rules + exact-match human-approved rules loaded from~/.tucana-code/policy-calibration.json. - System 1 (optional, never blocking): Point
TUCANA_KEV_URLorOLLAMA_HOSTto your local model ($0), or optionally setJEV_API_KEY. When offline or unconfigured, gray-zone commands gracefullyescalate(ask) — never crashing your session.
Every raw agent trace starts as scattered telemetry points in the dark (01 Origin). Run it through continuous evaluation and uncertainty sorting ( 02 Vortex), assemble human-verified judgment on a structured grid ( 03 Assemblage), and lock it into sharp, deterministic <1 ms instincts ( 04 The Tucana).
Built for real pay-as-you-go developers across the Americas and beyond. Configure limits in USD and track spend in USD ($), MXN ( MX$), COP ( COL$), ARS ( ARS$), BRL ( R$), CLP ( CLP$), or PEN ( S/):
# Set per-thread and daily spending caps
tucana-code budget set --currency MXN --thread-limit 0.15 --daily-limit 2.00
# Check current thread & daily spend
tucana-code budget status --currency MXN --thread-id session-1
# Record token usage; triggers kill-switch once the cap is reached
tucana-code budget record --model claude-sonnet-5-5 --input 100000 --output 20000 --thread-id session-1 --currency MXN
# Once tripped, even benign commands are halted cleanly
tucana-code guard check --thread-id session-1 --currency MXN -- git status
# -> BLOCK (kill_switch, conf=1, 0ms): Kill-switch: thread spend MX$... reached limit MX$...
# Summarize local traces or clear limits when ready
tucana-code trace summary --currency MXN
tucana-code budget set --thread-limit none --daily-limit none
Every guardrail verdict is appended locally to ~/.tucana-code/traces/decision-trace.jsonl (conforming to schemas/decision-trace.schema.json v0.1.0).
Open those traces in Tucana Lab (aisona-lab/tucana-lab) to:
- Measure real calibration (10-bin Reliability Diagram, Expected Calibration Error, Brier score).
- Label only high-uncertainty edge cases via keyboard-first Active Learning (
feedback.jsonl, keepingdecision-trace.jsonlstrictly immutable). - Export
policy-calibration.jsonstraight back to~/.tucana-code/policy-calibration.jsonsotucana-codeimproves<1 msdecisions instantly —with zero model training required . - Export clean SFT JSONL datasets whenever you are ready to fine-tune your own local Qwen / Llama / Mistral classifier.
- Zero telemetry: 100% free of PostHog, Axiom, Clerk, analytics beacons, or cloud relay dependencies. Everything lives under
~/.tucana-code/. - Fast hot path:
tucana-code initwritestucana-code hook claude-pretool(ornode <resolved-bin.mjs> hook claude-pretool) — nevernpxinsidePreToolUse. - MIT Open Source: Licensed under theMIT License .
git clone https://github.com/aisona-lab/tucana-code.git
cd tucana-code
corepack pnpm install
corepack pnpm run typecheck
corepack pnpm --filter @tucana/guardian test
corepack pnpm --filter tucana-code build
Verify shared schema parity with tucana-lab:
node scripts/verify-contract-parity.mjs
If Tucana Code saved a production directory or an unexpected API bill, consider giving the repo a ⭐
and exploring aisona-lab/tucana-lab for visual calibration & Active Learning.
原文来源:github.com