### Start Backend and Frontend Servers Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/example-plan/session-manager-plan.md Installs and starts the necessary backend and frontend servers for testing. Ensure you are in the correct project directory before execution. ```bash cd backend && uvicorn app.main:app --port 8000 & cd frontend && npm run dev & sleep 5 ``` -------------------------------- ### Install and Configure Serena MCP Server Source: https://context7.com/coleam00/context-engineering-intro/llms.txt Steps to install uvx and add the Serena MCP server for semantic code analysis. Includes commands for starting, listing, getting details, and removing the server. ```bash # Install uvx (required for Serena) # On WSL/Linux: sudo snap install astral-uv --classic # Add Serena MCP server (semantic code analysis + LSP editing) claude mcp add serena -- uvx \ --from git+https://github.com/oraios/serena \ serena start-mcp-server \ --context ide-assistant \ --project $(pwd) # Manage MCP servers claude mcp list # List all configured servers claude mcp get serena # Show server details and status claude mcp remove serena # Unregister a server # Serena capabilities: # - Semantic code retrieval and analysis # - LSP-powered editing (Python, TS/JS, PHP, Go, Rust, C/C++, Java) # - Free and open-source ``` -------------------------------- ### Environment Variable Setup Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/CLAUDE.md Copies an example environment file for local development and sets production secrets using Wrangler. ```bash # Create .dev.vars file for local development based on .dev.vars.example cp .dev.vars.example .dev.vars ``` ```bash # Production secrets (via Wrangler) wrangler secret put GITHUB_CLIENT_ID wrangler secret put GITHUB_CLIENT_SECRET wrangler secret put COOKIE_ENCRYPTION_KEY wrangler secret put DATABASE_URL wrangler secret put SENTRY_DSN ``` -------------------------------- ### Example Directory Structure for Code Examples Source: https://github.com/coleam00/context-engineering-intro/blob/main/README.md This structure illustrates how to organize code examples within an 'examples/' directory. It includes patterns for CLI implementations, agent architectures, and testing setups, along with a README to explain each example. ```tree examples/ ├── README.md # Explains what each example demonstrates ├── cli.py # CLI implementation pattern ├── agent/ # Agent architecture patterns │ ├── agent.py # Agent creation pattern │ ├── tools.py # Tool implementation pattern │ └── providers.py # Multi-provider pattern └── tests/ # Testing patterns ├── test_agent.py # Unit test patterns └── conftest.py # Pytest configuration ``` -------------------------------- ### Quick Start Bash Commands Source: https://github.com/coleam00/context-engineering-intro/blob/main/README.md Commands to clone the template, set up rules, add examples, create feature requests, and generate/execute PRPs. ```bash # 1. Clone this template git clone https://github.com/coleam00/Context-Engineering-Intro.git cd Context-Engineering-Intro # 2. Set up your project rules (optional - template provided) # Edit CLAUDE.md to add your project-specific guidelines # 3. Add examples (highly recommended) # Place relevant code examples in the examples/ folder # 4. Create your initial feature request # Edit INITIAL.md with your feature requirements # 5. Generate a comprehensive PRP (Product Requirements Prompt) # In Claude Code, run: /generate-prp INITIAL.md # 6. Execute the PRP to implement your feature # In Claude Code, run: /execute-prp PRPs/your-feature-name.md ``` -------------------------------- ### INITIAL.md: Feature Request Template Example Source: https://context7.com/coleam00/context-engineering-intro/llms.txt Serves as the entry point for feature requests, detailing requirements, referencing example files and documentation, and outlining other considerations. It guides the AI on what to build and how to approach it. ```markdown ## FEATURE: Build an async web scraper using BeautifulSoup that extracts product data from e-commerce sites, handles rate limiting, and stores results in PostgreSQL. ## EXAMPLES: - examples/cli.py — Use as template for the CLI interface - examples/agent/agent.py — Pattern for agent creation and tool registration - examples/agent/providers.py — Multi-provider LLM configuration pattern Don't copy directly — use as inspiration and for best practices. ## DOCUMENTATION: - Pydantic AI docs: https://ai.pydantic.dev/ - BeautifulSoup docs: https://www.crummy.com/software/BeautifulSoup/bs4/doc/ ## OTHER CONSIDERATIONS: - Include .env.example and README with setup instructions. - Virtual environment already set up with necessary dependencies. - Use python_dotenv and load_env() for environment variables. - Handle 429 rate-limit responses with exponential backoff. ``` -------------------------------- ### Frontend Dev Server Start Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/example-plan/session-manager-plan.md Starts the frontend development server. ```bash # 4. Dev server starts npm run dev & sleep 3 ``` -------------------------------- ### Clone and Setup MCP Server Project Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/README.md Clones the context engineering repository, copies the MCP server template to a new project, installs dependencies, and sets up the Wrangler CLI for Cloudflare deployment. ```bash # Clone the context engineering repository git clone https://github.com/coleam00/Context-Engineering-Intro.git cd Context-Engineering-Intro/use-cases/mcp-server # Copy template to your new project directory python copy_template.py my-mcp-server-project # Navigate to your new project cd my-mcp-server-project # Install dependencies npm install # Install Wrangler CLI globally npm install -g wrangler # Authenticate with Cloudflare wrangler login ``` -------------------------------- ### GitHub CLI Setup and Verification Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md Commands to install, authenticate, and verify the GitHub CLI. This enables Claude to interact with GitHub repositories. ```bash # Install GitHub CLI # Visit: https://github.com/cli/cli#installation # Authenticate gh auth login # Verify setup gh repo list ``` -------------------------------- ### Install uvx and Serena MCP Server Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md Install the uvx package manager and then add the Serena MCP server for semantic code analysis and editing. This involves using `snap` for installation and a `claude mcp add` command. ```bash sudo snap install astral-uv --classic ``` ```bash # Install Serena for semantic code analysis and editing claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd) ``` -------------------------------- ### Install Dependencies Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/agents/rag_agent/README.md Install all required Python packages for the agent. ```bash pip install -r requirements.txt ``` -------------------------------- ### Frontend Dependencies Install and Build Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/example-plan/session-manager-plan.md Installs frontend dependencies, compiles TypeScript, and builds the project. ```bash # 1. Dependencies install npm install && echo "✓ Dependencies installed" # 2. TypeScript compiles npx tsc --noEmit && echo "✓ TypeScript valid" # 3. Build succeeds npm run build && echo "✓ Build successful" ``` -------------------------------- ### Install Dependencies Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/CLAUDE.md Installs all project dependencies or adds a development dependency with types. ```bash npm install # Install all dependencies ``` ```bash npm install --save-dev @types/package # Add dev dependency with types ``` -------------------------------- ### Start Docker Services for E2E Testing Source: https://github.com/coleam00/context-engineering-intro/blob/main/validation/example-validate.md Start the Docker services required for end-to-end testing. ```bash docker-compose up -d ``` -------------------------------- ### Install and Initialize Agent Browser CLI Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/example-plan/session-manager-plan.md Installs the Agent Browser CLI globally and initializes it for use. This is a prerequisite for running automated agent tests. ```bash npm install -g agent-browser agent-browser install ``` -------------------------------- ### Start Main MCP Server Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/CLAUDE.md Starts the main MCP server with OAuth authentication, accessible at http://localhost:8792/mcp. ```bash # Start main MCP server (with OAuth) wrangler dev # Available at http://localhost:8792/mcp ``` -------------------------------- ### Simple MCP Example (No Auth) Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/README.md A basic example of an MCP server that does not include authentication, useful for demonstrating core functionality. ```typescript src/simple-math.ts ``` -------------------------------- ### Start Development Service Source: https://github.com/coleam00/context-engineering-intro/blob/main/PRPs/templates/prp_base.md Starts the application service in development mode. This is typically done before running integration tests or manual checks. ```bash uv run python -m src.main --dev ``` -------------------------------- ### Development Server Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/CLAUDE.md Starts the local development server for Cloudflare Workers. ```bash wrangler dev # Start local development server ``` ```bash npm run dev # Alternative via npm script ``` -------------------------------- ### Python Examples for Data Models Source: https://github.com/coleam00/context-engineering-intro/blob/main/PRPs/templates/prp_base.md Illustrates the creation of core data models, emphasizing type safety and consistency. Includes examples for ORM models, Pydantic models, schemas, and validators. ```python Examples: - orm models - pydantic models - pydantic schemas - pydantic validators ``` -------------------------------- ### Project Setup and Configuration Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/PRPs/templates/prp_mcp_base.md Instructions for setting up the project, including copying configuration files, defining environment variables, and configuring OAuth credentials. ```yaml Task 1 - Project Setup: COPY wrangler.jsonc to wrangler-[server-name].jsonc: - MODIFY name field to "[server-name]" - ADD any new environment variables to vars section - KEEP existing OAuth and database configuration CREATE .dev.vars file (if not exists): - ADD GITHUB_CLIENT_ID=your_client_id - ADD GITHUB_CLIENT_SECRET=your_client_secret - ADD DATABASE_URL=postgresql://... - ADD COOKIE_ENCRYPTION_KEY=your_32_byte_key - ADD any domain-specific environment variables ``` -------------------------------- ### Agent Initialization and Prompt Application Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/agents/rag_agent/planning/prompts.md Demonstrates how to import and apply the system prompt and dynamic search context to an agent instance. ```python from .prompts.system_prompts import SYSTEM_PROMPT, get_search_context ``` ```python agent = Agent( model, system_prompt=SYSTEM_PROMPT, deps_type=AgentDependencies ) # Add dynamic prompt for search context agent.system_prompt(get_search_context) ``` -------------------------------- ### Define Requirements for PRP Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md Structure your `INITIAL.md` file to include FEATURE, EXAMPLES, DOCUMENTATION, and OTHER CONSIDERATIONS to guide the PRP generation. ```markdown ## FEATURE Build a user authentication system ## EXAMPLES - Authentication flow: `examples/auth-flow.js` - Similar API endpoint: `src/api/users.js` - Database schema pattern: `src/models/base-model.js` - Validation approach: `src/validators/user-validator.js` ## DOCUMENTATION - JWT library docs: https://github.com/auth0/node-jsonwebtoken - Our API standards: `docs/api-guidelines.md` ## OTHER CONSIDERATIONS - Use existing error handling patterns - Follow our standard response format - Include rate limiting ``` -------------------------------- ### Run Research Agent with Async Client Source: https://context7.com/coleam00/context-engineering-intro/llms.txt Example of using the research agent with an asynchronous HTTP client. Ensure `httpx` is installed. ```python import asyncio async def main(): async with httpx.AsyncClient() as client: deps = AgentDependencies(brave_api_key="BSA...", http_client=client) result = await research_agent.run( "Research AI safety and draft a summary email to john@example.com", deps=deps, ) print(result.data) asyncio.run(main()) ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/agents/rag_agent/README.md Copy the example environment file and edit it with your specific credentials and settings. ```bash cp .env.example .env # Edit .env with your credentials ``` -------------------------------- ### PydanticAI Development Patterns (YAML Configuration) Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/template-generator/PRPs/template-pydantic-ai.md Illustrates common PydanticAI development patterns using YAML, including project structure for basic and advanced setups, package management commands for installation and dependencies, testing workflow commands, and environment setup for API keys and development/production configurations. ```yaml # PydanticAI Development Patterns (researched from docs and examples) project_structure: basic_pattern: | my_agent/ ├── agent.py # Main agent definition ├── tools.py # Tool functions ├── models.py # Pydantic output models ├── dependencies.py # Context dependencies └── tests/ ├── test_agent.py └── test_tools.py advanced_pattern: | agents_project/ ├── agents/ │ ├── __init__.py │ ├── chat_agent.py │ └── workflow_agent.py ├── tools/ │ ├── __init__.py │ ├── web_search.py │ └── calculator.py ├── models/ │ ├── __init__.py │ └── outputs.py ├── dependencies/ │ ├── __init__.py │ └── database.py ├── tests/ └── examples/ package_management: installation: "pip install pydantic-ai" optional_deps: "pip install 'pydantic-ai[examples]'" dev_deps: "pip install pytest pytest-asyncio inline-snapshot dirty-equals" testing_workflow: unit_tests: "pytest tests/ -v" agent_testing: "Use TestModel for fast validation" integration_tests: "Use real models with rate limiting" evals: "Run performance benchmarks separately" environment_setup: api_keys: ["OPENAI_API_KEY", "ANTHROPIC_API_KEY", "GEMINI_API_KEY"] development: "Set ALLOW_MODEL_REQUESTS=False for testing" production: "Configure proper logging and monitoring" ``` -------------------------------- ### PydanticAI Template Directory Structure Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/template-generator/PRPs/template-pydantic-ai.md This outlines the complete directory structure for the PydanticAI template package, including guides, commands, PRP templates, examples, and utility scripts. ```directory use-cases/pydantic-ai/ ├── CLAUDE.md # PydanticAI implementation guide ├── .claude/commands/ │ ├── generate-pydantic-ai-prp.md # Agent PRP generation │ └── execute-pydantic-ai-prp.md # Agent PRP execution ├── PRPs/ │ ├── templates/ │ │ └── prp_pydantic_ai_base.md # PydanticAI base PRP template │ ├── ai_docs/ # PydanticAI documentation │ └── INITIAL.md # Example agent feature request ├── examples/ │ ├── basic_chat_agent/ # Simple chat agent with memory │ ├── tool_enabled_agent/ # Web search + calculator tools │ ├── workflow_agent/ # Multi-step workflow processing │ ├── structured_output_agent/ # Custom Pydantic models │ └── testing_examples/ # Agent testing patterns ├── copy_template.py # Template deployment script └── README.md # Comprehensive usage guide ``` -------------------------------- ### Directory Structure for Technology Template Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/template-generator/PRPs/templates/prp_template_base.md Defines the standard directory structure for a generated context engineering template package, including guides, commands, PRP templates, examples, and scripts. ```tree use-cases/{technology-name}/ ├── CLAUDE.md # Domain implementation guide ├── .claude/commands/ │ ├── generate-{technology}-prp.md # Domain PRP generation │ └── execute-{technology}-prp.md # Domain PRP execution ├── PRPs/ │ ├── templates/ │ │ └── prp_{technology}_base.md # Domain base PRP template │ ├── ai_docs/ # Domain documentation (optional) │ └── INITIAL.md # Example feature request ├── examples/ # Domain code examples ├── copy_template.py # Template deployment script └── README.md # Comprehensive usage guide ``` -------------------------------- ### PRP Framework Quick Start Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md A three-step process for context engineering using the Product Requirements Prompt (PRP) framework: define requirements, generate PRP, and execute PRP. ```bash # 1. Define your requirements with examples and context # Edit INITIAL.md to include example code and patterns # 2. Generate a comprehensive PRP /generate-prp INITIAL.md # 3. Execute the PRP to implement your feature /execute-prp PRPs/your-feature-name.md ``` -------------------------------- ### Debugging Commands with ipdb, memory-profiler, and rich Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/CLAUDE.md Demonstrates commands for installing and using debugging tools like ipdb for interactive debugging, memory-profiler for memory usage analysis, and rich for enhanced tracebacks. ```bash # Interactive debugging with ipdb uv add --dev ipdb # Add breakpoint: import ipdb; ipdb.set_trace() # Memory profiling uv add --dev memory-profiler uv run python -m memory_profiler script.py # Line profiling uv add --dev line-profiler # Add @profile decorator to functions # Debug with rich traceback uv add --dev rich # In code: from rich.traceback import install; install() ``` -------------------------------- ### PydanticAI Specialization Configuration Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/template-generator/PRPs/template-pydantic-ai.md Defines the specialization details for PydanticAI, including agent patterns, validation strategies, example types, common pitfalls, and security measures. This configuration object guides the template generation process. ```typescript const pydantic_ai_specialization = { agent_patterns: [ "chat_agent_with_memory", "tool_integrated_agent", "workflow_processing_agent", "structured_output_agent" ], validation: [ "agent_behavior_testing", "tool_function_validation", "output_schema_verification", "model_provider_compatibility" ], examples: [ "basic_conversation_agent", "web_search_calculator_tools", "multi_step_workflow_processing", "custom_pydantic_output_models", "comprehensive_testing_suite" ], gotchas: [ "async_sync_mixing_issues", "model_token_limits", "dependency_injection_complexity", "tool_error_handling_failures", "context_state_management" ], security: [ "api_key_environment_management", "input_validation_pydantic_models", "prompt_injection_prevention", "rate_limiting_implementation", "secure_tool_parameter_handling" ] }; ``` -------------------------------- ### CLAUDE.md: Minimal Working Example for Global AI Behavior Rules Source: https://context7.com/coleam00/context-engineering-intro/llms.txt Defines project-wide behavioral rules for AI, including project awareness, code structure, testing requirements, style conventions, and AI behavior rules. Ensures consistent naming, modularity, testing, and adherence to style guides like PEP8. ```markdown # CLAUDE.md (minimal working example) ### 🔄 Project Awareness & Context - Always read `PLANNING.md` at the start of a new conversation. - Check `TASK.md` before starting a new task. If not listed, add it. - Use consistent naming conventions as described in `PLANNING.md`. - Use venv_linux for all Python commands including unit tests. ### 🧱 Code Structure & Modularity - Never create a file longer than 500 lines. Refactor by splitting modules. - Organize agents as: agent.py / tools.py / prompts.py - Use python_dotenv and load_env() for environment variables. ### 🧪 Testing & Reliability - Always create Pytest unit tests for new features. - Tests live in a /tests folder mirroring the main app. - Include at least: 1 expected-use test, 1 edge case, 1 failure case. ### 📎 Style & Conventions - Use Python as primary language. Follow PEP8 with type hints. - Format with black. Use pydantic for data validation. - Google-style docstrings for every function: def my_func(param: str) -> int: """ Brief summary. Args: param (str): Description. Returns: int: Description. """ ### 🧠 AI Behavior Rules - Never hallucinate libraries. Only use known, verified packages. - Never delete existing code unless explicitly instructed. - Ask questions if context is missing — never assume. ``` -------------------------------- ### Example Database Tools Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/mcp-server/README.md Demonstrates how to create MCP tools that interact with the database, following established security and design patterns. ```typescript examples/database-tools.ts ``` -------------------------------- ### Example Prompts for Simple Agents Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/README.md These prompts demonstrate how to request the creation of basic AI agents with specific functionalities. ```text "Build an AI agent that can search the web" "Create an agent for summarizing documents" "I need an assistant that can query databases" ``` -------------------------------- ### Install tmux on macOS Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/README.md Installs tmux using Homebrew on macOS. Ensure Homebrew is installed first. ```bash brew install tmux ``` -------------------------------- ### Install Claude Code (macOS/Linux) Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md Installs the Claude Code package globally using npm. Ensure Node.js is installed. ```bash npm install -g @anthropic-ai/claude-code ``` -------------------------------- ### Simple Agent Request Example Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/CLAUDE.md Illustrates the expected process and timeline for handling a simple agent request, such as building a web search agent. ```text 1. Planner asks minimal questions (1-2) 2. Assumes standard patterns (Brave API, string output) 3. Completes in ~10 minutes total 4. Delivers working agent with basic tests ``` -------------------------------- ### Quick Start: Generate and Execute Template PRP Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/template-generator/README.md Defines the steps to generate a comprehensive template PRP and then execute it to create a complete template package. Ensure your template requirements are detailed in PRPs/INITIAL.md before generation. ```bash # 1. Define your template requirements in detail # Edit PRPs/INITIAL.md with specific technology and requirements # 2. Generate comprehensive template PRP /generate-template-prp PRPs/INITIAL.md # 3. Execute the PRP to create complete template package /execute-template-prp PRPs/template-{technology-name}.md ``` -------------------------------- ### OpenAI LLM and Embedding Client Setup Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/agents/rag_agent/planning/dependencies.md Provides functions to initialize OpenAI LLM and embedding clients using loaded settings. Requires `load_settings` to be defined elsewhere. ```python from some_module import load_settings, OpenAIProvider, OpenAIModel, OpenAI def get_llm_model(): """Get OpenAI model configuration.""" settings = load_settings() provider = OpenAIProvider( base_url=settings.llm_base_url, api_key=settings.openai_api_key ) return OpenAIModel(settings.llm_model, provider=provider) def get_embedding_client(): """Get OpenAI client for embeddings.""" settings = load_settings() return OpenAI(api_key=settings.openai_api_key) ``` -------------------------------- ### Verify tmux installation Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/README.md Checks if tmux is installed and displays its version. This command should be run in your terminal. ```bash tmux -V ``` -------------------------------- ### Verify Claude Code Installation Source: https://github.com/coleam00/context-engineering-intro/blob/main/claude-code-full-guide/README.md Checks if the Claude Code CLI is installed and accessible by displaying its version. ```bash claude --version ``` -------------------------------- ### Install tmux on Linux (Fedora/RHEL) Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/README.md Installs tmux on Fedora or RHEL-based Linux distributions. Requires sudo privileges. ```bash sudo dnf install tmux ``` -------------------------------- ### Set up PostgreSQL with PGVector Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/agent-factory-with-subagents/agents/rag_agent/README.md Run the provided SQL schema to set up your PostgreSQL database with the PGVector extension. This can be done directly in a SQL editor or via the psql command-line tool. ```bash # SIMPLEST: Run the SQL in your SQL editor if you are using a platform like Supabase/Postgres # Or run the schema with psql psql -d your_database -f sql/schema.sql ``` -------------------------------- ### Install tmux on Linux (Ubuntu/Debian) Source: https://github.com/coleam00/context-engineering-intro/blob/main/use-cases/build-with-agent-team/README.md Installs tmux on Ubuntu or Debian-based Linux distributions. Requires sudo privileges. ```bash sudo apt update && sudo apt install tmux ```