Turn off Claude Code subagent forking
Forked subagents are on by default in Claude Code; set CLAUDE_CODE_FORK_SUBAGENT=0 to turn them off so Claude waits for subagents instead of running them in the background.
Short, self-contained notes - one idea each: rules, snippets, and concepts from working with LLMs and agents. Cross-linked and kept current. Long-form pieces live in Articles.
[NOTES: 38]Forked subagents are on by default in Claude Code; set CLAUDE_CODE_FORK_SUBAGENT=0 to turn them off so Claude waits for subagents instead of running them in the background.
Claude Code sets CLAUDE_CODE_REMOTE in cloud sessions and leaves it unset locally, so one repo SessionStart hook can run installs only in the cloud VM.
In Claude Code, set promptCacheTtl to 1h for the main conversation and subagentPromptCacheTtl to 5m so long pauses keep the cache while subagents stay cheap to write.
A Claude Code cloud session clones from GitHub and its idle VM is reclaimed, so push before claude --cloud and commit before you walk away.
Auto memory is a per-repo directory Claude Code writes for itself, outside version control. Only the first 200 lines or 25KB of MEMORY.md load per session.
Batch processing cuts every token 50% with a 24h SLA and stacks with prompt caching to ~95% off cached async work - same model, asynchronous delivery.
Claude Code skills compose through explicit Skill-tool calls, not a sub-skill primitive - and disable-model-invocation blocks that call path too.
Put only universally applicable instructions in CLAUDE.md; task-specific content raises the odds an agent treats the whole file as noise and ignores it.
Fast mode buys up to 2.5x speed on Opus for a flat ~2x per-token premium with no quality change; lower effort cuts tokens and sometimes quality. They stack.
Claude Code's /goal evaluator is a Stop hook that doesn't call tools, so proof of completion - test output, an exit code - must appear in the conversation.
CLAUDE.md is advisory text the model re-weighs every turn; a PreToolUse hook that exits 2 is enforced code. A rule you can check shouldn't be a sentence.
Output tokens cost ~5x input and never cache - cut free-form prose first. Rewriting inside a cached prefix mid-session can raise the bill, not lower it.
Permission rules use ToolName(specifier) in allow and deny arrays; a bare tool name in deny disables it. Pair with OS sandboxing for subprocesses.
Use plan mode when the approach is uncertain, the change spans files, or the code is unfamiliar. Skip it for one-line diffs - typos, renames, log lines.
Plan mode's read-only promise is prompt reinforcement, not a lockdown. A PreToolUse hook blocking Write and Edit in plan mode makes it actually read-only.
Claude Code ships 46 built-in tools; only 14 ask for permission. Reads (Read, Grep, Glob) run freely in the working directory; mutations and external calls (Bash, Edit, Write) ask.
On Sonnet 5.5 and Opus 5.5, asking the model to reproduce its reasoning can return a reasoning_extraction refusal. Read summarized thinking instead.
Fable 5 safety classifiers return refusals as HTTP 200 with stop_reason refusal - every integration needs refusal handling and a fallback, not just errors.
Claude Code's /doctor prompt-audit is a model call, not a linter: the re-scan after fixes caught an instance the first pass missed. Fix, then run it again.
OS-level Bash sandboxing cut Anthropic's permission prompts ~84%, but /sandbox only wraps Bash. Climb to sandbox-runtime, container, or VM for a boundary.
Startup tax is the tokens loaded before your first prompt - system prompt, CLAUDE.md, MCP tools, skills, auto memory - paid each session and every turn.
A Stop hook that demands proof of completion - named check, exit code, real output - blocks the agent from ending the turn unverified. Mechanism, not plea.
A subagent runs in its own context window and returns only a summary, keeping heavy intermediate tokens out of the parent conversation.
A decision you can walk back through. Amazon's Type 1 / Type 2 split for agent delegation: reversible work goes to the agent; one-way doors go to a human.
Google's 2026 SDLC whitepaper draws the line at verification: vibe coding is prompts plus seems-to-work checks; agentic engineering adds specs, evals, CI.
Route architecture to a frontier planner and implementation to a cheap executor - a DeepSeek Flash-class executor at roughly 1/20-1/40 of Opus output cost needs a complete plan.
On Sonnet 5.5, 'minimize tool calls' makes it answer from training data when a search would catch what changed. Delete the line; say when to check sources.
Ask whether a fact must be known or followed. Knowledge tolerates a probabilistic layer; a rule that must always hold belongs in a check, not a prompt.
Claude Code runs a gather → act → verify loop: startup load fills context before you type, tool output piles up, and compaction, /clear, subagents trim it.
Fire the same request twice; if cache_read_input_tokens is zero on call 2, the prefix is changing or under the model minimum. Verify before you celebrate.
Observation masking swaps old tool outputs for a placeholder, keeping what the agent tried but not the bytes - agent cost down over 50%, solve rate intact.
Done means a named check passed with a real exit code - not the model saying so. Enforcement is a Stop hook, so it holds when session discipline decays.
Last-mile deployment adapts a working product to a customer's real systems until the paid-for outcome lands - the gap Forward Deployed Engineers close.
Put only byte-stable content before the prompt-cache marker - system prompt and tool schemas first, timestamps after - or every call pays full input price.
LLM-as-a-judge scores model output with a fixed rubric: DAG for pass/fail, G-Eval for subjective quality, QAG for fact checks. Cap pipelines at ~5 metrics.
Context engineering is curating what enters the model's context window each turn, rather than relying on a bigger window to absorb the clutter.
A verifiable completion condition is a loop stop rule with one measurable end state the model can prove from its own output - the loop ends, not spins.
Language models use information at the start and end of a long context far more reliably than the middle - recall drops well before the token limit.