Run the example consumer:
npm run exampleWhat it does:
- creates a
shellprintinstance with default hook matchers - runs a real Agent SDK
query() - logs each emitted event through
onEvent - writes JSONL output to
shellprint-example-events.jsonl
Main example file:
Core integration pattern:
import { query } from "@anthropic-ai/claude-agent-sdk";
import { createShellPrint } from "shellprint";
const shellprint = createShellPrint({
jsonlPath: "./shellprint-example-events.jsonl",
onEvent(event) {
console.log(event.action, event.description);
},
});
const result = query({
prompt: "Research this deal...",
options: {
hooks: {
PreToolUse: [shellprint.preToolMatcher],
PostToolUse: [shellprint.postToolMatcher],
PostToolUseFailure: [shellprint.failureMatcher],
},
},
});
for await (const message of result) {
// existing handling unchanged
}
await shellprint.flush();
const events = shellprint.getEvents();