|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file guides AI coding agents working on `context-profiler`. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`context-profiler` is a trace-source agnostic context analysis harness for LLM agents. It accepts raw provider requests, observability traces, local coding-agent transcripts, and future benchmark trajectories, then reports how context grows, repeats, and concentrates around tools/artifacts. |
| 8 | + |
| 9 | +Core boundary: this project analyzes traces. It does not fetch traces, replay agent loops, or execute third-party tools. |
| 10 | + |
| 11 | +## Common Commands |
| 12 | + |
| 13 | +```bash |
| 14 | +# Run the smoke suite |
| 15 | +PYTHONPATH=src uv run --with pytest pytest tests/test_smoke.py -v |
| 16 | + |
| 17 | +# Check CLI entry point |
| 18 | +PYTHONPATH=src uv run context-profiler --help |
| 19 | + |
| 20 | +# Analyze a raw request |
| 21 | +PYTHONPATH=src uv run context-profiler analyze tests/fixtures/repeated_tool_calls.json --format openai |
| 22 | + |
| 23 | +# Diagnose a transcript |
| 24 | +PYTHONPATH=src uv run context-profiler diagnose tests/fixtures/cursor_transcript.jsonl --format cursor-jsonl --json |
| 25 | + |
| 26 | +# Generate HTML |
| 27 | +PYTHONPATH=src uv run context-profiler analyze tests/fixtures/cursor_transcript.jsonl --format cursor-jsonl --html /tmp/context-profiler-report.html |
| 28 | +``` |
| 29 | + |
| 30 | +## Architecture |
| 31 | + |
| 32 | +- `src/context_profiler/cli.py` — Click CLI entry point. |
| 33 | +- `src/context_profiler/formats.py` — format registry exposed to agents. |
| 34 | +- `src/context_profiler/schemas.py` — JSON Schemas for agent-readable contracts. |
| 35 | +- `src/context_profiler/validation.py` — validation and canonical normalization helpers. |
| 36 | +- `src/context_profiler/profiler.py` — session/request loading and analyzer orchestration. |
| 37 | +- `src/context_profiler/analyzers/` — token, repeat, and field analyzers. |
| 38 | +- `src/context_profiler/context_diff.py` — turn-to-turn diff evidence and hints. |
| 39 | +- `src/context_profiler/diagnostics.py` — stable issue-code diagnosis JSON. |
| 40 | +- `src/context_profiler/reporters/` — CLI, JSON, and HTML reports. |
| 41 | +- `src/context_profiler/templates/report.html` — self-contained report UI. |
| 42 | +- `skills/` — public Agent Skills distribution. |
| 43 | + |
| 44 | +## Format and Analyzer Rules |
| 45 | + |
| 46 | +- Add synthetic fixtures under `tests/fixtures/`; do not commit real private traces. |
| 47 | +- Every supported format must have metadata in `formats.py` with `input_kind`, `confidence`, `analysis_scope`, `limitations`, and `agent_conversion_guidance`. |
| 48 | +- Keep analyzer outputs evidence-first: issue code, severity, token counts, request indices, tool names, artifact keys, and recommendation. |
| 49 | +- For heuristic findings, use hint language such as `possible_*` and include confidence. |
| 50 | +- Do not overclaim exactness for `agent-transcript`; transcripts may omit hidden prompts, tool definitions, rules, and provider compaction. |
| 51 | + |
| 52 | +## Product Boundaries |
| 53 | + |
| 54 | +Do not add provider-specific fetch clients to core. Agents can use Langfuse CLI, SDKs, Hugging Face tooling, or local transcript discovery to obtain data, then pass files or stdin to `context-profiler`. |
| 55 | + |
| 56 | +Do not make Toolathlon a first-class multi-turn demo. Prefer genuinely multi-turn datasets such as `pagarsky/agent-trace`, `cx-cmu/agent_trajectories`, and SWE-agent trajectories for future research examples. |
| 57 | + |
| 58 | +## Skill Distribution |
| 59 | + |
| 60 | +Canonical public skills live in `skills/`. |
| 61 | + |
| 62 | +Do not put product-distribution skills in `.agents/skills/` or `.claude/skills/`; those directories are for project-local agent behavior. |
| 63 | + |
| 64 | +If skill paths change, update: |
| 65 | + |
| 66 | +- `.plugin/plugin.json` |
| 67 | +- `.claude-plugin/marketplace.json` |
| 68 | +- README skill distribution section |
| 69 | +- tests covering manifests |
0 commit comments