google/capsem/dev-debugging

Claude Code and agent skill by google/capsem

Trust tier 4
  • vendor
Source check pending

Checking that the SKILL.md file is still in the repository.

Debugging methodology: reproduce first, find the root cause, fix the whole pattern. Use for bugs, test failures, or CI/local parity failures.

Install

npx vskill@latest install google/capsem/dev-debugging

SKILL.md

The same SKILL.md was published earlier as google/capsem/dev-debugging.

Debugging

The rule

Never fix code before you understand why it broke. The temptation to "just make the test pass" or "just patch the symptom" leads to fragile fixes that hide deeper problems. Follow the three-step workflow below every time.

Choose the cheapest truthful feedback loop

Keep implementation moving. Use a minimal reproducer and focused TDD checks during coding, then return to the next implementation item. Broad qualification runs belong at the end of a major phase; a small fix does not justify another whole contract/workspace/VM/install run. The bounded wrapper retains timeout and cleanup without a routine machine lease.

Capsem now has two distinct execution surfaces:

  • Just exposes the small public product interface.
  • Python under build_system/builder/gate/ owns build/test/release plans, graph edges,

locking, resources, evidence, and cleanup.

For a gate failure, debug the Python step and action that failed; do not infer the implementation from the Just recipe or recreate it with shell commands. Start with:

bash
uv run --project build_system --frozen capsem-gate runs last --failed
uv run --project build_system --frozen capsem-gate <command> --dry-run
uv run --project build_system --frozen capsem-gate <command> --graph

Use the smallest focused pytest, cargo, pnpm, or script command for red/green work. Use just focus-test functional for focused integration feedback, and just fast-test for the fast gate itself. Use just test when the forward fix is ready for the complete local verification a release requires.

Direct diagnostics which may block, build, launch children, or wait on input must use the portable bounded-process wrapper rather than a bare shell command:

bash
python3 build_system/scripts/ci/run-bounded-command.py --timeout-seconds 1800 -- <command> <args...>

The wrapper closes stdin, creates a dedicated process group, and terminates the whole group on timeout or interruption. This prevents a PTY-backed docker build -f -, compiler, test runner, or child helper from surviving its owning diagnostic. Pick a finite timeout appropriate to the focused operation; do not wrap just test or a release command, whose config-owned step timeouts, journal, teardown, and resumable graph are the authority.

Diagnostic continuation for a late gate failure

When a clean candidate fails after expensive predecessors have succeeded, use diagnostic continuation to reuse that retained state and reach the frontier quickly. The current CLI retains legacy flag names:

bash
uv run --project build_system --frozen capsem-gate runs last --failed
uv run --project build_system --frozen capsem-gate candidate --prefix <retained-prefix> --from <failed-step>

The --from step runs; graph predecessors are reported as carried. Before using it, match the prefix and failed step to the origin run, confirm the required predecessor really completed there, and record the origin run ID in the diagnosis. Prefer a fresh focused test when the edit invalidates the expensive producer itself.

Carried steps with external runtime products are revalidated before resumed work. If one was reclaimed, use the exact owning --from label in the refusal; do not guess an earlier frontier or recreate the product by hand.

Call the result diagnostic-passed or diagnostic-failed, even if the current implementation still summarizes a zero exit as ok. It combines earlier outputs with current source and therefore answers only whether the new segment can proceed. It does not prove the complete current tree.

Never use diagnostic continuation with release-binaries or release-assets, and never let it authorize publication. After the fix, use the smallest owning focus-test group. Before release, run just test <commit> to success: the public release command requires its complete local journal for that commit or an identical Git tree by default. An explicitly authorized release force permits a focused test-only correction without repeating the complete local run; source guards and full hosted qualification remain. The unattended nightly scheduler is also exempt ([release].unattended_channels in `config/gate.toml`; see `RELEASE.md` section 8). The hosted lane then independently qualifies the artifact pairing it publishes.

Step 1: Reproduce with a test

Before touching any implementation code, write a test that captures the bug. This test must:

  • Fail right now, demonstrating the broken behavior
  • Be specific enough to distinguish the bug from correct behavior
  • Live in the right test location (see dev-testing for where tests go)

If you can't reproduce it in a test, you don't understand it well enough to fix it. For VM-level issues, use capsem-doctor or write a targeted diagnostic command:

bash
just exec "<command that triggers the bug>"

For telemetry issues, inspect a live session through the typed timeline, history, statistics, and security routes. Use check_session.py --db only on a coherent, quiesced evidence copy after its ledger worker has stopped; see /dev-session-debug.

Step 2: Diagnose the root cause

With a failing test in hand, investigate. Do not skip this step. Common diagnostic approaches:

MCP triage trio (run FIRST when an investigation is open-ended):

capsem_panics { since: "1h" } # any Rust panic in any host log? -> rank highest
capsem_triage { id: "vm-1" } # ranked recent ipc-warns + 4xx/5xx + slow_ops + session.db errors
capsem_timeline { id: "vm-1", trace_id: "<X>" } # follow ONE logical operation across exec/tool/net/fs/model

These read post-W2 JSON logs (~/.capsem/run/{service,mcp,gateway,tray}.log + capsem-app's latest jsonl) and post-W6 session.db tables. The W4 target=fs op=fsync duration_ms=... markers feed capsem_triage's slow-op rank; the W3 schema_hash check appears in capsem_panics output as IPC handshake failed; refusing connection events. Always start with capsem_panics -- a single panic outranks a hundred warns.

Cross-version mix? The service.start log line emits protocol_version=N, schema_hash=<hex> per binary. If the support bundle (capsem support-bundle) shows two different schema_hash values across binaries, you're hitting the W3 cross-version-mix detection -- rebuild + restart the lagging binary.

Integration-test failures: read the preserved service log. When any integration test fails, the test fixture (tests/helpers/service.py::ServiceInstance, the e2e RealService, and the MCP _start_capsem_service) archives its tmp_dir to cache/target/tests/evidence/<timestamp>-<worker>-<nodeid>/<tmp-basename>/ before the usual rmtree. The failing test's stderr has the exact path: look for a line ARTIFACT: preserved /var/folders/... -> cache/target/tests/evidence/.... Inside that directory:

service.log host-side capsem-service debug log (RUST_LOG=debug)
logs/gateway.log gateway stdout/stderr
logs/tray.log tray stdout/stderr (if spawned)
sessions/<vm-id>/process.log per-VM capsem-process log (vsock bridge, IPC, spawn chain)
sessions/<vm-id>/serial.log VM serial console (kernel boot, capsem-init, agent startup)
sessions/<vm-id>/session.db SQLite telemetry DB (net_events, model_calls, ...)
persistent/<name>/... persistent-VM state (checkpoint.vzsave, workspace)

cache/target/tests/evidence/ is gitignored. Multiple failures sharing a session-scoped service land in different subdirs but the latest run's name tags them by the most recent failing nodeid. First place to look for "VM didn't become exec-ready" style failures: sessions/<id>/serial.log (did the VM boot?) and sessions/<id>/process.log (did the agent come up + IPC handshake?). For "provision hung" or service-side contention: service.log, grep for the VM id.

Rust code: Read the code path the test exercises. Trace the data flow. Add tracing instrumentation if needed (RUST_LOG=capsem=debug). Check if the issue is in capsem-core, capsem-app, or capsem-agent.

Guest VM issues: Boot with targeted commands and inspect behavior:

bash
just exec "capsem-doctor -k <category>" # Run specific diagnostic category
just exec "<manual investigation command>"

Check boot logs for daemon startup failures, vsock connection issues, or timing problems.

Network/security issues: Check the network intercept path -- SNI parsing, HTTP/DNS/model normalization, cert minting, SecurityEvent construction, security rule evaluation, plugin execution, runtime materialization, and ledger materialization. Do not debug by adding credential handling to formatters, routes, DB readers, frontend transforms, or harnesses. Inspect the typed timeline and security routes to see what the live ledger recorded. For page or archive integrity, preserve a quiesced evidence copy and follow /dev-session-debug.

Frontend issues: Run just dev ui, open Chrome DevTools, check console errors, use take_screenshot to capture state. See dev-testing-frontend for the full visual verification workflow.

Build pipeline issues: Check cache/containers/logs/build.log -- all build infrastructure (runner, code signing, generation scripts) logs here. The runner (build_system/packaging/macos/run_signed.sh) and _generate-settings recipe both append to this file. Never write diagnostics to stdout from build scripts (it contaminates binary output like mcp-export).

For a Python gate or release failure, inspect the recorded run first. Step labels, argv, timing, captured output, resource events, and the first failed action live under cache/target/gate-runs/; capsem-gate runs last --failed is the supported reader. cache/containers/logs/build.log is supporting build evidence, not the gate's execution ledger.

Do not retry a release through its script, capsem-admin release, or a GitHub workflow. The public command first accepts the exact qualification journal, then runs prechecks, source publication, and dispatch as one graph. A direct script or workflow skips the edges that make release safe.

Telemetry pipeline issues: The canonical session ledgers (net_events, model_calls, tool_calls, tool_responses, fs_events, dns_events, security_rule_events) each have their own boundary. If a table is empty or has wrong data:

  • Check if the guest daemon started (boot logs)
  • Check if the vsock connection was accepted (host logs)
  • Check timing -- did the VM shut down before the DB-owned buffer flushed? Use

the DB flush barrier or shutdown/reopen proof; do not add a sleep or poll.

For route latency or stale stats, do not add service-owned logged-data projections. Logged-data hot state belongs inside the logger DB object as table-level mem/disk ownership with DB-layer tests and benchmarks. Service routes may describe the query they need, but production service code must not open rusqlite connections or DbReader directly.

Do not "fix" route latency by hardcoding route-specific query helpers in DbWriter, by adding service caches, or by swallowing missing tables/columns as empty data. The correct diagnosis target is the DB object: connection/thread ownership, mem/disk layout, batching, flush, and query execution. If the schema is missing, surface the broken ledger contract.

Write down what you find. The diagnosis should explain why the bug exists, not just where the symptom appears.

Concurrency flakes are product bugs, not test-tuning problems

just test runs the python suite under pytest -n 4 --dist=loadfile. Four real VMs boot in parallel; this is dogfooding. Capsem ships as a multi-VM sandbox for AI agents -- if the test suite cannot safely run 4 concurrent VMs, real users running an agent farm will hit the same bug. When a test flakes only under concurrency, the diagnosis target is Capsem's product code, not the test:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 24 Jun 2026.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
58
Repository forks
8
7-day trend score
20

Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 13 Oct 2026, a month ago.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill CERTIFIED badge
[![vskill CERTIFIED](https://verified-skill.com/api/v1/skills/google/capsem/dev-debugging/badge)](https://verified-skill.com/skills/google/capsem/dev-debugging)

Something wrong with this skill or its page? Tell us.