Impact-Site-Verification: 578d421e-1081-463d-918b-ec5e29c5b9db
<Back

AI Coding-Agent Tooling

Personal Project

Overview

Built the operating setup for handing work to Claude Code: a CLI that delegates work to headless workers on a specified model, hooks that enforce the delegation rules, review-model selection by diff size, and Claude Code skills. Lightweight tasks such as file search and summarization go to a local LLM self-hosted on a DGX Spark.

Hooks and Review-Model Selection

  1. Delegation enforcement: the hook counts the main session's own tool calls and denies them past a budget of 60 reads and 8 edits or other calls; delegating resets the count.
  2. Review-model selection: 300 or more changed lines get the top model, 200 to 299 the next, and under 200 the standard model, with no review for documentation-only changes. Sensitive paths (credentials, auth, payments, hooks), destructive patterns (rm -rf, force push, DROP TABLE, and the like), dependency-manifest changes, and retried changes always get the top model. Anything that cannot be measured raises the tier (fail-closed).
  3. Hooks (6 registered): enforce delegation, back up before rm, check merges non-destructively before push, enforce plan mode for the plan command, block a mail-sending path that garbles Japanese subjects, and lint full-width Japanese punctuation.
  4. Skills: 17 self-written Claude Code skills (vendored ones excluded).

Delegation CLI

The caller names the model, and the CLI hands the work to a headless Claude Code worker. The core is 3,669 lines of Bash, with 2,634 lines of Python helpers for statistics and review tiers (standard library only). The CLI itself does not judge difficulty; the mapping from difficulty to model is written as rules.

  1. Run records: each run is logged as one JSON line with the model, role, turns, session ID, and evidence path, and the prompt is saved.
  2. Implementation lock: implementer workers take a per-directory lock so two workers never edit one tree. If the lock is busy, a git worktree is created automatically so the work runs in parallel, and the result is brought back to the original branch afterwards.
  3. Test evidence: implementers write test results to an evidence file along with a fingerprint of the work tree; reviewers read it and are told when the tree has moved and the evidence is stale.
  4. Runaway guard: workers run in their own process group under a watchdog (3,600 seconds by default), and a timeout stops the whole tool subtree. Session IDs are assigned up front so a killed run can be resumed. Nested calls from a worker are refused with an exit code.
  5. No turn cap by default: a cap would stop a run mid-edit, so the watchdog is the runaway guard instead.
  6. MCP servers are loaded into a worker only when requested, which keeps the shared prompt prefix small.

Local LLM

Qwen3.8-Flash-Next (NVFP4-quantized), self-hosted with vLLM on DGX Spark, runs file search, code reading, summarization, and harmless mechanical edits through OpenCode. Implementation and review never go to the local model; it is a separate path from the delegation CLI.

  1. Pinned image: the stock vLLM image cannot load this model's quantized tables, and the recipe broke twice in one week, so the working image tag is pinned. The 26.8 GiB tables live on NVMe and are read with io_uring to fit in memory.
  2. Rejected: routing sub-agents to the local model by request header needed a dedicated launcher that loses remote control, and had no fallback when the DGX Spark is down.
  3. Safeguards: shell access is limited to a read-only allowlist. When several runs start in the same second, OpenCode's SQLite database locks, so the runner waits a random interval and retries once.
  4. Observed: the local model also followed an instruction to change a config default, so the scope it gets is limited by caller discipline.

Verification and Usage Record

  1. Tests: the delegation CLI is tested against a fake Claude CLI; the run recorded on October 21, 2026 shows 742 passed and 0 failed. Review-model selection has its own tests, and 4 of the 6 hooks have test scripts.
  2. Measured (when switching the local model): 631 seconds to start, 46.3 tokens/s on one stream, 96.1 tokens/s in total over 4 parallel streams, and all 4 parallel runs exited normally.
  3. Measured (run logs as of November 16, 2026): 3,128 delegation-CLI runs (one run = one logged invocation, including resumes and failures). The local-LLM path ran 139 times, 59 of them on Qwen3.8-Flash-Next (earlier runs used a different model).

Technologies

Claude CodeBashPythongit worktreeHooksOpenCodevLLMDGX SparkQwen3.8-Flash-NextDockerchezmoi