This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Agentic Code Optimization. Elevated Agent Experience.
CodeOptiX is an agentic code optimization platform that evaluates, reflects on, and evolves the behavior of coding AI agents (Claude Code, Codex, Gemini CLI). It uses a workflow of Observe → Evaluate → Reflect → Evolve with multi-modal evaluation (static analysis + LLM judgment + test results).
# Install with dev dependencies
pip install -e ".[dev,docs]"
# OR with uv (faster)
uv sync --dev --extra docs
# Run all tests
pytest
# Run single test file
pytest tests/test_evaluation.py
# Run with coverage
pytest --cov=codeoptix --cov-report=html
# Format code
ruff format .
# Lint code
ruff check .
# Type check
mypy src/codeoptix
# Security check
bandit -r src/codeoptix
# Pre-commit hooks
pre-commit install
pre-commit run --all-files
# Run CLI evaluation
codeoptix eval --agent claude-code --behaviors insecure-code --llm-provider openai
# CI mode (fails on issues)
codeoptix ci --agent claude-code --behaviors insecure-code --fail-on-failureThe codebase follows a modular engine-based architecture:
-
Adapters (
src/codeoptix/adapters/): Standardized interface for coding agents.AgentAdapterbase class withClaudeCodeAdapter,CodexAdapter,GeminiCLIAdapterimplementations. Usecreate_adapter()factory. -
Behaviors (
src/codeoptix/behaviors/): Modular behavior definitions for evaluation.BehaviorSpecbase class with built-inInsecureCodeBehavior,VacuousTestsBehavior,PlanDriftBehavior. Usecreate_behavior()factory. -
Evaluation Engine (
src/codeoptix/evaluation/): Orchestrates multi-modal evaluation.EvaluationEnginecoordinatesScenarioGenerator,StaticAnalyzer,LLMEvaluator,TestRunner. -
Reflection Engine (
src/codeoptix/reflection/): Analyzes results and generates insights. Produces markdown reports with actionable recommendations. -
Evolution Engine (
src/codeoptix/evolution/): GEPA-style prompt optimization.EvolutionEngineusesPromptProposerto generate and evaluate prompt mutations. -
Linters (
src/codeoptix/linters/): Multi-linter orchestration viaLinterRunner. Individual linters (Ruff, Bandit, MyPy, etc.) extendBaseLinter. -
ACP (
src/codeoptix/acp/): Agent Client Protocol integration for editor workflows.
- Factory pattern:
create_adapter(),create_behavior(),create_llm_client() - Abstract base classes: Extend
AgentAdapter,BehaviorSpec,BaseLinterfor customization - Configuration-driven: All engines accept config dictionaries
- LLM provider abstraction: Supports Anthropic, OpenAI, Google, Ollama via
LLMClient
- Agent adapter executes task → returns
AgentOutput(code, tests, traces) - Behaviors evaluate output → return
BehaviorResult(passed, score, evidence, severity) - Evaluation engine aggregates results → stores via
ArtifactManager - Reflection engine analyzes → generates markdown insights
- Evolution engine proposes → iterates on prompts
Main CLI is in src/codeoptix/cli.py. Commands: eval, ci, reflect, evolve, lint, acp.
from codeoptix.adapters.factory import create_adapter
from codeoptix.evaluation import EvaluationEngine
from codeoptix.reflection import ReflectionEngine
from codeoptix.evolution import EvolutionEngine
from codeoptix.utils.llm import create_llm_client, LLMProviderSupports multiple providers via the --llm-provider flag or LLMProvider enum:
openai- GPT-4, GPT-4oanthropic- Claude modelsgoogle- Gemini modelsollama- Local models (no API key required)
Tests are in tests/ with pytest. Fixtures in conftest.py. Run specific tests with pytest tests/test_<module>.py -v.