Skip to main content

Tools for managing Claude Code conversations and projects

Project description

Claude Code Feedback Extractor

Extract user feedback from Claude Code conversation history for retrospective analysis.

Installation

# Clone repository
git clone <repo-url>
cd claudeutils

# Install with uv
uv tool install .

Usage

Basic Commands

# List all conversation sessions
uv run claudeutils list

# Extract feedback from a specific session (by prefix)
uv run claudeutils extract e12d203f

# Extract to file
uv run claudeutils extract e12d203f --output feedback.json

# Use custom project directory
uv run claudeutils list --project /path/to/project
uv run claudeutils extract abc123 --project /path/to/project

Token Counting

Count tokens in files using the Anthropic API. Requires ANTHROPIC_API_KEY environment variable.

# Count tokens in a single file
uv run claudeutils tokens sonnet prompt.md

# Count tokens across multiple files
uv run claudeutils tokens opus file1.md file2.md

# JSON output format
uv run claudeutils tokens haiku prompt.md --json

# Use full model ID instead of alias
uv run claudeutils tokens claude-sonnet-4-5-20250929 prompt.md

Supported model aliases:

  • haiku - Latest Claude Haiku model
  • sonnet - Latest Claude Sonnet model
  • opus - Latest Claude Opus model

Aliases automatically resolve to the latest available model version (cached for 24 hours). You can also use full model IDs like claude-sonnet-4-5 or claude-sonnet-4-5-20250929.

Feedback Processing Pipeline

Process feedback in stages: collect → analyze → rules

# Step 1: Collect feedback from ALL sessions into one file
uv run claudeutils collect --output all_feedback.json

# Step 2: Analyze - filter noise and categorize
uv run claudeutils analyze --input all_feedback.json
# Output: total count, filtered count, category breakdown

# Step 3: Extract rule-worthy items (sorted, deduplicated)
uv run claudeutils rules --input all_feedback.json --format json

# Pipeline with stdin (no intermediate files)
uv run claudeutils collect | uv run claudeutils analyze -
uv run claudeutils collect | uv run claudeutils rules --input -

Categories (from analyze)

  • instructions - Directives: "don't", "never", "always", "must", "should"
  • corrections - Fixes: "no", "wrong", "incorrect", "fix", "error"
  • process - Workflow: "plan", "next step", "workflow", "before", "after"
  • code_review - Quality: "review", "refactor", "improve", "clarity"
  • preferences - Other substantive feedback

Filtering (automatic)

Noise removed: command output, bash stdout, system messages, short messages (<10 chars)

Rules command applies stricter filters: removes questions ("How..."), long items (>1000 chars), and deduplicates by content prefix.

Features

  • Session listing: Display top-level sessions with titles and timestamps
  • Prefix matching: Extract sessions by partial UUID prefix (e.g., e12d203f)
  • Recursive extraction: Automatically processes sub-agent sessions
  • Trivial filtering: Filters out single-character responses and common keywords
  • Token counting: Count tokens in files using Anthropic API with automatic model alias resolution
  • Structured output: JSON format with full metadata
  • Type-safe: Pydantic validation with strict mypy checking

Data Model

class FeedbackType(StrEnum):
    TOOL_DENIAL = "tool_denial"     # User denied tool execution
    INTERRUPTION = "interruption"   # User interrupted agent
    MESSAGE = "message"             # User message/feedback

class FeedbackItem(BaseModel):
    timestamp: str                  # ISO 8601 format
    session_id: str                 # UUID or agent ID
    feedback_type: FeedbackType
    content: str                    # User's message/feedback
    agent_id: Optional[str]         # If from sub-agent
    slug: Optional[str]             # Agent session slug
    tool_use_id: Optional[str]      # For tool denials

Development

# Run full dev cycle (format, check, test)
just dev

# Run tests only
just test

# Run linting and type checking
just check

Project Structure

src/claudeutils/
├── cli.py          # CLI entry point
├── models.py       # Pydantic models
├── paths.py        # Path encoding utilities
├── parsing.py      # Content extraction
├── discovery.py    # Session/agent discovery
├── extraction.py   # Recursive extraction
├── tokens.py       # Token counting with Anthropic API
├── tokens_cli.py   # Token counting CLI handler
└── exceptions.py   # Custom exceptions

tests/
├── test_cli_list.py
├── test_cli_extract_basic.py
├── test_cli_extract_output.py
├── test_cli_tokens.py
├── test_cli_help.py
├── test_discovery.py
├── test_parsing.py
├── test_paths.py
├── test_models.py
├── test_agent_files.py
├── test_extraction.py
├── test_tokens_count.py
├── test_tokens_resolve.py
└── test_tokens_integration.py

Implementation Notes

Built with Test-Driven Development (TDD) across 5 implementation steps:

  1. Path encoding & session discovery - Project path encoding, session listing
  2. Trivial message filter - Filter out non-substantive responses
  3. Message parsing - Extract feedback from conversation history
  4. Recursive sub-agent processing - Handle nested agent sessions
  5. CLI subcommands - User-facing interface with argparse

See agents/DESIGN_DECISIONS.md for architectural decisions and implementation patterns.

Documentation

  • START.md - Quick start guide for contributors
  • AGENTS.md - Project overview and coding standards
  • agents/DESIGN_DECISIONS.md - Architectural and implementation decisions
  • agents/TEST_DATA.md - Data types and sample entries
  • agents/ROADMAP.md - Future enhancement ideas
  • agents/code.md - TDD implementation guidelines (skill)
  • agents/commit.md - Git commit standards (skill)

Requirements

  • Python 3.14+
  • Dependencies: pydantic>=2.0, anthropic, platformdirs
  • Dev dependencies: pytest, mypy, ruff
  • Optional: ANTHROPIC_API_KEY environment variable (required for token counting)

License

[Add license here]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

claudeutils-0.0.2.tar.gz (231.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

claudeutils-0.0.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file claudeutils-0.0.2.tar.gz.

File metadata

  • Download URL: claudeutils-0.0.2.tar.gz
  • Upload date:
  • Size: 231.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for claudeutils-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bcd66177ff49b45b6d9e41b09b342194c1981e9aa626f5d47d8ca648c3b8560d
MD5 1d428d8183df25504e3f3678ae6119d7
BLAKE2b-256 b28c3d7b21f1f72b45d5f4a48db4033f95bd89238bd3f7c41aa5bb40db58ed83

See more details on using hashes here.

File details

Details for the file claudeutils-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: claudeutils-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for claudeutils-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 83e0364fbb055da7690a2baa307a29c6ee5380676a5d3b8250081a9a0aaf2a65
MD5 926ef42e68844047a85b8d435abbcc2a
BLAKE2b-256 fbb89b914bf8dc8866e37e6f432b2f74ff468bbd3106b67e7c551a179fd0da42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page