User Settings: Global Claude configuration at
~/.claude/CLAUDE.md(user-level)This file contains all project guidelines: baseline standards and project-specific configurations.
This project was generated from the cookiecutter-python-template using cruft.
MANDATORY: When working on this project, if you identify any issue that should have been addressed in the template (missing files, incorrect configurations, documentation gaps, tooling issues, etc.), you MUST:
- Add the feedback to docs/template_feedback.md
- Include:
- Issue: Clear description of what's wrong or missing
- Context: How you discovered it
- Suggested Fix: What the template should do differently
- Priority: Critical / High / Medium / Low
This feedback will be shared with the template team to improve the cookiecutter template for future projects.
Name: Audio Processor Description: Audio file conversion and processing for RAG content pipelines Author: Byron Williams byron@williamshome.family Repository: https://github.com/ByronWilliamsCPA/audio-processor Created: 2025-12-04
- Python: 3.12
- Package Manager: UV
- Code Quality: Ruff (linter/formatter), BasedPyright (type checker)
- Testing: pytest, coverage
- Security: Bandit, pip-audit
- CLI Framework: Click
- Documentation: MkDocs Material
- Containerization: Docker
- Code Quality: Ruff formatting (88 chars), Ruff linting (PyStrict-aligned), BasedPyright type checking (strict mode)
- Security: GPG/SSH key validation, dependency scanning, encrypted secrets
- Testing: Minimum 80% coverage, tiered testing approach
- Git: Conventional commits, signed commits, feature branch workflow
- Response-Aware Development: Assumption tagging and verification
When writing code, ALWAYS tag assumptions that could cause production failures:
# #CRITICAL: [category]: [assumption that could cause outages/data loss]
# #VERIFY: [defensive code required]
# Example: Payment processing, auth flows, concurrent writes
# #ASSUME: [category]: [assumption that could cause bugs]
# #VERIFY: [validation needed]
# Example: UI state, form validation, API responses
# #EDGE: [category]: [assumption about uncommon scenarios]
# #VERIFY: [optional improvement]
# Example: Browser compatibility, slow networks- Timing Dependencies: State updates, async operations, race conditions
- External Resources: API availability, file existence, network connectivity
- Data Integrity: Type safety at boundaries, null/undefined handling
- Concurrency: Shared state, transaction isolation, deadlock potential
- Security: Authentication, authorization, input validation
- Payment/Financial: Transaction integrity, retry logic, rollback handling
NEVER work directly on the main branch. Always create a feature branch before making any code changes.
# 1. Check current branch
git branch --show-current
# 2. If on main/master, create a feature branch FIRST
git checkout -b feat/{descriptive-slug}
# 3. Or for bug fixes
git checkout -b fix/{issue-or-description}| Task Type | Branch Prefix | Commit Type | Version Impact |
|---|---|---|---|
| New feature | feat/ |
feat: |
Minor (0.X.0) |
| Bug fix | fix/ |
fix: |
Patch (0.0.X) |
| Breaking change | feat/ or fix/ |
feat!: or fix!: |
Major (X.0.0) |
| Documentation | docs/ |
docs: |
No release |
| Refactoring | refactor/ |
refactor: |
No release |
| Performance | perf/ |
perf: |
Patch (0.0.X) |
| Testing | test/ |
test: |
No release |
| Chore/maintenance | chore/ |
chore: |
No release |
ALWAYS create a new branch when:
- Starting ANY implementation task - Never commit directly to
mainordevelop - TODO item involves code changes - Each feature/fix should have its own branch
- Multiple independent features - Create separate branches for parallel work
- User explicitly requests a feature/fix - Branch immediately before coding
Note: The primary branch is main (not master).
Claude MUST adopt a security-first approach in all development:
When working on this project, always suggest appropriate security measures:
- Dependencies: Suggest vulnerability scanning (
pip-audit) - APIs: Suggest authentication, rate limiting, input validation
- Data: Suggest encryption at rest and in transit, access controls
- Containers: Suggest image vulnerability scanning (Trivy)
- ALL security findings from scanners (Semgrep, SonarQube, Bandit, Checkov) should be addressed, not dismissed
- If a finding is a false positive, document WHY with inline comments
- Use baseline files only for truly unavoidable exceptions with justification
- Treat linting warnings as errors to fix, not ignore
- Address ALL type checker warnings, not just errors
- Don't accumulate technical debt by deferring quality issues
- Security scanners: fail on HIGH/CRITICAL by default
- Type checking: strict mode (already configured)
- Linting: no ignored rules without documented reason
For deployment on FIPS-enabled systems (Ubuntu LTS with fips-updates, government systems, healthcare, finance):
Prohibited algorithms (will fail in FIPS mode):
- MD5, MD4, SHA-1 (for security purposes)
- DES, 3DES, RC2, RC4, Blowfish
- Non-approved key exchange methods
Required patterns:
# ✗ WRONG - Will fail on FIPS systems
import hashlib
h = hashlib.md5(data)
# ✓ CORRECT - Non-security use is allowed
h = hashlib.md5(data, usedforsecurity=False)
# ✓ CORRECT - Use FIPS-approved algorithms for security
h = hashlib.sha256(data)Check FIPS compatibility:
uv run python scripts/check_fips_compatibility.py --fix-hintsProblematic packages (need verification or replacement):
bcrypt→ Usepasslibwith PBKDF2 orargon2-cffipycrypto→ Usepycryptodomewith FIPS mode- Verify
cryptographyversion >= 3.4.6 with OpenSSL FIPS provider
BasedPyright replaces MyPy as the standard type checker (3-5x faster, stricter analysis):
- Mode:
strict(recommended) - Strict Inference:
strictListInference,strictDictionaryInference,strictSetInferenceenabled - Configuration: In
pyproject.tomlunder[tool.basedpyright]
Ruff configuration includes PyStrict-aligned rules for ultra-strict code quality:
- BLE: Blind except detection (no bare
except:orexcept Exception:) - EM: Error message best practices
- SLF: Private member access violations
- INP: Require
__init__.pyin packages - ISC: Implicit string concatenation
- PGH: Deprecated type comments, blanket ignores
- RSE: Raise statement best practices
- TID: Banned imports, relative import rules
- YTT: Python version checks
- FA: Future annotations
- T10: Debugger statements (no
breakpoint(),pdb) - G: Logging format strings
- Python: 88-char line length, comprehensive rule compliance
- Markdown: 120-char line length, consistent formatting
- YAML: 2-space indentation, 120-char line length
- Validation: Pre-commit hooks enforce all standards
Claude Code acts as the SUPERVISOR for all development tasks and MUST:
- Always Use TodoWrite Tool: Create and maintain TODO lists for ALL tasks
- Assign Tasks to Agents: Each TODO item should be assigned to a specialized agent
- Review Agent Work: Validate all agent outputs before proceeding
- Use Temporary Reference Files: Create
.tmp-prefixed files intmp_cleanup/for complex tasks - Maintain Continuity: Use reference files to preserve context across conversation compactions
- Security tasks -> Security Agent (mcp__zen__secaudit)
- Code reviews -> Code Review Agent (mcp__zen__codereview)
- Testing -> Test Engineer Agent (mcp__zen__testgen)
- Documentation -> Documentation Agent (mcp__zen__docgen)
- Debugging -> Debug Agent (mcp__zen__debug)
- Analysis -> Analysis Agent (mcp__zen__analyze)
- Refactoring -> Refactor Agent (mcp__zen__refactor)
All projects must have:
LICENSE- Open source licenseSECURITY.md- Security policy and vulnerability reportingCONTRIBUTING.md- Contribution guidelinesCHANGELOG.md- Release historyREADME.md- Project documentation
- All tests pass (80%+ coverage)
- Ruff linting (no errors)
- BasedPyright type checking
- Security scans (no high/critical)
- Pre-commit hooks pass
Any CHANGELOG entry that fixes a security vulnerability MUST include the CVE ID
if one has been assigned. Format: - fix(security): resolve CVE-YYYY-NNNNN: <brief description>
If no CVE has been assigned at release time, record the GitHub Security Advisory ID and update the entry when a CVE is allocated.
Security First -> Quality Standards -> Documentation -> Testing -> Collaboration
- Security First: Always validate keys, encrypt secrets, scan dependencies
- Reuse First: Check existing repositories for solutions before building new code
- Configure, Don't Build: Prefer configuration and orchestration over custom implementation
- Quality Standards: Maintain consistent code quality across all projects
- Documentation: Keep documentation current and well-formatted
- Testing: Maintain high test coverage and run tests before commits
- Collaboration: Use consistent Git workflows and clear commit messages
Before committing ANY changes, ensure:
- Working on appropriate feature branch (not main/develop)
- Branch follows
{type}/{descriptive-slug}convention - TodoWrite used for task tracking
- File-specific linter has been run and passes
- Pre-commit hooks execute successfully
- No linting warnings or errors remain
- Code formatting is consistent with project standards
- Security scanning shows no vulnerabilities
Coverage & Quality:
- Test coverage: Minimum 80%
- All linters must pass:
uv run ruff check .,uv run basedpyright src/ - Security scans:
uv run bandit -r src,uv run pip-audit
First-Time Setup: If planning documents show "Awaiting Generation", see the Project Setup Guide.
Planning Documents (in docs/planning/):
- project-vision.md - Problem, solution, scope, success metrics
- tech-spec.md - Architecture, data model, APIs, security
- roadmap.md - Phased implementation plan
- adr/ - Architecture decisions with rationale
- PROJECT-PLAN.md - Synthesized plan with git branches (after synthesis)
References:
- Complete Workflow: Project Setup Guide
- Skill Reference:
.claude/skills/project-planning/
# 1. Generate planning documents
/plan <your project description>
# 2. Synthesize into project plan
"Synthesize my planning documents into a project plan"
# 3. Review docs/planning/PROJECT-PLAN.md
# 4. Start development
/git/milestone start feat/phase-0-foundation# Load context for a task
Load from project-vision.md sections 2-3 and adr/adr-001-*.md,
then implement [feature] per tech-spec.md section [X].
# Validate code against specs
Review this code against tech-spec.md section 6 (security).
# Check phase progress
Review PROJECT-PLAN.md Phase 1 deliverables and update status.
# Initial setup
uv sync --all-extras
uv run pre-commit install
# Development cycle
uv run pytest -v # Run tests
uv run pytest --cov=src --cov-report=html # With coverage
uv run ruff format . # Format code
uv run ruff check . --fix # Lint and fix
uv run basedpyright src/ # Type check
# Before commit (all must pass)
uv run pytest --cov=src --cov-fail-under=80
uv run ruff check .
uv run basedpyright src/
uv run bandit -r src
pre-commit run --all-files
# Documentation
uv run mkdocs serve # Local preview
uv run mkdocs build # Build static site
# Docker
docker-compose up -d # Start dev environment
docker build -t audio_processor . # Build production imagesrc/audio_processor/
├── __init__.py # Package initialization
├── cli.py # CLI entry point
├── core/ # Core business logic
│ ├── __init__.py
│ ├── config.py # Configuration (Pydantic Settings)
│ └── exceptions.py # Centralized exception hierarchy
├── middleware/ # Middleware components
│ └── __init__.py
└── utils/ # Utilities
├── __init__.py
└── logging.py # Structured logging with correlation
tests/
├── unit/ # Unit tests
├── integration/ # Integration tests
├── conftest.py # Pytest fixtures
└── test_example.py # Example tests
docs/ # MkDocs documentation
├── index.md # Home page
└── ... # Additional docs
Project-Specific Patterns:
- Configuration: Use Pydantic Settings with
.envfiles - Logging: Structured logging via
src/audio_processor/utils/logging.py - Error Handling: Custom exceptions in
src/audio_processor/core/exceptions.py
Use the centralized exception hierarchy for consistent error handling:
from audio_processor.core.exceptions import (
ValidationError,
ResourceNotFoundError,
ConfigurationError,
AuthenticationError,
AuthorizationError,
ExternalServiceError,
APIError,
DatabaseError,
BusinessLogicError,
)
# Raise with context
raise ValidationError(
"Invalid email format",
field="email",
value=user_input,
)
# Handle in API endpoints
try:
process_data(input_data)
except ValidationError as e:
return {"error": str(e), "details": e.to_dict()}Exception Types:
| Exception | Use Case |
|---|---|
ConfigurationError |
Missing/invalid config |
ValidationError |
Input validation failures |
ResourceNotFoundError |
Missing resources (404) |
AuthenticationError |
Auth failures (401) |
AuthorizationError |
Permission denied (403) |
ExternalServiceError |
Third-party service failures |
APIError |
External API errors |
DatabaseError |
Database operation errors |
BusinessLogicError |
Domain rule violations |
Docstrings (Google Style):
def process_data(input_path: str, max_rows: int = 1000) -> dict[str, Any]:
"""Process data from input file.
Args:
input_path: Path to input file
max_rows: Maximum rows to process (default: 1000)
Returns:
Dictionary with processing results
Raises:
FileNotFoundError: If input file doesn't exist
ValueError: If file format is invalid
"""Use Pydantic Settings for environment-based configuration:
from pydantic_settings import BaseSettings
from pydantic import Field
class Settings(BaseSettings):
project_name: str = "Audio Processor"
log_level: str = Field(default="INFO", env="LOG_LEVEL")
debug: bool = Field(default=False, env="DEBUG")
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
settings = Settings()Full Documentation: See
~/.claude/CLAUDE.mdfor complete worktree concepts, commands, and best practices.
Project-Specific Paths:
# Worktree directory for this project
../audio_processor-worktrees/
# Quick reference commands
git worktree add ../audio_processor-worktrees/feature-name -b feature/feature-name
git worktree add ../audio_processor-worktrees/pr-42 origin/feature/pr-branch
git worktree list
git worktree remove ../audio_processor-worktrees/feature-nameRemember: Each worktree needs uv sync --all-extras after creation (worktrees share git but not virtualenvs).
uv add package-name # Production
uv add --dev package-name # Developmentuv sync --upgrade # All packages
uv sync --upgrade-package package-name # Specific packageuv run pytest tests/unit/test_example.py::test_function_name -vGitHub Actions Workflows:
- CI (
.github/workflows/ci.yml): Tests, linting, type checking - Security (
.github/workflows/security-analysis.yml): CodeQL, Bandit, pip-audit, OSV - Docs (
.github/workflows/docs.yml): Build and deploy documentation - Publish (
.github/workflows/publish-pypi.yml): PyPI release automation
Quality Gates (must pass):
- All tests pass (80% coverage)
- Ruff linting (no errors)
- BasedPyright type checking
- Security scans (no high/critical)
- Pre-commit hooks
CodeRabbit provides automated AI-powered code reviews on every pull request.
Configuration: .coderabbit.yaml
Features:
- Automatic review on PR creation
- Security vulnerability detection
- Code quality suggestions
- Path-specific review instructions
Commands:
# In PR comments:
@coderabbitai summary # Get high-level summary
@coderabbitai review # Request re-review
@coderabbitai help # Show available commandsSetup: Install the CodeRabbit GitHub App
pre-commit run --all-files # Run manually
pre-commit clean # Clean cache
pre-commit install --install-hooks # Reinstalluv lock # Regenerate lock
uv sync --all-extras # Reinstall dependencies (includes dev tools)uv run basedpyright src/ # Show type errors
# Add `# pyright: ignore[error-code]` for specific issues| Metric | Target | Notes |
|---|---|---|
| Test Suite | <30s | Full suite with coverage |
| CI Pipeline | <5min | All checks |
| Code Coverage | 80% | Enforced in CI |
This project uses a two-part standards system for safe template updates.
┌─────────────────┐ cruft update ┌──────────────────┐
│ Template │ ──────────────────► │ .standards/ │
│ Repository │ │ (baselines) │
└─────────────────┘ └────────┬─────────┘
│
│ /merge-standards
▼
┌──────────────────┐
│ Root files │
│ (customized) │
└──────────────────┘
- Baseline files in
.standards/are updated automatically by cruft - Root files (
CLAUDE.md,REUSE.toml) contain your customizations - Merge agent helps integrate baseline changes into your files
# 1. Check for template updates
cruft check
# 2. View what would change
cruft diff
# 3. Update (baselines in .standards/ will be updated automatically)
cruft update --skip CLAUDE.md --skip REUSE.toml --skip docs/template_feedback.md
# 4. Check if baselines changed
git diff .standards/
# 5. If baselines changed, merge them into your root files
/merge-standards
# Or ask Claude: "Merge the updated baseline standards"These contain project-specific customizations:
CLAUDE.md- Your project guidelines (merge from.standards/CLAUDE.baseline.md)REUSE.toml- Your licensing annotations (merge from.standards/REUSE.baseline.toml)docs/template_feedback.md- Project-specific template feedbackdocs/planning/*- Project planning documents.env- Environment configuration
.standards/*- Baseline files (merge into root files after update).github/workflows/*- CI/CD workflowspyproject.toml- Review changes, may need manual merge- Tool configs - Usually safe to update
| Baseline | Merges Into | Purpose |
|---|---|---|
.standards/CLAUDE.baseline.md |
CLAUDE.md |
Development standards |
.standards/REUSE.baseline.toml |
REUSE.toml |
SPDX licensing |
See .standards/README.md for detailed merge instructions.
- Project README: README.md
- Contributing Guide: CONTRIBUTING.md
- Security Policy: SECURITY.md
- Template Feedback: docs/template_feedback.md
- UV Documentation: https://docs.astral.sh/uv/
- Ruff Documentation: https://docs.astral.sh/ruff/
Use the right model for each task to balance quality and cost:
| Task type | Model | When |
|---|---|---|
| Architecture, planning, ADRs | Opus 4.7 | Multi-step decisions, deep code review |
| Standard development | Sonnet 4.6 | Most coding and editing |
| Read-only exploration | Haiku 4.5 | File scanning, quick lookups |
Per-agent model defaults and orchestration patterns: see
~/.claude/.claude/rules/supervisor.md
The following global rule files govern behavior in this project. Consult them when the relevant situation arises; the brief notes below describe the scope of each.
| Rule file | Scope |
|---|---|
~/.claude/.claude/rules/writing.md |
AI pattern blacklist, grammar authority, full writing rules |
~/.claude/.claude/rules/git-workflow.md |
Branch naming, worktree patterns, commit conventions |
~/.claude/.claude/rules/python.md |
Python linting gates, function quality, BasedPyright config |
~/.claude/.claude/rules/testing.md |
Testing scope, root-cause order, golden file protection |
~/.claude/.claude/rules/supervisor.md |
Agent assignment patterns, model selection per agent |
Last Updated: 2025-12-05 Template Version: 0.1.0