instrumentation
Use when instrumenting code with runtime logs to test a hypothesis — @dxos/log debug lines captured to app.log (browser), test.log (node tests), or…
Skill by wittjosiah
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/wittjosiah-instrumentation
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing, data, productivity
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/instrumentation
What's inside
- Skill name
instrumentation- Description
- Use when instrumenting code with runtime logs to test a hypothesis — @dxos/log debug lines captured to app.log (browser), test.log (node tests), or test-browser.log (browser tests/storybook), and querying them with query-logs.mjs. Reference for the log-exfiltration pipeline and instrumentation mechanics, not a debugging workflow.
- License
- MIT
- Instructions
- 104 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Debugging instrumentation (@dxos/log pipeline)
Mechanics for hypothesis-testing with runtime logs. The debugging _process_ —
hypotheses, isolation, verification, user interaction — is owned by the calling
skill (`diagnosing-bugs`, or `diagnosing-ui` for UI bugs) or workflow; this skill is only how to get
signals out of running code cleanly.
## The pipeline — how log exfiltration works here
This repo already ships the full pipeline; do not reinvent it.
- `@dxos/vite-plugin-log` is wired into `composer-app/vite.config.ts` and intercepts every browser-side `@dxos/log` call via a `LogProcessor`.
- Entries are serialized as **NDJSON** and POSTed to the plugin's dev-server sink (`/@dxos-plugin-log/sink`, not the HMR WebSocket), which appends them to **`packages/apps/composer-app/app.log`**. The file is truncated when the dev server starts.
- Third-party plugin code hosted inside Composer imports `@dxos/log` from the host, so its logs land in the same `app.log`.
- Query the log with `node scripts/query-logs.mjs packages/apps/composer-app/app.log -q <filter> -g <regex>`. See the `logging` skill for the full filter syntax (levels, `path:level`, `!exclude`, `-q` OR / `-g` AND).
- Node-side code (tests, CLI, server): `@dxos/log` works identically; set `LOG_FILTER=debug` for stdout capture in vitest runs. Node vitest also writes an NDJSON file sink at **`<package>/test.log`** (path is printed at run start).
- **Browser tests** (vitest browser mode, `*.browser.test.ts`, storybook) have no filesystem, so `@dxos/log` entries are POSTed to the `DxosLogPlugin` dev-server sink and appended to **`<package>/test-browser.log`** (NDJSON, same shape as `app.log`/`test.log`). Both the page realm and worker realms are covered. Filter defaults to `debug`; override with `DX_TEST_LOG_FILTER` (or `LOG_FILTER`). Query it the same way: `node scripts/query-logs.mjs <package>/test-browser.log -q debug -g '\[DEBUG H'`. This is the primary window into worker-side behavior for worker-framework browser tests.
- Composer runs client services in a **dedicated worker per tab** (a coordinator handles cross-tab exclusivity; there is no long-lived SharedWorker hosting services — `DX_SHARED_WORKER` is an opt-in exception). A plain page reload therefore picks up newly instrumented worker-side code; do NOT ask the user to close all tabs first. Worker-side logs land in the same `app.log` (the log plugin handles `?worker_file` / `?sharedworker_file` entries).
## Instrumentation rules
### Use `@dxos/log`, not `console.log` or `print`
```ts
// #region DEBUG
import { log } from '@dxos/log';
log('[DEBUG H1] frobbed check', { frobbed, ts: Date.now() });
// #endregion DEBUG
```
- **Static message first** (lowercase phrase, hypothesis tag included). No template-literal interpolation in the message string.
- **Structured context second** — dynamic values go in the object, never only in the message.
- Tag each line with `[DEBUG H<n>]` (n = hypothesis number) so instrumentation is greppable and distinct from framework logs.
- If the file does not already import `@dxos/log`, add the import inside the `#region DEBUG` block so it removes cleanly.
- **Never use `console.log`, `print`, stdout, or stderr.** All debug output goes through `@dxos/log`.
### Region markers
ALL instrumentation MUST be wrapped in region blocks for clean removal:
```text
// #region DEBUG (JS/TS/Java/C#/Go/Rust/C/C++)
# #region DEBUG (Python/Ruby/Shell/YAML)
<!-- #region DEBUG --> (HTML/Vue/Svelte)
-- #region DEBUG (Lua)
...instrumentation...
// #endregion DEBUG (matching closer)
```
### Be minimal
Log only what confirms or rules out the hypothesis — variable states, execution
paths, timing, decision points. Prune aggressively; `app.log` is noisy with
existing framework logs.
## Capture cycle
1. **Rotate the sink before each reproduction** — `app.log` only self-truncates on dev-server restart, so clear it between iterations, but move the previous capture aside rather than destroying it (the run you are about to overwrite may hold the only evidence of an intermittent failure):
```bash
mv packages/apps/composer-app/app.log "$(mktemp packages/apps/composer-app/app.log.XXXXXX)" && touch packages/apps/composer-app/app.log
```
**Always rotate to a unique destination.** A fixed name (`app.log.prev`) clobbers the previous capture on the second iteration, which is exactly the evidence loss the rotation exists to prevent; `mktemp` allocates the destination atomically, so back-to-back rotations cannot collide the way a timestamp suffix can.
**`touch`, never `: >`.** The dev-server sink appends by path (`fs.appendFile`), reopening the file per write, so it recreates `app.log` on its own after the `mv`; truncating instead would wipe any lines it already wrote in the window between the two commands.
**Node tests rotate only between runs.** The node file processor holds an open fd (`openSync(path, 'a')`), so a rotation during a live run follows the inode — output keeps landing in the rotated file while the new `test.log` stays empty. Rotate `<package>/test.log` (node) or `<package>/test-browser.log` (browser) with the same unique-destination rule, but do it between runs, and re-run the test yourself each iteration.
The log is shared with whoever else is attached to that dev server — never delete a sink you did not create, and if a capture predates your session, keep it.
2. Reproduce (yourself via browser tools whenever possible — see `diagnosing-ui`).
3. **Check size first** (`wc -l`), then extract only your lines:
```bash
node scripts/query-logs.mjs packages/apps/composer-app/app.log -q debug -g '\[DEBUG H'
```
Narrow further as needed:
```bash
node scripts/query-logs.mjs packages/apps/composer-app/app.log -q debug -g '\[DEBUG H2'
node scripts/query-logs.mjs packages/apps/composer-app/app.log -q 'debug,!rpc.ts' -g '\[DEBUG H'
```
Output columns: `timestamp`, level letter, `file:line`, scope, message, context, error. The `f`/`n` NDJSON fields give file:line; `c` carries structured context; `o` carries scope.
## Cleanup
- **Never remove instrumentation before the fix is verified** in the reporting environment.
- Once verified: remove all `#region DEBUG` blocks and their contents (Grep for `#region DEBUG` across touched files). Do not delete `app.log` itself — it's the standard dev log.
## Related skills
- `diagnosing-bugs` — the governing diagnosis loop (Phase 4 is where this skill is used).
- `diagnosing-ui` — the UI branch (isolation ladder, verification contract, interaction budget).
- `logging` — full `@dxos/log` reference (levels, `dbg`, NDJSON shape) and `query-logs.mjs` filter syntax.
Workflow inspiration: [doraemonkeys/claude-code-debug-mode](https://github.com/doraemonkeys/claude-code-debug-mode) (generic HTTP-endpoint version). This repo's adaptation uses the existing `@dxos/log` → `app.log` pipeline instead of a bespoke endpoint.From wittjosiah/agent-skills, MIT.
More from wittjosiah/agent-skills
- 0.567score
converge
wittjosiah
Loop interrogate review-and-fix rounds on one PR until a round has no Act On items.
SkillAFreshness: AClaude Code +9 - 0.528score
handoff
wittjosiah
Compact the current conversation into a handoff prompt the user pastes into another agent.
SkillAFreshness: AClaude Code +9 - 0.524score
diagnosing-ui
wittjosiah
UI branch of the diagnosing loop.
SkillBFreshness: BClaude Code +9 - 0.524score
dxos-code-style
wittjosiah
DXOS TypeScript authoring conventions.
SkillBFreshness: BClaude Code +9 - 0.501score
architect
wittjosiah
Sketch types, signatures, and module structure before code, then stay in the loop while implementation fills in.
SkillBFreshness: BClaude Code +9 - 0.501score
interrogate
wittjosiah
Use for "interrogate", "adversarial review", "multi-model review", "challenge this", "stress test this code", "find blind spots", or "tear this apart".
SkillBFreshness: BClaude Code +9 - 0.499score
domain-modeling
wittjosiah
Build and sharpen a project's domain model.
SkillBFreshness: BClaude Code +9 - 0.499score
code-review
wittjosiah
Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes: Standards (does the code follow this repo's documented coding…
SkillBFreshness: BClaude Code +9 - 0.499score
grilling
wittjosiah
Grill the user relentlessly about a plan, decision, or idea.
SkillBFreshness: BClaude Code +9 - 0.499score
codebase-design
wittjosiah
Shared vocabulary for designing deep modules.
SkillBFreshness: BClaude Code +9 - 0.499score
diagnosing-bugs
wittjosiah
Diagnosis loop for hard bugs and regressions.
SkillBFreshness: BClaude Code +9 - 0.496score
arena
wittjosiah
Spawn N parallel candidates at the same task, pick a base, graft the strongest parts of the losers into it.
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 24, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/wittjosiah/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from wittjosiah
- 0.567score
converge
wittjosiah
Loop interrogate review-and-fix rounds on one PR until a round has no Act On items.
SkillAFreshness: AClaude Code +9 - 0.528score
handoff
wittjosiah
Compact the current conversation into a handoff prompt the user pastes into another agent.
SkillAFreshness: AClaude Code +9 - 0.524score
diagnosing-ui
wittjosiah
UI branch of the diagnosing loop.
SkillBFreshness: BClaude Code +9 - 0.524score
dxos-code-style
wittjosiah
DXOS TypeScript authoring conventions.
SkillBFreshness: BClaude Code +9 - 0.501score
architect
wittjosiah
Sketch types, signatures, and module structure before code, then stay in the loop while implementation fills in.
SkillBFreshness: BClaude Code +9 - 0.501score
interrogate
wittjosiah
Use for "interrogate", "adversarial review", "multi-model review", "challenge this", "stress test this code", "find blind spots", or "tear this apart".
SkillBFreshness: BClaude Code +9
Cite this page
instrumentation skill. Agent Mart. https://agentmart.dev/skills/wittjosiah-instrumentation (last updated 2026-10-24)