Trace capture for Claude Code sessions - sync to PISAMA platform for analysis
Project description
pisama-claude-code
Trace capture for Claude Code sessions with token usage and cost tracking.
Installation
pip install pisama-claude-code
Quick Start
# Install capture hooks
pisama-cc install
# View recent traces
pisama-cc traces
# Show token usage and cost
pisama-cc usage --by-model --by-tool
# Export traces
pisama-cc export -o traces.jsonl
Overview
Lightweight trace capture client for Claude Code. Captures tool calls, token usage, and costs. Optionally syncs to PISAMA platform for analysis.
This package captures traces. Analysis happens on the platform.
┌─────────────────────┐ ┌─────────────────────┐
│ Claude Code │ │ PISAMA Platform │
│ + pisama-cc │ ──────▶ │ (analysis) │
│ (capture) │ sync │ (detection) │
└─────────────────────┘ │ (self-healing) │
└─────────────────────┘
Features
Local Features (no platform needed)
| Feature | Description |
|---|---|
| Trace capture | Capture all tool calls (Bash, Read, Write, etc.) |
| Token tracking | Input, output, and cache tokens per call |
| Cost calculation | USD cost per trace and session totals |
| Model tracking | Track which Claude model is used |
| Local storage | SQLite + JSONL in ~/.claude/pisama/traces/ |
| Export | JSONL and gzip formats |
Platform Features (requires connection)
| Feature | Description |
|---|---|
| Failure detection | 28 MAST failure modes |
| Severity scores | Confidence and severity ratings |
| Fix suggestions | AI-powered remediation |
| Self-healing | Automatic intervention |
| Dashboard | Visual analytics |
CLI Commands
pisama-cc install # Install capture hooks to ~/.claude/hooks/
pisama-cc uninstall # Remove hooks
pisama-cc status # Show status, token totals, and cost
pisama-cc traces # View recent traces
pisama-cc traces -v # Verbose: show tokens and cost per trace
pisama-cc usage # Token usage and cost breakdown
pisama-cc usage --by-model --by-tool # Grouped breakdown
pisama-cc export -o FILE # Export to JSONL
pisama-cc export --compress # Export to gzip
pisama-cc connect # Connect to PISAMA platform
pisama-cc sync # Upload traces to platform
pisama-cc analyze # Run failure detection (requires platform)
Example Output
Status
📊 PISAMA Status
========================================
🔧 Hook Installation:
✅ pisama-capture.py
✅ pisama-pre.sh
✅ pisama-post.sh
All hooks installed
📁 Local Traces: 1400
Input tokens: 9,580
Output tokens: 79,569
Total cost: $43.22
Models: claude-opus-4-5-20251101
Usage Breakdown
📊 Token Usage Summary (last 100 traces)
==================================================
Input tokens: 10,234
Output tokens: 85,421
Cache read tokens: 1,234,567
Total tokens: 95,655
Total cost: $ 52.34
📈 By Model:
--------------------------------------------------
claude-opus-4-5-20251101 $52.34
🔧 By Tool:
--------------------------------------------------
Bash 45 calls $25.12
Read 30 calls $15.34
Write 20 calls $8.45
Edit 5 calls $3.43
Model Pricing
Supported models and pricing (per 1M tokens):
| Model | Input | Output | Cache Read |
|---|---|---|---|
| claude-opus-4-5 | $15.00 | $75.00 | $1.50 |
| claude-sonnet-4 | $3.00 | $15.00 | $0.30 |
| claude-3-5-sonnet | $3.00 | $15.00 | $0.30 |
| claude-3-5-haiku | $0.80 | $4.00 | $0.08 |
Privacy
- Traces stored locally in
~/.claude/pisama/traces/ - Secrets automatically redacted (API keys, passwords, tokens)
- File paths anonymized (home directory →
~) - Platform sync is opt-in
Requirements
- Python 3.10+
- Claude Code CLI
Configuration
After installation, add hooks to ~/.claude/settings.local.json:
{
"hooks": {
"PreToolCall": [
{
"command": "~/.claude/hooks/pisama-pre.sh",
"timeout": 2000
}
],
"PostToolCall": [
{
"command": "~/.claude/hooks/pisama-post.sh",
"timeout": 2000
}
]
}
}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pisama_claude_code-0.3.2.tar.gz.
File metadata
- Download URL: pisama_claude_code-0.3.2.tar.gz
- Upload date:
- Size: 33.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d22556a8f7013078aeda11f0b5e83ac9bea9b6b25f79f0a992702f8d24e55880
|
|
| MD5 |
17fd20cb07a68d1d92270d3a6a2aad57
|
|
| BLAKE2b-256 |
0a5b3e0882c855e8831f122615550b60d2b24bf1852b5708605b341771c6fa43
|
File details
Details for the file pisama_claude_code-0.3.2-py3-none-any.whl.
File metadata
- Download URL: pisama_claude_code-0.3.2-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34db1c03fd6242ac1e173690aace693f455e3939f976dd3627e0eec3d2770396
|
|
| MD5 |
3abc2dedebbdf85950dabacd77b0fa57
|
|
| BLAKE2b-256 |
f39b0957c7dccacc69febab9086c2693bb329b762f0376201ef19a2922b5b666
|