Skip to content

Commit 37e25ca

Browse files
committed
Add dedicated CLAUDE.md files for every component
1 parent c1991ef commit 37e25ca

File tree

7 files changed

+528
-1
lines changed

7 files changed

+528
-1
lines changed

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,5 @@ Each component uses:
117117
- Add @author tags to newly introduced classes by the user
118118
- Prefer classic if statements over short-circuit evaluation when possible
119119
- Define array shapes for parameters and return types
120-
- Use project specific exceptions instead of global exception classes like \RuntimeException, \InvalidArgumentException etc.
120+
- Use project specific exceptions instead of global exception classes like \RuntimeException, \InvalidArgumentException etc.
121+
- NEVER mention Claude as co-author in commits

demo/CLAUDE.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a Symfony 7.3 demo application showcasing AI integration capabilities using Symfony AI components. The application demonstrates various AI use cases including RAG (Retrieval Augmented Generation), streaming chat, multimodal interactions, and MCP (Model Context Protocol) server functionality.
8+
9+
## Architecture
10+
11+
### Core Components
12+
- **Chat Systems**: Multiple specialized chat implementations in `src/` (Blog, YouTube, Wikipedia, Audio, Stream)
13+
- **Twig LiveComponents**: Interactive UI components using Symfony UX for real-time chat interfaces
14+
- **AI Agents**: Configured agents with different models, tools, and system prompts
15+
- **Vector Store**: ChromaDB integration for embedding storage and similarity search
16+
- **MCP Tools**: Model Context Protocol tools for extending agent capabilities
17+
18+
### Key Technologies
19+
- Symfony 7.3 with UX components (LiveComponent, Turbo, Typed)
20+
- OpenAI GPT-4o-mini models and embeddings
21+
- ChromaDB vector database
22+
- FrankenPHP runtime
23+
- Docker Compose for ChromaDB service
24+
25+
## Development Commands
26+
27+
### Environment Setup
28+
```bash
29+
# Start ChromaDB service
30+
docker compose up -d
31+
32+
# Install dependencies
33+
composer install
34+
35+
# Set OpenAI API key
36+
echo "OPENAI_API_KEY='sk-...'" > .env.local
37+
38+
# Initialize vector store
39+
symfony console app:blog:embed -vv
40+
41+
# Test vector store
42+
symfony console app:blog:query
43+
44+
# Start development server
45+
symfony serve -d
46+
```
47+
48+
### Testing
49+
```bash
50+
# Run all tests
51+
vendor/bin/phpunit
52+
53+
# Run specific test
54+
vendor/bin/phpunit tests/SmokeTest.php
55+
56+
# Run with coverage
57+
vendor/bin/phpunit --coverage-text
58+
```
59+
60+
### Code Quality
61+
```bash
62+
# Fix code style (uses PHP CS Fixer via Shim)
63+
vendor/bin/php-cs-fixer fix
64+
65+
# Static analysis
66+
vendor/bin/phpstan analyse
67+
```
68+
69+
### MCP Server
70+
```bash
71+
# Start MCP server
72+
symfony console mcp:server
73+
74+
# Test MCP server (paste in terminal)
75+
{"method":"tools/list","jsonrpc":"2.0","id":1}
76+
```
77+
78+
## Configuration Structure
79+
80+
### AI Configuration (`config/packages/ai.yaml`)
81+
- **Agents**: Multiple pre-configured agents (blog, stream, youtube, wikipedia, audio)
82+
- **Platform**: OpenAI integration with API key from environment
83+
- **Store**: ChromaDB vector store for similarity search
84+
- **Indexer**: Text embedding model configuration
85+
86+
### Chat Implementations
87+
Each chat type follows the pattern:
88+
- `Chat` class: Handles message flow and session management
89+
- `TwigComponent` class: LiveComponent for UI interaction
90+
- Agent configuration in `ai.yaml`
91+
92+
### Session Management
93+
Chat history stored in Symfony sessions with component-specific keys (e.g., 'blog-chat', 'stream-chat').
94+
95+
## Development Notes
96+
97+
- Uses PHP 8.4+ with strict typing and modern PHP features
98+
- All AI agents use OpenAI GPT-4o-mini by default
99+
- Vector embeddings use OpenAI's text-ada-002 model
100+
- ChromaDB runs on port 8080 (mapped from container port 8000)
101+
- Application follows Symfony best practices with dependency injection
102+
- LiveComponents provide real-time UI updates without custom JavaScript
103+
- MCP server enables tool integration for AI agents

examples/CLAUDE.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is the examples directory of the Symfony AI monorepo, containing standalone examples demonstrating component usage across different AI platforms. The examples serve as both reference implementations and integration tests.
8+
9+
## Development Commands
10+
11+
### Setup
12+
```bash
13+
# Install dependencies
14+
composer install
15+
16+
# Link local AI components for development
17+
../link
18+
19+
# Start Docker services for store examples
20+
docker compose up -d
21+
```
22+
23+
### Running Examples
24+
25+
#### Standalone Examples
26+
```bash
27+
# Run a specific example
28+
php openai/chat.php
29+
30+
# Run with verbose output to see HTTP and tool calls
31+
php openai/toolcall-stream.php -vvv
32+
```
33+
34+
#### Example Runner
35+
```bash
36+
# Run all examples in parallel
37+
./runner
38+
39+
# Run examples from specific subdirectories
40+
./runner openai mistral
41+
42+
# Filter examples by name pattern
43+
./runner --filter=toolcall
44+
```
45+
46+
### Environment Configuration
47+
Examples require API keys configured in `.env.local`. Copy from `.env` template and add your keys for the platforms you want to test.
48+
49+
## Architecture
50+
51+
### Directory Structure
52+
- Each subdirectory represents a different AI platform (openai/, anthropic/, gemini/, etc.)
53+
- `misc/` contains cross-platform examples
54+
- `rag/` contains RAG (Retrieval Augmented Generation) examples
55+
- `toolbox/` contains utility tools and integrations
56+
- `bootstrap.php` provides common setup and utilities for all examples
57+
58+
### Common Patterns
59+
- All examples use the shared `bootstrap.php` for setup
60+
- Examples follow a consistent structure with platform-specific clients
61+
- Verbose output (`-vv`, `-vvv`) shows detailed HTTP requests and responses
62+
- Examples demonstrate both synchronous and streaming capabilities
63+
64+
### Dependencies
65+
Examples use `@dev` versions of Symfony AI components:
66+
- `symfony/ai-platform`
67+
- `symfony/ai-agent`
68+
- `symfony/ai-store`
69+
70+
## Testing
71+
Examples serve as integration tests. The runner executes them in parallel to verify all components work correctly across different platforms.

src/agent/CLAUDE.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in the Agent component.
4+
5+
## Component Overview
6+
7+
The Agent component provides a framework for building AI agents that interact with users and perform tasks. It sits on top of the Platform component and optionally integrates with the Store component for memory capabilities.
8+
9+
## Architecture
10+
11+
The Agent component follows a processor-based architecture:
12+
13+
### Core Classes
14+
- **Agent** (`src/Agent.php`): Main agent class that orchestrates input/output processing
15+
- **AgentInterface** (`src/AgentInterface.php`): Contract for agent implementations
16+
- **Chat** (`src/Chat.php`): High-level chat interface with conversation management
17+
- **Input/Output** (`src/Input.php`, `src/Output.php`): Data containers for processing pipeline
18+
19+
### Processing Pipeline
20+
- **InputProcessorInterface** (`src/InputProcessorInterface.php`): Contract for input processors
21+
- **OutputProcessorInterface** (`src/OutputProcessorInterface.php`): Contract for output processors
22+
23+
### Key Features
24+
- **Memory System** (`src/Memory/`): Conversation memory with embedding support
25+
- **Toolbox** (`src/Toolbox/`): Tool integration for function calling capabilities
26+
- **Structured Output** (`src/StructuredOutput/`): Support for typed responses
27+
- **Message Stores** (`src/Chat/MessageStore/`): Persistence for chat conversations
28+
29+
## Development Commands
30+
31+
### Testing
32+
```bash
33+
# Run all tests
34+
vendor/bin/phpunit
35+
36+
# Run specific test
37+
vendor/bin/phpunit tests/AgentTest.php
38+
39+
# Run tests with coverage
40+
vendor/bin/phpunit --coverage-html coverage/
41+
```
42+
43+
### Code Quality
44+
```bash
45+
# Static analysis (from component directory)
46+
vendor/bin/phpstan analyse
47+
48+
# Code style fixing (from monorepo root)
49+
cd ../../.. && vendor/bin/php-cs-fixer fix src/agent/
50+
```
51+
52+
## Component-Specific Architecture
53+
54+
### Input/Output Processing Chain
55+
The agent uses a middleware-like pattern:
56+
1. Input processors modify requests before sending to the platform
57+
2. Platform processes the request
58+
3. Output processors modify responses before returning
59+
60+
### Built-in Processors
61+
- **SystemPromptInputProcessor**: Adds system prompts to conversations
62+
- **ModelOverrideInputProcessor**: Allows runtime model switching
63+
- **MemoryInputProcessor**: Adds conversation context from memory providers
64+
65+
### Memory Providers
66+
- **StaticMemoryProvider**: Simple in-memory storage
67+
- **EmbeddingProvider**: Vector-based semantic memory using Store component
68+
69+
### Tool Integration
70+
The Toolbox system enables function calling:
71+
- Tools are auto-discovered via attributes
72+
- Fault-tolerant execution with error handling
73+
- Event system for tool lifecycle management
74+
75+
## Dependencies
76+
77+
The Agent component depends on:
78+
- **Platform component**: Required for AI model communication
79+
- **Store component**: Optional, for embedding-based memory
80+
- **Symfony components**: HttpClient, Serializer, PropertyAccess, Clock
81+
82+
## Testing Patterns
83+
84+
- Use `MockHttpClient` for HTTP mocking instead of response mocking
85+
- Test processors independently from the main Agent class
86+
- Use fixtures from `/fixtures` for multimodal content testing
87+
- Prefer `self::assert*` over `$this->assert*` in tests
88+
89+
## Development Notes
90+
91+
- All new classes should have `@author` tags
92+
- Use component-specific exceptions from `src/Exception/`
93+
- Follow Symfony coding standards with `@Symfony` PHP CS Fixer rules
94+
- The component is marked as experimental and subject to BC breaks

0 commit comments

Comments
 (0)