| name | agentcrumbs |
| description | Debug mode for AI coding agents. Drop structured traces inline while writing code, query them when something breaks, strip before merge. Covers the core workflow: trail, crumb, markers, collector, query, strip. Activate when using agentcrumbs, adding debug tracing, or when an agent needs to understand runtime behavior.
|
| type | core |
| library | agentcrumbs |
| library_version | 0.2.0 |
| sources | ["triggerdotdev/trigger-labs:debug-mode/README.md","triggerdotdev/trigger-labs:debug-mode/src/trail.ts","triggerdotdev/trigger-labs:debug-mode/src/types.ts"] |
agentcrumbs
Structured debug traces that agents drop inline while writing code, then query when something breaks. Stripped before merge, zero cost when off.
Workflow
1. Write code + crumbs → crumb("user verified", { userId }); // @crumbs
2. Run with collector → agentcrumbs collect & AGENTCRUMBS=1 node app.js
3. Something breaks → agentcrumbs query --since 5m
4. Fix the bug → (read the trail, find the cause, fix it)
5. Strip before merge → agentcrumbs strip
Core API
import { trail } from "agentcrumbs";
const crumb = trail("my-service");
crumb("checkout started", { cartId: "c_91" });
crumb("cache miss", { key }, { tags: ["perf"] });
const reqCrumb = crumb.child({ requestId: req.id });
reqCrumb("handling request", { path: req.url });
const user = await crumb.scope("validate-token", async (ctx) => {
ctx.crumb("checking jwt");
return await verifyToken(token);
});
if (crumb.enabled) { crumb("dump", { state: structuredClone(big) }); }
Markers
Every crumb line needs a marker so agentcrumbs strip can remove it before merge.
crumb("event", { data });
const result = await crumb.scope("operation", async (ctx) => {
ctx.crumb("step 1");
ctx.crumb("step 2");
return value;
});
Unmarked crumbs will leak into production code. The strip command only removes lines with // @crumbs or code inside #region @crumbs blocks.
CLI quick reference
agentcrumbs collect
agentcrumbs tail
agentcrumbs tail --app foo
agentcrumbs tail --all-apps
agentcrumbs query --since 5m
agentcrumbs query --since 5m --cursor <id>
agentcrumbs clear
agentcrumbs clear --all-apps
agentcrumbs strip
agentcrumbs strip --check
agentcrumbs --help
Most commands accept --app <name> and --all-apps. Default is auto-detect from package.json.
Querying crumbs
IMPORTANT: Query broadly, paginate — don't filter narrowly. The value of crumbs is seeing what happened across ALL services, not just one. Filtering to a single namespace or adding match filters defeats the purpose — you'll miss the cross-service interactions that reveal the real bug.
The right approach:
- Query a time window with no namespace filter
- Read the first page of results
- Use
--cursor to paginate forward if you need more
agentcrumbs query --since 5m
agentcrumbs query --since 5m --cursor a1b2c3d4
agentcrumbs query --after 2026-03-11T14:00:00Z --before 2026-03-11T14:01:00Z
agentcrumbs query --since 5m --limit 25
agentcrumbs query --session a1b2c3
Results are paginated (50 per page by default). When there are more results, the output includes a short --cursor ID for the next page.
Run agentcrumbs <command> --help for detailed options on any command.
Enable tracing
Node.js: Set the AGENTCRUMBS environment variable:
AGENTCRUMBS=1 node app.js
AGENTCRUMBS='{"ns":"auth-*"}' node app.js
Browser: Use configure() instead (no env vars in browsers):
import { configure, trail } from "agentcrumbs";
configure("*");
const crumb = trail("ui");
Bundlers (Vite, webpack, esbuild, Next.js) auto-resolve to the browser build. Same import path.
When tracing is not enabled, trail() returns a frozen noop. No conditionals, no overhead.
App isolation
Every crumb is stamped with an app name. This keeps crumbs from different projects separate — storage, CLI queries, and tail all scope to the current app by default.
App name resolution (first match wins):
app field in AGENTCRUMBS JSON config: AGENTCRUMBS='{"app":"my-app","ns":"*"}'
AGENTCRUMBS_APP env var
- Auto-detected from the nearest
package.json name field
Crumbs are stored per-app at ~/.agentcrumbs/<app>/crumbs.jsonl.
agentcrumbs tail
agentcrumbs tail --app my-app
agentcrumbs tail --all-apps
agentcrumbs stats --all-apps
Critical mistakes
- Over-filtering queries — Do NOT add
--ns or --match filters to narrow results. Use --limit and --cursor to paginate instead. Filtering to one namespace hides cross-service bugs. If there are too many results, narrow the time window or reduce --limit, not the namespaces.
- Missing markers — Every crumb line needs
// @crumbs or a #region @crumbs block. Without them, strip can't clean up.
- Creating trail() in hot paths —
trail() parses config each call. Create once at module scope, use child() for per-request context.
- Forgetting configure() in the browser — In browser apps, call
configure("*") before any trail() calls. Without it, all namespaces are disabled.
- No collector running — Without
agentcrumbs collect, crumbs go to stderr only and can't be queried. Start the collector before reproducing issues.
Further discovery
- CLI details:
agentcrumbs --help and agentcrumbs <command> --help
- TypeScript types: Check the type definitions in
node_modules/agentcrumbs/dist/index.d.ts
- Docs: https://agentcrumbs.dev/docs
- Sessions and tags:
crumb.session() for grouping, { tags: [...] } as third arg for filtering
- Testing:
import { MemorySink, addSink } from "agentcrumbs" to capture crumbs in tests
- Scopes:
crumb.scope(), crumb.wrap(), crumb.snapshot(), crumb.assert() for structured tracing