Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when programmatically creating or managing agent trajectories in TypeScript - provides TrajectoryClient for persistent storage and TrajectoryBuilder for in-memory construction
.claude/skills/majiayu000-using-trajectories-sdk/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -23% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 5% | 0% |
| case-03 | ✗→✓ | ▲ Improved | -34% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 19% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 22% | 0% |
The agent-trajectories SDK provides two APIs for programmatically capturing agent work trajectories: TrajectoryClient (persistent, async) and TrajectoryBuilder (in-memory, sync).
trail CLI instead)| Need | Use | |------|-----| | Persist trajectories to disk | TrajectoryClient | | Build trajectories in memory | TrajectoryBuilder or trajectory() | | One-liner start | trajectory('title') shorthand | | Export formats | .toMarkdown(), .toJSON(), .toTimeline(), .toPRSummary() |
bashnpm install agent-trajectories
Use when you need trajectories saved to .trajectories/ on disk.
typescriptimport { TrajectoryClient } from 'agent-trajectories/sdk'; const client = new TrajectoryClient({ defaultAgent: 'my-agent' }); await client.init(); // Required before use // Start a trajectory const session = await client.start('Implement feature X'); // Record work in chapters await session.chapter('Research'); await session.note('Found existing auth patterns'); await session.finding('Current implementation uses JWT'); await session.chapter('Implementation'); await session.decide( 'JWT vs Session tokens', 'JWT', 'Better for stateless API clients', [{ option: 'Session tokens', reason: 'Simpler but requires server state' }] ); // Complete with retrospective await session.done('Implemented JWT auth', 0.9, { approach: 'Extended existing auth module', learnings: ['JWT refresh flow needs careful error handling'], }); await client.close();
typescriptnew TrajectoryClient({ dataDir: '.trajectories', // Storage location (default) defaultAgent: 'agent-name', // Default agent for chapters autoSave: true, // Auto-persist after each operation (default) });
| Method | Description | |--------|-------------| | client.start(title) | Start new trajectory, returns session | | client.resume() | Resume active trajectory | | client.get(id) | Get trajectory by ID | | client.list(query?) | List trajectories with optional filter | | client.search(text) | Full-text search |
| Method | Description | |--------|-------------| | session.chapter(title, agent?) | Start a new chapter | | session.note(content) | Record a note | | session.finding(content) | Record a finding (medium significance) | | session.reflect(content, confidence?) | Record a reflection (high significance) | | session.error(content) | Record an error (high significance) | | session.decide(question, chosen, reasoning, alts?) | Record a decision | | session.done(summary, confidence, opts?) | Complete trajectory | | session.abandon(reason?) | Abandon trajectory |
Use when you don't need persistence - just building a trajectory data structure.
typescriptimport { TrajectoryBuilder, trajectory } from 'agent-trajectories/sdk'; // Shorthand const result = trajectory('Fix auth bug') .chapter('Investigation', 'claude') .finding('Null pointer in login handler') .decide('Fix approach', 'Add null check', 'Simplest correct fix') .done('Fixed null pointer exception', 0.95); // Export console.log(TrajectoryBuilder.create('Task') .chapter('Work', 'agent') .note('Did the thing') .toMarkdown());
Builder is synchronous and chainable. Call .done(), .complete(), or .build() to get the Trajectory object.
Both Client sessions and Builder support:
typescriptsession.toMarkdown(); // Human-readable markdown session.toJSON(); // Raw JSON data session.toJSON(true); // Compact JSON session.toTimeline(); // Chronological timeline view session.toPRSummary(); // Optimized for PR descriptions
| Mistake | Fix | |---------|-----| | Forgetting await client.init() | Always call init before using client | | Using Builder when you need persistence | Use TrajectoryClient instead | | Not calling client.close() | Always close when done | | Starting a trajectory when one is active | Complete or abandon the active one first | | Missing await on session methods | Client session methods are async |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 23,037 | 15,028 | -35% | 1 | 1 | 0% | 3,638 | 2,789 | -23% | 0 | 0 | — |
case-02 | fail→pass | 14,631 | 8,566 | -41% | 1 | 1 | 0% | 2,714 | 2,860 | +5% | 0 | 0 | — |
case-03 | fail→pass | 20,460 | 12,695 | -38% | 1 | 1 | 0% | 3,941 | 2,614 | -34% | 0 | 0 | — |
case-04 | fail→pass | 9,163 | 9,586 | +5% | 1 | 1 | 0% | 1,535 | 1,828 | +19% | 0 | 0 | — |
case-05 | pass→pass | 13,339 | 15,334 | +15% | 1 | 1 | 0% | 2,478 | 2,991 | +21% | 0 | 0 | — |
case-06 | pass→pass | 21,486 | 13,945 | -35% | 1 | 1 | 0% | 2,611 | 2,844 | +9% | 0 | 0 | — |
case-07 | fail→pass | 13,247 | 7,781 | -41% | 1 | 1 | 0% | 1,328 | 1,626 | +22% | 0 | 0 | — |
case-08 | pass→pass | 15,272 | 7,432 | -51% | 1 | 1 | 0% | 1,724 | 1,484 | -14% | 0 | 0 | — |
case-09 | fail→fail | 12,664 | 9,748 | -23% | 1 | 1 | 0% | 2,641 | 1,975 | -25% | 0 | 0 | — |
case-10 | fail→pass | 14,460 | 7,435 | -49% | 1 | 1 | 0% | 1,495 | 1,404 | -6% | 0 | 0 | — |
case-11 | fail→pass | 10,861 | 8,138 | -25% | 1 | 1 | 0% | 860 | 1,682 | +96% | 0 | 0 | — |
case-12 | fail→pass | 9,765 | 9,070 | -7% | 1 | 1 | 0% | 1,813 | 1,872 | +3% | 0 | 0 | — |
case-13 | fail→pass | 21,511 | 3,552 | -83% | 1 | 1 | 0% | 2,688 | 1,722 | -36% | 0 | 0 | — |
case-14 | fail→pass | 13,072 | 4,276 | -67% | 1 | 1 | 0% | 1,300 | 1,881 | +45% | 0 | 0 | — |
case-15 | fail→pass | 12,416 | 3,087 | -75% | 1 | 1 | 0% | 1,319 | 1,712 | +30% | 0 | 0 | — |
case-16 | fail→pass | 10,358 | 3,573 | -66% | 1 | 1 | 0% | 1,601 | 1,811 | +13% | 0 | 0 | — |
case-17 | fail→pass | 11,036 | 9,191 | -17% | 1 | 1 | 0% | 1,970 | 1,846 | -6% | 0 | 0 | — |
case-18 | fail→pass | 13,943 | 4,247 | -70% | 1 | 1 | 0% | 1,679 | 1,886 | +12% | 0 | 0 | — |
case-19 | fail→pass | 19,723 | 7,292 | -63% | 1 | 1 | 0% | 3,170 | 1,494 | -53% | 0 | 0 | — |
case-20 | fail→pass | 15,306 | 8,788 | -43% | 1 | 1 | 0% | 1,685 | 1,774 | +5% | 0 | 0 | — |
case-21 | fail→pass | 12,400 | 2,346 | -81% | 1 | 1 | 0% | 1,160 | 1,463 | +26% | 0 | 0 | — |
case-22 | fail→pass | 13,725 | 6,867 | -50% | 1 | 1 | 0% | 1,423 | 1,442 | +1% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +82 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.