### Install and Initialize CrewCode CLI Source: https://github.com/sowonlabs/crewcode/blob/main/README.md These commands cover the initial setup for CrewCode, including installation, project initialization, and system checks. They are essential for getting started with the CrewCode CLI. ```bash # Install npm install -g crewcode # Initialize crewcode init # Check system crewcode doctor # Try it out crewcode query "@claude analyze my code" crewcode execute "@claude create a login component" ``` -------------------------------- ### Start CrewCode MCP Server Source: https://github.com/sowonlabs/crewcode/blob/main/docs/mcp-integration.md This command initiates the CrewCode MCP server, enabling it to communicate with compatible clients such as VS Code and Claude Desktop. No specific dependencies are required beyond having CrewCode installed. ```bash crewcode mcp ``` -------------------------------- ### Setting Up Slack Bot Environment Variables Source: https://github.com/sowonlabs/crewcode/blob/main/SLACK_INSTALL.md This snippet demonstrates how to create and configure the `.env.slack` file with the necessary Slack API tokens. Ensure you replace the placeholder values with your actual tokens obtained during the Slack App setup process. ```bash cd /path/to/crewcode/worktree/slack-bot cp .env.slack.example .env.slack # Slack Bot Token (Step 5에서 받은 값) SLACK_BOT_TOKEN=xoxb-your-actual-bot-token-here # Slack App Token (Step 3에서 받은 값) SLACK_APP_TOKEN=xapp-your-actual-app-token-here # Slack Signing Secret (Step 6에서 받은 값) SLACK_SIGNING_SECRET=your-actual-signing-secret-here ``` -------------------------------- ### Install and Verify CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Installs the CrewCode CLI globally using npm and verifies the installation by checking the version. This is a common first step for troubleshooting. ```bash # Install globally npm install -g crewcode # Verify installation crewcode --version ``` -------------------------------- ### Tool Naming and Description Example Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Illustrates the importance of using clear, action-oriented names and detailed descriptions for tools. This snippet shows an example of how to define these properties for effective AI understanding and selection. ```json { "name": "search_database", // Clear, action-oriented "description": "Search the product database by name, category, or SKU. Returns matching products with details.", // Detailed for AI understanding } ``` -------------------------------- ### Start CrewCode as a Slack Bot Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Initiates the CrewCode Slack bot, allowing interaction with different AI agents like Claude, Gemini, or Copilot. Requires Slack app setup and environment variables for authentication and configuration. ```bash crewcode slack # Start with Claude (default) crewcode slack --agent gemini # Use Gemini crewcode slack --agent copilot # Use GitHub Copilot crewcode slack --agent custom_agent # Use custom agent ``` -------------------------------- ### Verify Crewcode Configuration Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Displays the content of the crewcode.yaml configuration file to help diagnose setup issues. Useful for checking working directory, provider options, and other settings. ```bash cat crewcode.yaml ``` -------------------------------- ### Example of Valid YAML Configuration Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Demonstrates a correctly formatted YAML structure for agent configuration within CrewCode, emphasizing proper indentation, spacing, and the use of quotes for string values. ```yaml agents: - id: "my_agent" # ✓ Correct indentation name: "My Agent" # ✓ Quotes around strings provider: "claude" # ✓ Proper spacing ``` -------------------------------- ### Inviting and Testing the Slack Bot Source: https://github.com/sowonlabs/crewcode/blob/main/SLACK_INSTALL.md This section provides commands to test the CrewCode Slack Bot within your Slack workspace. It includes how to invite the bot to a channel and send a test message to verify its functionality. ```bash # 1. 아무 채널에 CrewCode 봇을 초대: /invite @crewcode # 2. 메시지 보내기: @crewcode Hello! What can you help me with? ``` -------------------------------- ### Install AI Provider CLI Tools Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Installs necessary command-line interface tools for various AI providers, such as Anthropic's Claude, Google's Gemini, and GitHub Copilot. This is crucial for AI provider integration. ```bash # Install missing tools npm install -g @anthropic/claude-code npm install -g @google/generative-ai-cli gh extension install github/gh-copilot ``` -------------------------------- ### CrewCode Diagnostics and Help Commands Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Outlines the steps for getting help with CrewCode issues, including running diagnostics, checking logs, verifying configuration, and testing individual providers. It also directs users on how to report an issue on GitHub. ```bash # Run diagnostics: crewcode doctor # Check logs: ls .crewcode/logs/ cat .crewcode/logs/latest.log # Verify configuration: cat crewcode.yaml # or agents.yaml crewcode init --force # Reset to defaults # Test providers individually: claude "hello" gemini -p "hello" gh copilot suggest "hello" ``` -------------------------------- ### Running the CrewCode Slack Bot Source: https://github.com/sowonlabs/crewcode/blob/main/SLACK_INSTALL.md Instructions on how to build and run the CrewCode Slack Bot. It shows commands for building the project, running the bot with the default agent (Claude), and specifying alternative agents like Gemini or Copilot. Logging can also be enabled. ```bash # 빌드 (처음 한 번만) npm run build # Bot 실행 (기본: Claude) source .env.slack && crewcode slack # 다른 에이전트 사용 source .env.slack && crewcode slack --agent gemini source .env.slack && crewcode slack --agent copilot # 또는 로그와 함께 실행 source .env.slack && crewcode slack --log source .env.slack && crewcode slack --agent gemini --log ``` -------------------------------- ### YAML Agent Prompt: Custom Tool List Formatting Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md An example system prompt that customizes the display of available tools for an agent. It iterates through the tool list and presents each tool's name, description, and required parameters in a structured format. ```yaml agents: - id: "custom_format_agent" inline: system_prompt: | You are an AI assistant with tool capabilities. {{#if tools}} ## Your Toolkit ({{tools.count}} tools) {{#each tools.list}} ### {{this.name}} - **Description:** {{this.description}} - **Required Parameters:** {{#each this.input_schema.required}}{{this}}, {{/each}} {{/each}} Use these tools to enhance your responses. {{/if}} ``` -------------------------------- ### YAML Agent Prompt: Basic Tool Awareness Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md An example of an agent's system prompt that uses Handlebars to check if tools are available and mentions the number of tools to the AI. It adapts the response based on tool availability. ```yaml agents: - id: "my_agent" inline: system_prompt: | You are an AI assistant. {{#if tools}} You have access to {{tools.count}} tool(s). Use them when appropriate to provide accurate information. {{else}} Respond based on your knowledge without tools. {{/if}} ``` -------------------------------- ### Test MCP Server Manually Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Starts the MCP server manually using the `crewcode mcp` command. This is useful for debugging MCP integration issues and checking for immediate error messages. ```bash # Test MCP server manually crewcode mcp ``` -------------------------------- ### Use Documents in Agent System Prompt (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md This YAML example shows how to integrate documents into an agent's system prompt using Handlebars template variables. It demonstrates referencing project-level and agent-specific documents. ```yaml crewcode.yaml documents: project-guide: | # Project Guide This is project-specific documentation. agents: - id: "my_agent" inline: documents: agent-doc: | # Agent-Specific Doc Only this agent can see this. system_prompt: | You are a helpful assistant. {{{documents.quick-tips.content}}} {{{documents.readme.toc}}} Summary: {{documents.readme.summary}} ``` -------------------------------- ### Bash Read File Command Example Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Demonstrates how to use the 'read_file' built-in tool via the Crewcode CLI to read the content of a specified file. This is useful for agents that need to process file contents. ```bash crewcode query "@gemini README.md 파일을 읽고 요약해줘" ``` -------------------------------- ### Including Documents in Agent Prompt - YAML Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md An example demonstrating how to include content from global and project-level documents into an agent's system prompt using YAML. It shows how to reference and embed document content for context. ```yaml documents.yaml (global): ```yaml documents: coding-standards: | # Coding Standards ## TypeScript - Use strict type checking - Prefer interfaces over types - Document public APIs ``` crewcode.yaml (project): ```yaml documents: project-conventions: | # Project Conventions - Follow trunk-based development - Write tests for all features - Use semantic commit messages agents: - id: "code_reviewer" inline: documents: review-checklist: | # Review Checklist - Check type safety - Verify test coverage - Review error handling system_prompt: | You are a code reviewer. {{{documents.coding-standards.content}}} {{{documents.project-conventions.content}}} {{{documents.review-checklist.content}}} ``` -------------------------------- ### Initialize CrewCode Configuration File Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Creates the `crewcode.yaml` configuration file using the CrewCode CLI. This is the preferred method for setting up the initial configuration. ```bash # Create crewcode.yaml (preferred) crewcode init # Verify file exists ls crewcode.yaml ``` -------------------------------- ### CrewCode CLI Agent Creation Commands (Bash) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Demonstrates how to use the `crewcode execute` command with the `@crewcode` assistant to create specialized agents. These examples cover Python, React, DevOps, and Security Analyst agents, illustrating the flexibility in defining agent roles and expertise via natural language prompts. ```bash # Create a Python expert crewcode execute "@crewcode Create a Python expert agent. ID 'python_expert', use claude sonnet. Specializes in code review, optimization, and debugging." # Create a React specialist crewcode execute "@crewcode Create a React specialist agent with TypeScript expertise" # Create a DevOps agent crewcode execute "@crewcode Create a DevOps agent for Docker and Kubernetes" # Create a security analyst crewcode execute "@crewcode Create a security analyst agent" ``` -------------------------------- ### CrewCode Agent Configuration Example Source: https://context7.com/sowonlabs/crewcode/llms.txt Illustrates the structure for defining custom AI agents within CrewCode using YAML. This allows for specialized agent behaviors, specific working directories, and the inclusion of knowledge documents to guide agent responses. ```yaml # Example YAML for agent configuration # Define custom agents with specialized behaviors, working directories, and knowledge documents. ``` -------------------------------- ### Install and Verify CrewCode CLI Source: https://context7.com/sowonlabs/crewcode/llms.txt Installs the CrewCode CLI globally via npm and runs system diagnostics to verify AI provider availability and installation status. This is a prerequisite for using other CrewCode CLI commands. ```bash # Install globally via npm npm install -g crewcode # Initialize with project templates crewcode init # Check AI provider availability and installation status crewcode doctor # Expected output: # 🤖 AI Providers Status # # Available Providers: # ✅ claude # ✅ gemini # ✅ copilot # # Installation Status: # • Claude CLI: ✅ Installed # • Gemini CLI: ✅ Installed # • Copilot CLI: ✅ Installed ``` -------------------------------- ### Start CrewCode MCP Server for IDE Integration Source: https://context7.com/sowonlabs/crewcode/llms.txt Runs CrewCode as an MCP (Model Context Protocol) server, enabling integration with IDEs like VS Code, Claude Desktop, and Cursor. Supports both stdio and HTTP protocols for communication. Includes example configurations for VS Code and Claude Desktop. ```bash # Start MCP server (stdio mode) crewcode mcp # Start with HTTP mode for debugging crewcode mcp --protocol HTTP --port 3000 # Configuration for Claude Desktop (add to claude_desktop_config.json) { "mcpServers": { "crewcode": { "command": "npx", "args": ["crewcode", "mcp"] } } } # Configuration for VS Code (add to settings.json) { "mcp.servers": { "crewcode": { "command": "npx", "args": ["crewcode", "mcp"] } } } # Available MCP tools: # - crewcode_listAgents: List available AI agents # - crewcode_queryAgent: Query agent (read-only) # - crewcode_executeAgent: Execute agent task # - crewcode_queryAgentParallel: Query multiple agents in parallel # - crewcode_executeAgentParallel: Execute multiple tasks in parallel # - crewcode_checkAIProviders: Check AI CLI installation status # - crewcode_getTaskLogs: Monitor task execution logs # - crewcode_clearAllLogs: Clear accumulated task logs ``` -------------------------------- ### Start CrewCode MCP Server Mode Source: https://github.com/sowonlabs/crewcode/blob/main/README.md This command starts the MCP server, enabling IDE integrations such as VS Code, Claude Desktop, and Cursor. This mode facilitates seamless AI assistance directly within your development environment. ```bash crewcode mcp # VS Code, Claude Desktop, Cursor ``` -------------------------------- ### Example of Invalid YAML Configuration Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Illustrates common YAML syntax errors, such as incorrect indentation and missing quotes around string values, which can lead to parsing errors in CrewCode configurations. ```yaml agents: - id: my_agent # ✗ No quotes (may break with special chars) name: My Agent # ✗ No quotes provider: claude # ✗ Wrong indentation ``` -------------------------------- ### CrewCode Common Patterns: Implementation and Multi-Perspective Analysis Source: https://github.com/sowonlabs/crewcode/blob/main/templates/documents/crewcode-manual.md Examples showcasing CrewCode's 'execute' mode for implementation tasks with Copilot and 'query' mode for multi-perspective analysis involving several AI agents. ```bash crewcode x "@copilot implement JWT middleware" crewcode q "@claude @gemini @copilot analyze performance issues" ``` -------------------------------- ### Use MCP Tool: List Agents (TypeScript) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/mcp-integration.md Example of how to use the `crewcode_listAgents` MCP tool from a client. This TypeScript snippet demonstrates calling the tool with an empty options object to retrieve a list of available agents. Assumes `use_mcp_tool` function is available in the client environment. ```typescript await use_mcp_tool("crewcode_listAgents", {}) ``` -------------------------------- ### Perform Basic AI Agent Queries Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Shows how to use CrewCode for single agent queries (e.g., explaining a function) and comparing responses from multiple agents (e.g., Claude, Gemini, Copilot). ```bash # Single agent query crewcode query "@claude explain this function" # Multiple agents compare crewcode query "@claude @gemini @copilot which approach is better?" ``` -------------------------------- ### CrewCode Agent Configuration Example (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md This YAML configuration defines three agents: a Frontend Developer, a Backend Developer, and a DevOps Engineer. Each agent has specific roles, providers, working directories, and operational options tailored to their specialization. ```yaml agents: # Frontend specialist - id: "frontend_developer" name: "React Expert" provider: "claude" working_directory: "./src/frontend" options: query: - "--add-dir=." - "--verbose" execute: - "--add-dir=." - "--allowedTools=Edit,Bash" inline: type: "agent" model: "sonnet" system_prompt: | You are a senior frontend developer specializing in React. **Expertise:** - React 18+ with TypeScript - State management (Redux, Zustand) - Component design patterns - Performance optimization **Guidelines:** - Always use TypeScript strict mode - Prefer functional components with hooks - Write comprehensive PropTypes/TypeScript types - Follow accessibility (a11y) best practices # Backend specialist with fallback - id: "backend_developer" name: "Backend Expert" provider: ["gemini", "claude", "copilot"] working_directory: "./src/backend" options: execute: gemini: - "--include-directories=." - "--yolo" claude: - "--add-dir=." - "--allowedTools=Edit,Bash" inline: type: "agent" system_prompt: | You are a backend engineering expert. **Expertise:** - RESTful API design - Database optimization - Authentication & authorization - Microservices architecture **Focus:** - Security best practices - Scalable architecture - Error handling and logging - API documentation # DevOps specialist - id: "devops_engineer" name: "DevOps Expert" provider: "copilot" working_directory: "." options: query: - "--allow-tool=files" execute: - "--allow-tool=terminal" - "--allow-tool=files" inline: type: "agent" system_prompt: | You are a DevOps engineer expert in infrastructure and deployment. **Expertise:** - Docker and Kubernetes - CI/CD pipelines - Infrastructure as Code - Monitoring and logging **Focus:** - Deployment automation - Container orchestration - Security and compliance - Performance monitoring ``` -------------------------------- ### Configure Execute Mode Options (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Specifies command-line options for the 'execute' mode, which allows agents to perform file operations. This example includes options like `--add-dir=.` and `--allowedTools=Edit,Bash`, enabling file creation and modification. ```yaml options: execute: - "--add-dir=." - "--allowedTools=Edit,Bash" # Can create/modify files ``` -------------------------------- ### Handling No Available Tools with Handlebars Fallback Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md Provides an example of using an `{{else}}` clause in Handlebars to handle cases where no tools are available. This ensures that the agent provides a graceful response, such as 'No tools available at this time,' instead of failing or displaying incomplete information. It promotes robust user interaction. ```handlebars {{#if tools}} You have {{tools.count}} tools available. {{else}} No tools available at this time. {{/if}} ``` -------------------------------- ### Execute File Operations with CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Demonstrates using CrewCode's `execute` command to perform file operations such as creating new components, refactoring existing code, and executing multiple tasks sequentially. ```bash # Create files crewcode execute "@claude create a login component" # Modify files crewcode execute "@claude refactor authentication" # Multiple tasks crewcode execute "@claude create tests" "@gemini write docs" ``` -------------------------------- ### Use MCP Tool: Execute Agent Task (TypeScript) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/mcp-integration.md Example TypeScript snippet for executing a task through an agent using the `crewcode_executeAgent` MCP tool. This demonstrates providing the agent ID, the task description, and any relevant context for the agent to perform the action, such as file operations. ```typescript await use_mcp_tool("crewcode_executeAgent", { agentId: "frontend_developer", task: "Create a React login component with TypeScript", context: "Use functional components and hooks" }) ``` -------------------------------- ### Use MCP Tool: Query Agent (TypeScript) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/mcp-integration.md Example TypeScript snippet for querying an agent using the `crewcode_queryAgent` MCP tool. It shows how to pass agent ID, query string, and contextual information to the tool for analysis. Requires an active MCP connection to CrewCode. ```typescript await use_mcp_tool("crewcode_queryAgent", { agentId: "claude", query: "Analyze this authentication code", context: "Focus on security vulnerabilities" }) ``` -------------------------------- ### Select Specific AI Models with CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Explains how to specify particular AI models (e.g., different versions of Claude or Gemini) for distinct tasks, allowing for optimization based on speed, cost, or quality requirements. ```bash # Use specific models for different tasks crewcode query "@claude:haiku quick analysis" # Fast, concise crewcode query "@claude:opus comprehensive review" # Detailed, thorough crewcode execute "@gemini:gemini-2.5-flash rapid prototyping" # Fast execution crewcode execute "@gemini:gemini-2.5-pro production code" # High quality ``` -------------------------------- ### Set Working Directory for Multiple Agents (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Provides examples of setting specific working directories for different agents within the CrewCode configuration. Each agent can be assigned a unique `working_directory` path, including the project root or specific subdirectories. ```yaml agents: - id: "frontend_dev" working_directory: "./src/frontend" - id: "backend_dev" working_directory: "./src/backend" - id: "full_stack" working_directory: "." # Project root ``` -------------------------------- ### Orchestrate Complex Workflows with CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Illustrates how to chain CrewCode commands for multi-step workflows, such as a design-implement-test cycle for user management, or a code review pipeline involving diff analysis and refactoring. ```bash # Design → Implement → Test crewcode query "@architect design user management" --thread "user-mgmt" && \ crewcode execute "@backend implement it" --thread "user-mgmt" && \ crewcode query "@tester create test plan" --thread "user-mgmt" # Code review pipeline git diff | crewcode query "@claude review these changes" | \ crewcode execute "@refactor improve code quality" ``` -------------------------------- ### TypeScript Custom Calculator Tool Creation Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Demonstrates how to create a custom calculator tool in TypeScript. It defines the tool's schema and implements its execution logic, including input validation and arithmetic operations. This example shows the full process from definition to executor implementation. ```typescript import { ToolCallService, Tool, ToolExecutor, ToolExecutionContext, ToolExecutionResult } from '@/services/tool-call.service'; // 1. Define the tool const calculatorTool: Tool = { name: 'calculator', description: 'Perform basic arithmetic operations', input_schema: { type: 'object', properties: { operation: { type: 'string', enum: ['add', 'subtract', 'multiply', 'divide'], description: 'The arithmetic operation to perform' }, a: { type: 'number', description: 'First number' }, b: { type: 'number', description: 'Second number' } }, required: ['operation', 'a', 'b'] } }; // 2. Implement the executor const calculatorExecutor: ToolExecutor = { execute: async (context: ToolExecutionContext): Promise => { const startTime = Date.now(); try { const { operation, a, b } = context.input; // Validate input if (typeof a !== 'number' || typeof b !== 'number') { return { success: false, error: 'Both a and b must be numbers' }; } // Perform calculation let result: number; switch (operation) { case 'add': result = a + b; break; case 'subtract': result = a - b; break; case 'multiply': result = a * b; break; case 'divide': if (b === 0) { return { success: false, error: 'Division by zero' }; } result = a / b; break; default: return { success: false, error: `Unknown operation: ${operation}` }; } return { success: true, data: { result, operation }, metadata: { executionTime: Date.now() - startTime, toolName: 'calculator' } }; } catch (error: any) { return { success: false, error: `Execution failed: ${error.message}` }; } } }; // 3. Register the tool @Injectable() export class CustomToolsService { constructor(private readonly toolCallService: ToolCallService) { this.registerTools(); } private registerTools(): void { this.toolCallService.register(calculatorTool, calculatorExecutor); } } ``` -------------------------------- ### Configure Agent with a Single Fixed Provider (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Demonstrates how to configure an agent to exclusively use a single AI provider, 'claude' in this example. This ensures the agent will always attempt to use the specified provider without any fallback mechanism. ```yaml agents: - id: "claude_only" provider: "claude" # Always uses Claude, no fallback ``` -------------------------------- ### Integrate Conversation History with Slack Bot Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md This example shows how to integrate conversation history for a Slack bot using a system prompt. It utilizes the `formatConversation` helper to correctly format messages based on the platform. This is useful for maintaining context in agent-driven conversations. ```yaml agents: - id: "slack_bot" inline: system_prompt: | You are a Slack assistant. {{{formatConversation messages platform}}} Respond naturally based on the conversation history. ``` -------------------------------- ### VS Code MCP Configuration (macOS/Linux) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/mcp-integration.md Configuration for VS Code to connect to the CrewCode MCP server on macOS and Linux. It uses `npx` to execute CrewCode in MCP mode and defines the agent configuration path. This setup is standard for Unix-like systems. ```json { "servers": { "crewcode": { "command": "npx", "args": ["-y", "crewcode", "mcp"], "env": { "AGENTS_CONFIG": "${workspaceFolder}/crewcode.yaml" } } } } ``` -------------------------------- ### Conditional Prompt - Production vs. Development - YAML Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md Example of using Handlebars conditionals in a YAML configuration to modify an agent's system prompt based on the environment variable `NODE_ENV`. This allows for different agent behaviors in development and production. ```yaml agents: - id: "dev_assistant" inline: system_prompt: | You are a development assistant. {{#if (eq env.NODE_ENV "production")}} **Production Mode**: Be extra careful with suggestions. Always recommend testing changes thoroughly. {{else}} **Development Mode**: Feel free to experiment. You can suggest more experimental approaches. {{/if}} Working Directory: {{agent.workingDirectory}} ``` -------------------------------- ### Example of Correct Worktree and Branch Reset (Bash) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/rules/branch-protection.md This example demonstrates the correct way to perform work in a temporary directory (worktree) and then return to the main project directory, ensuring the 'develop' branch is checked out. It emphasizes the importance of returning to the correct branch after temporary operations. ```bash cd worktree/bugfix-xxx && (work) && cd /Users/doha/git/crewcode && git checkout develop ``` -------------------------------- ### Viewing Available Tools in TypeScript Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Provides a TypeScript snippet to list all currently registered tools using `toolCallService.list()`. The output displays the names of the available tools, which is useful for debugging and understanding the toolset. ```typescript const tools = toolCallService.list(); console.log('Available tools:', tools.map(t => t.name)); ``` -------------------------------- ### Configure Slack Bot Environment Variables Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Sets up the necessary environment variables for the CrewCode Slack bot. This includes Slack API tokens and optional parameters like maximum response length. ```bash SLACK_BOT_TOKEN=xoxb-... SLACK_APP_TOKEN=xapp-... SLACK_SIGNING_SECRET=... SLACK_MAX_RESPONSE_LENGTH=400000 # Optional ``` -------------------------------- ### Use Faster Claude Model for Queries Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Specifies the use of a faster Claude model, such as 'haiku', for executing queries. This can significantly reduce response times for quick questions or less complex tasks. ```bash crewcode query "@claude:haiku quick question" ``` -------------------------------- ### CrewCode Common Patterns: Code Review and Architecture Design Source: https://github.com/sowonlabs/crewcode/blob/main/templates/documents/crewcode-manual.md Examples of using CrewCode for common development tasks like code review involving multiple agents and architecture design with a specific Claude model. ```bash crewcode q "@claude @copilot review this pull request" crewcode q "@claude:opus design user authentication system" ``` -------------------------------- ### Configure Custom Agents using crewcode.yaml Source: https://github.com/sowonlabs/crewcode/blob/main/README.md Illustrates the structure of the `crewcode.yaml` file for defining custom AI agents. It includes an example of an agent configuration for a frontend developer, specifying its ID, name, provider, working directory, and system prompt. ```yaml agents: - id: "frontend_dev" name: "React Expert" provider: "claude" working_directory: "./src" inline: type: "agent" system_prompt: | You are a senior React developer. Provide detailed examples and best practices. ``` -------------------------------- ### Manage CrewCode Tasks and Logs Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Demonstrates how to execute operations with CrewCode, which automatically generates task IDs for logging. It also shows how to view logs for a specific task ID. ```bash # Operations automatically create logs crewcode execute "@claude create component" # Output includes: Task ID: abc123 # View task logs crewcode logs abc123 ``` -------------------------------- ### Enable Parallel Execution with CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Demonstrates how to use CrewCode for parallel execution of tasks by passing multiple task arguments to the query command. This allows for concurrent processing of different tasks. ```bash crewcode query "@claude task1" "@gemini task2" # Parallel ``` -------------------------------- ### CrewCode Custom Agent Configuration (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/templates/documents/crewcode-manual.md Example of how to define a custom agent in the `agents.yaml` file, specifying its ID, name, role, and inline provider details including model and system prompt. ```yaml agents: - id: "my_agent" name: "My Custom Agent" role: "developer" inline: provider: "claude" model: "sonnet" system_prompt: | You are a specialized assistant for... ``` -------------------------------- ### View Slack Environment Variables Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Displays the content of the '.env.slack' file, which contains essential environment variables for Slack integration, such as bot tokens and signing secrets. Crucial for troubleshooting Slack bot connectivity. ```bash cat .env.slack ``` -------------------------------- ### Configure Provider-Specific Options (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Illustrates how to assign different command-line options to specific AI providers when an agent uses multiple providers. This allows for fine-tuning the behavior of each provider individually within the same agent configuration. ```yaml agents: - id: "multi_provider" provider: ["claude", "gemini", "copilot"] options: execute: claude: - "--permission-mode=acceptEdits" - "--add-dir=." gemini: - "--include-directories=." copilot: - "--add-dir=." ``` -------------------------------- ### Use Faster Gemini Model for Tasks Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Instructs Crewcode to use a faster Gemini model, like 'gemini-2.5-flash', for executing tasks. This optimization is beneficial for time-sensitive operations. ```bash crewcode query "@gemini:gemini-2.5-flash fast task" ``` -------------------------------- ### Configure Multiple Crewcode Providers Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Sets up a fallback mechanism for Crewcode agents by specifying multiple AI providers. If the primary provider fails, Crewcode will attempt to use the next one in the list. ```yaml provider: ["claude", "gemini", "copilot"] ``` -------------------------------- ### List Crewcode Conversation Threads Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Lists all available conversation threads stored in the '.crewcode/conversations/' directory. This helps in managing and identifying existing threads for context preservation. ```bash ls .crewcode/conversations/ ``` -------------------------------- ### Test Crewcode Agent Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Executes a test query against a Crewcode agent to verify its functionality after configuration changes. Useful for confirming fixes for path issues or other agent errors. ```bash crewcode query "@agent test query" ``` -------------------------------- ### Handlebars Template Variables for Tools Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Illustrates how to conditionally display information about available tools within agent system prompts using Handlebars syntax. It shows how to access the count, JSON representation, and list of tools. ```yaml {{#if tools}} # Tools are available {{tools.count}} # Number of available tools {{{tools.json}}} # All tools as formatted JSON {{#each tools.list}} # Iterate through tools {{this.name}} {{this.description}} {{/each}} {{else}} # No tools available {{/if}} ``` -------------------------------- ### Use Provider Fallback in CrewCode Query Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Demonstrates how to configure CrewCode to query multiple AI providers by listing them in the agent configuration. This allows CrewCode to use an available provider if one fails or has reached its session limit. ```bash # Use provider fallback crewcode query "@flexible_agent your question" # Where flexible_agent has: provider: ["claude", "gemini", "copilot"] ``` -------------------------------- ### Create a New Crewcode Conversation Thread Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Initiates a new conversation thread in Crewcode with a specified name. This is useful for starting a new line of inquiry or task that requires a clean context. ```bash crewcode query "@claude start" --thread "new-thread" ``` -------------------------------- ### Customize CrewCode Provider Timeouts Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Allows customization of timeout values for AI model queries and execution, as well as system-level timeouts, using environment variables or a `.env` file. This helps manage the responsiveness of different AI providers. ```bash # Claude Provider CODECREW_TIMEOUT_CLAUDE_QUERY=600000 # 10 min CODECREW_TIMEOUT_CLAUDE_EXECUTE=45000 # 45 sec # Gemini Provider CODECREW_TIMEOUT_GEMINI_QUERY=600000 # 10 min CODECREW_TIMEOUT_GEMINI_EXECUTE=1200000 # 20 min # Copilot Provider CODECREW_TIMEOUT_COPILOT_QUERY=600000 # 10 min CODECREW_TIMEOUT_COPILOT_EXECUTE=1200000 # 20 min # System CODECREW_TIMEOUT_PARALLEL=300000 # 5 min CODECREW_TIMEOUT_STDIN_INITIAL=30000 # 30 sec CODECREW_TIMEOUT_STDIN_CHUNK=600000 # 10 min CODECREW_TIMEOUT_STDIN_COMPLETE=100 # 100ms ``` ```bash # Using .env file echo "CODECREW_TIMEOUT_CLAUDE_QUERY=900000" >> .env crewcode query "@claude complex analysis" # Inline CODECREW_TIMEOUT_CLAUDE_QUERY=1800000 crewcode query "@claude deep analysis" ``` -------------------------------- ### Build Multi-Step Pipeline Workflows Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Chains CrewCode commands together to create complex, multi-step workflows. This allows for sequential execution of tasks such as design, implementation, and testing, with output from one command feeding into the next. ```bash # Multi-step development crewcode query "@architect design user auth system" | \ crewcode execute "@backend implement API endpoints" | \ crewcode execute "@frontend create UI components" # Code review and improvement crewcode query "@claude analyze code quality" | \ crewcode execute "@gemini implement improvements" # Design, implement, test crewcode query "@architect design feature" | \ crewcode execute "@developer build it" | \ crewcode query "@tester verify implementation" ``` -------------------------------- ### Configure Gemini CLI API Key Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Sets the API key for the Gemini CLI, either through an environment variable or using the `gemini config` command. This is essential for authenticating with Google's AI services. ```bash # Set API key export GOOGLE_API_KEY="your-api-key" # Or configure gemini config set apiKey YOUR_API_KEY ``` -------------------------------- ### Task Breakdown: Sequential Agent Operations (Bash) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/guides/agent-best-practices.md Illustrates breaking down a complex workflow into distinct, sequential tasks, each assigned to a specialized agent. This example shows an architecture design, followed by implementation, and then optimization. ```bash # Architecture crewcode q "@claude design user authentication system" ``` ```bash # Implementation crewcode x "@copilot implement JWT middleware" ``` ```bash # Optimization crewcode q "@gemini optimize authentication performance" ``` -------------------------------- ### Handlebars Agent Metadata Access Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md Demonstrates accessing various agent metadata properties like ID, name, provider, model, and working directory using Handlebars expressions. ```handlebars {{agent.id}} {{agent.name}} {{agent.provider}} {{agent.model}} {{agent.workingDirectory}} ``` -------------------------------- ### Enable Debug Logging and Verbose Output Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Shows how to enable debug logging for CrewCode by setting the DEBUG environment variable and running commands with the --verbose flag. It also includes instructions on how to check the generated log files. ```bash # Set debug environment variable export DEBUG=crewcode:* # Run with verbose output crewcode query "@claude test" --verbose # Check logs cat .crewcode/logs/*.log ``` -------------------------------- ### YAML Agent Prompt: Detailed Tool Instructions Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Configures an agent's system prompt to include detailed instructions on using available tools. It lists the tools in JSON format within a specific tag and outlines a usage strategy for the AI. ```yaml agents: - id: "tool_expert" inline: system_prompt: | You are a helpful AI assistant. {{#if tools}} ## Available Tools You have {{tools.count}} tool(s) at your disposal: {{{tools.json}}} **Instructions:** 1. Analyze user requests carefully 2. Use tools when they provide accurate, real-time data 3. Explain what tool you're using and why 4. Always validate tool results before responding {{/if}} ## Your Task Answer questions clearly and use tools effectively. ``` -------------------------------- ### Handlebars Document Variable Examples Source: https://github.com/sowonlabs/crewcode/blob/main/docs/templates.md These Handlebars expressions illustrate how to access document content, table of contents, and summary metadata within templates. Triple braces are used for unescaped content. ```handlebars Content: {{{documents.doc-name.content}}} - Full document content (unescaped) {{documents.doc-name.content}} - Escaped content Metadata: {{{documents.doc-name.toc}}} - Table of contents {{documents.doc-name.summary}} - Document summary {{documents.doc-name.type}} - Document type ``` -------------------------------- ### Start CrewCode in Slack Mode Source: https://github.com/sowonlabs/crewcode/blob/main/README.md This command initiates CrewCode in Slack mode, enabling AI agents to be used directly within Slack channels for team collaboration. It allows team members to @mention AI agents and maintain conversational context. ```bash # Start CrewCode in your Slack workspace crewcode slack # Your team can now: # - @mention AI agents in channels # - Maintain context in threads # - Share AI insights with the whole team ``` -------------------------------- ### Fix npm Permissions on macOS/Linux Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Resolves permission errors during global npm installations on macOS and Linux by configuring npm to use a user-specific global directory and updating the PATH environment variable. This avoids the need for `sudo`. ```bash # Fix npm permissions mkdir ~/.npm-global npm config set prefix '~/.npm-global' echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc source ~/.bashrc ``` -------------------------------- ### Perform System Status Checks with CrewCode Source: https://github.com/sowonlabs/crewcode/blob/main/docs/troubleshooting.md Provides commands for checking the system status of CrewCode. This includes running a comprehensive health check with `crewcode doctor`, verifying provider availability by querying each one, and checking configuration files. ```bash # Comprehensive health check crewcode doctor # Check provider availability crewcode query "@claude hello" crewcode query "@gemini hello" crewcode query "@copilot hello" # Verify configuration cat agents.yaml ``` -------------------------------- ### Crewcode 정식 릴리스 워크플로우 (Bash) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/development.md 정식 버전을 릴리스하는 과정입니다. develop 브랜치에서 릴리스 브랜치를 생성하고, npm을 사용하여 버전을 업데이트하며, 최종 빌드 및 배포를 수행합니다. 이후 릴리스 브랜치와 태그를 푸시하고, develop 및 main 브랜치에 병합합니다. 마지막으로 GitHub Release를 생성합니다. ```bash # 1. 릴리스 브랜치 생성 (⚠️ 중요: 누락하면 안됨) cd $(git rev-parse --show-toplevel) # 프로젝트 루트로 이동 git worktree add worktree/release-0.3.9 -b release/0.3.9 develop # 2. 릴리스 브랜치로 이동 cd worktree/release-0.3.9 # 3. 버전 업데이트 (RC suffix 제거) npm version 0.3.9 # 4. 빌드 및 배포 npm run build npm publish --access public # 5. 브랜치 및 태그 푸시 (⚠️ 중요: 누락하면 안됨) git push -u origin release/0.3.9 git push origin v0.3.9 # 6. develop 브랜치 머지 cd /Users/doha/git/crewcode git checkout develop git merge --no-ff release/0.3.9 git push origin develop # 7. main 브랜치 머지 git checkout main git merge --no-ff release/0.3.9 git push origin main # 8. GitHub Release 생성 # - 릴리스 노트 작성 # - 변경사항 요약 # - 해결된 버그 목록 ``` -------------------------------- ### Initialize CrewCode Project (`crewcode init`) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/cli-guide.md Initializes a new CrewCode project by creating a `crewcode.yaml` configuration file. It supports options to skip MCP registration, use a custom config filename, and force overwrites. This command sets up default agents and logging directories. ```bash crewcode init # Initialize with auto MCP registration crewcode init --skip-mcp # Skip MCP server registration crewcode init --config custom.yaml # Use custom config filename crewcode init --force # Overwrite existing configuration ``` -------------------------------- ### Configure Agent with Multiple Providers for Fallback (YAML) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Shows how to set up an agent that can utilize multiple AI providers in a fallback sequence. The agent will attempt to use 'claude', then 'gemini', and finally 'copilot' if the preceding providers are unavailable. ```yaml agents: - id: "flexible_agent" provider: ["claude", "gemini", "copilot"] # Tries in order ``` -------------------------------- ### TypeScript Tools Object Structure Source: https://github.com/sowonlabs/crewcode/blob/main/docs/tools.md Defines the TypeScript interface for the 'tools' object available in agent prompts. It includes properties for the number of tools, a JSON string of tool definitions, and an array of detailed tool definitions. ```typescript tools: { count: number; // Number of available tools json: string; // JSON string of tool definitions list: Array<{ // Array of tool definitions name: string; description: string; input_schema: object; output_schema?: object; }>; } ``` -------------------------------- ### Override AI Model at Runtime (Bash) Source: https://github.com/sowonlabs/crewcode/blob/main/docs/agent-configuration.md Shows how to dynamically override the AI model for an agent at runtime using the `crewcode` command-line interface. The `@agent:model` syntax allows specifying a different model for a particular query or execution. ```bash # Override model with @agent:model syntax crewcode query "@claude:haiku quick analysis" crewcode execute "@gemini:gemini-2.5-flash rapid prototyping" ```