Customization
How to modify and extend your generated agent.
The generated agent is fully customizable. This guide covers common customization scenarios and best practices.
Modifying Agent Behavior
System Prompt
The agent's personality and behavior are defined in src/agent.ts. Find the system prompt and modify it:
1const systemPrompt = `
2You are a helpful AI assistant specialized in...
3
4Your capabilities include:
5- Reading and analyzing files
6- Searching codebases
7- ...
8
9Always:
10- Be concise and precise
11- Ask for clarification when needed
12- Explain your reasoning
13`;Memory (CLAUDE.md)
Add persistent context by editing CLAUDE.md:
1# Project Context
2
3This agent assists with [your specific use case].
4
5## Important Guidelines
6
7- Always follow [specific convention]
8- Never modify files in [restricted directory]
9- Prefer [specific approach] when possibleAdding Custom Tools
Define the Tool
Add new tools in src/agent.ts:
1const customTool = {
2 name: 'my-custom-tool',
3 description: 'Description of what this tool does',
4 parameters: {
5 type: 'object',
6 properties: {
7 input: {
8 type: 'string',
9 description: 'The input to process'
10 }
11 },
12 required: ['input']
13 },
14 execute: async (params: { input: string }) => {
15 // Your implementation here
16 const result = await processInput(params.input);
17 return { success: true, result };
18 }
19};Register the Tool
Add your tool to the agent's tool list:
1const tools = [
2 // ... existing tools
3 customTool,
4];Tool best practices
Keep tools focused on a single task. It's better to have multiple specific tools than one tool that does everything.
Adding Slash Commands
Create new commands in .claude/commands/:
1Perform my custom workflow:
2
31. First, do this with $1
42. Then, analyze the results
53. Finally, generate a report
6
7Focus on: $ARGUMENTSThe command is now available as /my-command.
Adding Subagents
Create specialized subagents in .claude/agents/:
1# My Specialist
2
3## Description
4Handles [specific type of tasks].
5
6## System Prompt
7You are a specialist in [domain]. Your focus is:
8- [Specific capability 1]
9- [Specific capability 2]
10
11## Tools
12- Read
13- Write
14- Bash
15
16## Model
17sonnetModifying Hooks
Edit .claude/settings.json to add or modify hooks:
1{
2 "hooks": {
3 "PostToolUse": [
4 {
5 "name": "my-hook",
6 "matcher": "Write",
7 "command": "echo 'File written: $CLAUDE_FILE_PATH'",
8 "timeout": 5000
9 }
10 ]
11 }
12}Changing Permissions
Modify src/permissions.ts to customize security:
1// Add custom path restrictions
2const restrictedPaths = [
3 '/etc',
4 '/usr',
5 process.env.HOME + '/.ssh',
6 // Add your restrictions
7];
8
9// Add custom command filters
10const blockedCommands = [
11 'rm -rf',
12 'sudo',
13 // Add blocked patterns
14];Adding Domain Workflows
Create workflow definitions in .commands/:
1{
2 "name": "my-workflow",
3 "description": "My custom multi-step workflow",
4 "steps": [
5 {
6 "name": "step1",
7 "prompt": "First, analyze the input",
8 "tools": ["read-file", "search-files"]
9 },
10 {
11 "name": "step2",
12 "prompt": "Then, process the analysis",
13 "dependsOn": ["step1"]
14 },
15 {
16 "name": "step3",
17 "prompt": "Finally, generate output",
18 "dependsOn": ["step2"]
19 }
20 ]
21}Extending MCP Integration
Add new MCP servers by editing .mcp.json:
1{
2 "mcpServers": {
3 "existing-server": { ... },
4 "new-server": {
5 "command": "npx",
6 "args": ["-y", "@package/new-server"],
7 "env": {
8 "API_KEY": "${NEW_SERVER_API_KEY}"
9 }
10 }
11 }
12}Customizing the CLI
Modify src/cli.ts to add new commands or change behavior:
1// Add a new CLI command
2program
3 .command('analyze <path>')
4 .description('Analyze a file or directory')
5 .action(async (path) => {
6 // Your implementation
7 });
8
9// Add custom input handling
10if (input.startsWith('!')) {
11 // Handle custom prefix
12 await handleCustomCommand(input.slice(1));
13}Best Practices
Keep Changes Organized
Document your customizations. Consider adding comments explaining why changes were made.
Test Incrementally
Test after each significant change. It's easier to debug one change than many.
Version Control
Initialize git and commit regularly:
1git init
2git add .
3git commit -m "Initial generated agent"Backup Before Major Changes
Before significant modifications, create a backup or commit your current state.
Re-generating
If you need to re-generate your agent, your customizations will be lost. Consider extracting reusable customizations into separate files that you can merge back in.