### Bash Hook Example for PreToolUse Source: https://context7.com/hcd233/clawd-kobe/llms.txt An example Bash script for a PreToolUse hook that reads input from stdin, parses the tool command, and decides whether to block potentially dangerous commands. ```bash #!/bin/bash # hooks/validate-bash.sh - Example PreToolUse hook # Read hook input from stdin INPUT=$(cat) COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command') # Block dangerous commands if echo "$COMMAND" | grep -qE "rm -rf|:(){ :|&};:"; then echo '{"decision": "block", "reason": "Potentially dangerous command blocked"}' exit 0 fi # Allow safe commands echo '{"decision": "approve"}' ``` -------------------------------- ### Skill Definition Frontmatter Source: https://context7.com/hcd233/clawd-kobe/llms.txt Markdown frontmatter example for defining a skill, including its name, description, allowed tools, and model. ```markdown --- name: deploy description: Deploy the application to production tools: [Bash, Read, Write] model: sonnet --- # Deploy Skill When the user invokes /deploy, follow these steps: 1. Run the test suite to ensure all tests pass 2. Build the production bundle 3. Deploy to the configured environment ## Prerequisites - Ensure all environment variables are set - Verify AWS credentials are configured ## Deployment Steps ```bash npm run test npm run build aws s3 sync ./dist s3://my-bucket/ ``` ``` -------------------------------- ### Configure MCP Servers Source: https://context7.com/hcd233/clawd-kobe/llms.txt Configures MCP servers via project-level JSON or programmatically using the SDK. ```json // .mcp.json - Project-level MCP configuration { "mcpServers": { "filesystem": { "type": "stdio", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/dir"] }, "github": { "type": "stdio", "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"], "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" } }, "remote-api": { "type": "sse", "url": "https://api.example.com/mcp", "headers": { "Authorization": "Bearer ${API_TOKEN}" } } } } ``` ```typescript // Programmatic MCP server configuration via SDK import { createSdkMcpServer, tool } from '@anthropic-ai/claude-code'; import { z } from 'zod'; // Define custom tools const myTool = tool( "my_custom_tool", "Performs a custom operation", { input: z.string() }, async (args) => { return { content: [{ type: "text", text: `Processed: ${args.input}` }] }; } ); // Create SDK MCP server const mcpServer = createSdkMcpServer({ name: "my-sdk-server", version: "1.0.0", tools: [myTool] }); ``` -------------------------------- ### Configure Permission Rules in settings.json Source: https://context7.com/hcd233/clawd-kobe/llms.txt Specify allowed and denied tool usage patterns in settings.json to enforce security and control agent actions. ```json { "permissions": { "allow": [ "Bash(git *)", "Bash(npm test)", "Read(*)", "Glob(*)", "Grep(*)" ], "deny": [ "Bash(rm -rf *)", "Bash(sudo *)", "WebFetch(domain:*.internal.com)" ] } } ``` -------------------------------- ### Permission System Configuration Source: https://context7.com/hcd233/clawd-kobe/llms.txt Manage tool execution permissions using modes and explicit allow/deny rules. ```APIDOC ## Permissions Configuration ### Description Define fine-grained control over tool permissions through modes and explicit rules in settings.json. ### Request Body - **permissions** (object) - Required - Permission rules. - **allow** (array) - Optional - List of allowed tool patterns. - **deny** (array) - Optional - List of denied tool patterns. ### Request Example { "permissions": { "allow": ["Bash(git *)", "Read(*)"], "deny": ["Bash(rm -rf *)"] } } ``` -------------------------------- ### Skill Definition Source: https://context7.com/hcd233/clawd-kobe/llms.txt Define custom slash commands using markdown files with frontmatter. ```APIDOC ## Skill Definition ### Description Skills are defined via markdown files containing frontmatter that specifies the command name, description, and tool constraints. ### Frontmatter Fields - **name** (string) - Required - The slash command name (without /). - **description** (string) - Required - Description of the skill. - **tools** (array) - Optional - List of allowed tools. - **model** (string) - Optional - Model override. ### Example --- name: deploy description: Deploy the application to production tools: [Bash, Read, Write] model: sonnet --- ``` -------------------------------- ### query - Execute Single-Turn Agent Queries Source: https://context7.com/hcd233/clawd-kobe/llms.txt The `query` function is the primary entry point for running single-turn agent queries. It takes a prompt and options, executing the agent loop and streaming results back to the caller. ```APIDOC ## POST /query ### Description Executes a single-turn agent query with a given prompt and options, streaming results back. ### Method POST ### Endpoint /query ### Parameters #### Request Body - **prompt** (string) - Required - The user's prompt for the agent. - **options** (object) - Required - Configuration options for the query. - **model** (string) - Required - The Claude model to use (e.g., 'claude-sonnet-4-6'). - **permissionMode** (string) - Optional - The permission mode for tool execution (e.g., 'default'). - **maxTurns** (number) - Optional - The maximum number of turns for the agent loop. - **cwd** (string) - Optional - The current working directory for the agent. ### Request Example ```json { "prompt": "What files are in the current directory?", "options": { "model": "claude-sonnet-4-6", "permissionMode": "default", "maxTurns": 10, "cwd": "/path/to/project" } } ``` ### Response #### Success Response (200) - **type** (string) - The type of message received (e.g., 'assistant', 'result'). - **message** (object) - Contains the assistant's message content if type is 'assistant'. - **content** (string) - The assistant's response. - **result** (object) - Contains the final result if type is 'result'. - **total_cost_usd** (number) - The total cost of the query in USD. #### Response Example ```json { "type": "assistant", "message": { "content": "The files in the current directory are: ..." } } ``` ```json { "type": "result", "result": { "files": ["file1.txt", "file2.js"] }, "total_cost_usd": 0.0005 } ``` ``` -------------------------------- ### Hooks System Configuration Source: https://context7.com/hcd233/clawd-kobe/llms.txt Configure custom code execution at specific agent lifecycle events such as PreToolUse, PostToolUse, and SessionStart. ```APIDOC ## Hooks Configuration ### Description Hooks allow custom code execution at various points in the agent lifecycle. Configuration is defined in settings.json. ### Request Body - **hooks** (object) - Required - Map of event names to hook configurations. - **PreToolUse** (array) - Optional - List of hooks to run before tool execution. - **PostToolUse** (array) - Optional - List of hooks to run after tool execution. - **SessionStart** (array) - Optional - List of hooks to run at session initialization. ### Request Example { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": ["./hooks/validate-bash.sh"] } ] } } ``` -------------------------------- ### listSessions - List Available Sessions Source: https://context7.com/hcd233/clawd-kobe/llms.txt Lists all sessions with metadata, supporting pagination and project filtering. ```APIDOC ## GET /sessions ### Description Lists available sessions with metadata, supporting pagination and project filtering. ### Method GET ### Endpoint /sessions ### Parameters #### Query Parameters - **dir** (string) - Optional - The directory to filter sessions by. - **limit** (number) - Optional - The maximum number of sessions to return (default: 50). - **offset** (number) - Optional - The number of sessions to skip for pagination (default: 0). ### Response #### Success Response (200) - **sessionId** (string) - The unique identifier for the session. - **summary** (string) - A brief summary of the session. - **lastModified** (string) - The timestamp when the session was last modified. - **gitBranch** (string) - The Git branch associated with the session (if any). #### Response Example ```json [ { "sessionId": "session-uuid-abcde", "summary": "Initial setup for project X", "lastModified": "2023-10-27T10:00:00Z", "gitBranch": "main" }, { "sessionId": "session-uuid-fghij", "summary": "Refactoring component Y", "lastModified": "2023-10-27T11:30:00Z", "gitBranch": "feature/new-ui" } ] ``` ``` -------------------------------- ### Configure Hooks in settings.json Source: https://context7.com/hcd233/clawd-kobe/llms.txt Define hook configurations in settings.json to specify which scripts or functions to run for different hook events like PreToolUse or PostToolUse. ```json { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": ["./hooks/validate-bash.sh"] } ], "PostToolUse": [ { "matcher": "*", "hooks": ["./hooks/log-tool-use.js"] } ], "SessionStart": [ { "hooks": ["./hooks/setup-environment.sh"] } ] } } ``` -------------------------------- ### List Available Sessions with listSessions Source: https://context7.com/hcd233/clawd-kobe/llms.txt The `listSessions` function retrieves metadata for available sessions, supporting pagination and project filtering. Specify the directory, limit, and offset for the query. ```typescript import { listSessions } from '@anthropic-ai/claude-code'; // List sessions for a specific project const sessions = await listSessions({ dir: '/path/to/project', limit: 50, offset: 0 }); for (const session of sessions) { console.log(`Session: ${session.sessionId}`); console.log(` Summary: ${session.summary}`); console.log(` Last Modified: ${new Date(session.lastModified)}`); console.log(` Branch: ${session.gitBranch || 'N/A'}`); } ``` -------------------------------- ### unstable_v2_prompt - One-Shot Convenience Function Source: https://context7.com/hcd233/clawd-kobe/llms.txt A simplified one-shot function for single prompts that don't require session management. ```APIDOC ## POST /prompt ### Description A one-shot convenience function for executing single prompts without explicit session management. ### Method POST ### Endpoint /prompt ### Parameters #### Request Body - **prompt** (string) - Required - The prompt to send to the agent. - **options** (object) - Optional - Configuration options for the prompt. - **model** (string) - Required - The Claude model to use (e.g., 'claude-sonnet-4-6'). - **cwd** (string) - Optional - The current working directory for the prompt. ### Request Example ```json { "prompt": "Explain the purpose of this file: package.json", "options": { "model": "claude-sonnet-4-6", "cwd": "/path/to/project" } } ``` ### Response #### Success Response (200) - **result** (object) - The result of the prompt execution. - **explanation** (string) - The explanation provided by the agent. - **usage** (object) - Information about token usage. - **input_tokens** (number) - The number of input tokens used. - **output_tokens** (number) - The number of output tokens used. #### Response Example ```json { "result": { "explanation": "The package.json file is used to manage dependencies and metadata for Node.js projects." }, "usage": { "input_tokens": 150, "output_tokens": 50 } } ``` ``` -------------------------------- ### Fetch and Process Web Content Source: https://context7.com/hcd233/clawd-kobe/llms.txt Fetches URL content and converts it to markdown for processing. ```typescript // Fetch and summarize a webpage const fetchInput = { url: "https://docs.example.com/api/reference", prompt: "Extract all the API endpoints and their descriptions" }; // Result { "bytes": 45000, "code": 200, "codeText": "OK", "result": "Found 15 API endpoints:\n1. GET /users - List all users\n2. POST /users - Create user...", "durationMs": 2500, "url": "https://docs.example.com/api/reference" } ``` -------------------------------- ### Perform One-Shot Queries with unstable_v2_prompt Source: https://context7.com/hcd233/clawd-kobe/llms.txt Use `unstable_v2_prompt` for simple, single-prompt queries that do not require session management. It returns the result and token usage information. ```typescript import { unstable_v2_prompt } from '@anthropic-ai/claude-code'; // Simple one-shot query const result = await unstable_v2_prompt( "Explain the purpose of this file: package.json", { model: 'claude-sonnet-4-6', cwd: '/path/to/project' } ); console.log('Response:', result.result); console.log('Tokens used:', result.usage); ``` -------------------------------- ### Launch Subagents with Task Tool Source: https://context7.com/hcd233/clawd-kobe/llms.txt Configures and launches specialized subagents for autonomous tasks, supporting background execution and resuming previous sessions. ```typescript // Launch a general-purpose research agent const taskInput = { description: "Find authentication code", prompt: "Search the codebase and explain how user authentication is implemented. Look at login flows, session management, and any OAuth integrations.", subagent_type: "general-purpose", model: "haiku" // Optional: use faster model for simple tasks }; // Launch agent in background const backgroundAgent = { description: "Run full test suite", prompt: "Run all tests and fix any failures you find", subagent_type: "general-purpose", run_in_background: true }; // Resume a previous agent const resumeAgent = { description: "Continue previous work", prompt: "Continue investigating the bug", resume: "agent-id-from-previous-run" }; // Result (sync completion) { "status": "completed", "result": "Found authentication implementation in src/auth/...", "usage": { "inputTokens": 5000, "outputTokens": 2000 } } // Result (async/background) { "status": "async_launched", "agentId": "agent-abc123", "outputFile": "/path/to/agent-output.jsonl" } ``` -------------------------------- ### Create Persistent Multi-Turn Sessions with unstable_v2_createSession Source: https://context7.com/hcd233/clawd-kobe/llms.txt Utilize `unstable_v2_createSession` to establish persistent sessions for multi-turn conversations, maintaining state across interactions. Configure model, working directory, permission mode, and system prompt. ```typescript import { unstable_v2_createSession } from '@anthropic-ai/claude-code'; // Create a new persistent session const session = unstable_v2_createSession({ model: 'claude-sonnet-4-6', cwd: '/path/to/project', permissionMode: 'acceptEdits', systemPrompt: 'You are a helpful coding assistant.' }); // Send messages within the session const response1 = await session.send("Create a new React component"); console.log(response1); const response2 = await session.send("Now add TypeScript types to it"); console.log(response2); // Session maintains context across turns await session.close(); ``` -------------------------------- ### Define a custom agent configuration Source: https://context7.com/hcd233/clawd-kobe/llms.txt Use this JSON structure to define subagent capabilities, tools, and memory settings. ```json // .claude/agents/code-reviewer.json { "description": "Reviews code changes for quality and best practices", "prompt": "You are a code reviewer. Analyze the provided code changes for:\n- Code quality\n- Potential bugs\n- Performance issues\n- Security concerns\n\nProvide specific, actionable feedback.", "tools": ["Read", "Glob", "Grep", "LSP"], "model": "sonnet", "maxTurns": 20, "memory": "project" } ``` -------------------------------- ### Find Files by Pattern Source: https://context7.com/hcd233/clawd-kobe/llms.txt Fast file pattern matching using glob patterns, returning files sorted by modification time. Results are limited to 100 files. ```typescript // Find all TypeScript files const globInput = { pattern: "**/*.ts", path: "/path/to/project" // Optional, defaults to cwd }; // Find specific file types in subdirectory const specificGlob = { pattern: "src/components/**/*.tsx" }; // Result { "durationMs": 45, "numFiles": 23, "filenames": [ "src/components/App.tsx", "src/components/Header.tsx", "src/components/Footer.tsx" ], "truncated": false // Limited to 100 files } ``` -------------------------------- ### Create or Overwrite Files Source: https://context7.com/hcd233/clawd-kobe/llms.txt Writes content to files, creating new files or completely overwriting existing ones. The result indicates the type of operation ('create' or 'update'). ```typescript // Create new file const writeInput = { file_path: "/path/to/new-file.ts", content: `import React from 'react'; export function MyComponent() { return
Hello World
; } ` }; // Result { "type": "create", // or "update" for existing files "filePath": "/path/to/new-file.ts", "content": "...", "structuredPatch": [...] } ``` -------------------------------- ### Execute Single-Turn Agent Queries with query Source: https://context7.com/hcd233/clawd-kobe/llms.txt Use the `query` function for single-turn agent interactions. It handles the agent loop and streams results. Specify model, permission mode, max turns, and current working directory in options. ```typescript import { query } from '@anthropic-ai/claude-code'; // Basic single-turn query const result = query({ prompt: "What files are in the current directory?", options: { model: 'claude-sonnet-4-6', permissionMode: 'default', maxTurns: 10, cwd: '/path/to/project' } }); // Stream results from the query for await (const message of result) { if (message.type === 'assistant') { console.log('Assistant:', message.message.content); } else if (message.type === 'result') { console.log('Final result:', message.result); console.log('Cost:', message.total_cost_usd); } } ``` -------------------------------- ### Manage Task Lists with TodoWrite Source: https://context7.com/hcd233/clawd-kobe/llms.txt Maintains a structured task list. Ensure only one task is marked as 'in_progress' at any time. ```typescript // Create/update todo list const todoInput = { todos: [ { content: "Implement user authentication", status: "completed", activeForm: "Implementing user authentication" }, { content: "Add input validation", status: "in_progress", activeForm: "Adding input validation" }, { content: "Write unit tests", status: "pending", activeForm: "Writing unit tests" } ] }; // Status values: "pending" | "in_progress" | "completed" // Keep exactly ONE task "in_progress" at a time ``` -------------------------------- ### unstable_v2_createSession - Create Persistent Multi-Turn Sessions Source: https://context7.com/hcd233/clawd-kobe/llms.txt Creates a persistent session for multi-turn conversations, allowing state to be maintained across multiple interactions. ```APIDOC ## POST /sessions/create ### Description Creates a persistent session for multi-turn conversations, maintaining state across interactions. ### Method POST ### Endpoint /sessions/create ### Parameters #### Request Body - **model** (string) - Required - The Claude model to use (e.g., 'claude-sonnet-4-6'). - **cwd** (string) - Optional - The current working directory for the session. - **permissionMode** (string) - Optional - The permission mode for tool execution (e.g., 'acceptEdits'). - **systemPrompt** (string) - Optional - A system prompt to guide the agent's behavior. ### Request Example ```json { "model": "claude-sonnet-4-6", "cwd": "/path/to/project", "permissionMode": "acceptEdits", "systemPrompt": "You are a helpful coding assistant." } ``` ### Response #### Success Response (200) - **sessionId** (string) - The unique identifier for the created session. - **send** (function) - A function to send messages within the session. - **close** (function) - A function to close the session. #### Response Example ```json { "sessionId": "session-uuid-12345", "send": "[Function: send]", "close": "[Function: close]" } ``` ``` -------------------------------- ### Skill Frontmatter Options Interface Source: https://context7.com/hcd233/clawd-kobe/llms.txt TypeScript interface defining the structure and types for skill frontmatter options, including name, description, tools, model, and hook configurations. ```typescript // Skill frontmatter options interface SkillFrontmatter { name: string; // Skill name (without /) description: string; // What the skill does tools?: string[]; // Allowed tools model?: string; // Model override whenToUse?: string; // Natural language description argumentHint?: string; // Argument hint (e.g., "") hooks?: HooksSettings; // Skill-specific hooks } ``` -------------------------------- ### Perform Exact String Replacements Source: https://context7.com/hcd233/clawd-kobe/llms.txt Performs exact string replacements in files. Requires reading the file first. Set `replace_all: true` to replace all occurrences. ```typescript // Single replacement const editInput = { file_path: "/path/to/file.ts", old_string: "const x = 1;", new_string: "const x = 42;", replace_all: false // Only replace first occurrence }; // Replace all occurrences (useful for renaming) const renameInput = { file_path: "/path/to/file.ts", old_string: "oldVariableName", new_string: "newVariableName", replace_all: true }; // Result includes diff information { "type": "update", "filePath": "/path/to/file.ts", "structuredPatch": [ { "oldStart": 10, "newStart": 10, "oldLines": 1, "newLines": 1, "lines": ["-const x = 1;", "+const x = 42;"] } ] } ``` -------------------------------- ### Handle SDK message streaming Source: https://context7.com/hcd233/clawd-kobe/llms.txt Use this pattern to process various message types and events emitted during query execution. ```typescript // Message type union type SDKMessage = | SDKUserMessage | SDKAssistantMessage | SDKResultMessage | SDKSystemMessage | SDKPartialAssistantMessage // Streaming deltas | SDKToolProgressMessage | SDKTaskNotificationMessage | SDKRateLimitEvent; // Handle streamed messages for await (const msg of query({ prompt: "..." })) { switch (msg.type) { case 'system': if (msg.subtype === 'init') { console.log('Session started:', msg.session_id); console.log('Tools available:', msg.tools); console.log('Model:', msg.model); } break; case 'assistant': console.log('Assistant message:', msg.message.content); break; case 'stream_event': // Real-time streaming delta if (msg.event.type === 'content_block_delta') { process.stdout.write(msg.event.delta.text || ''); } break; case 'tool_progress': console.log(`Tool ${msg.tool_name} running... (${msg.elapsed_time_seconds}s)`); break; case 'result': if (msg.subtype === 'success') { console.log('Completed:', msg.result); console.log('Cost: $' + msg.total_cost_usd.toFixed(4)); } else { console.error('Error:', msg.errors); } break; } } ``` -------------------------------- ### Hook Input and Output Types Source: https://context7.com/hcd233/clawd-kobe/llms.txt TypeScript interfaces for the JSON data passed to and expected from hooks. PreToolUseHookInput defines the structure of data received by a PreToolUse hook, and HookOutput defines the structure of data returned to the agent. ```typescript // Hook input types (passed as JSON to stdin) interface PreToolUseHookInput { hook_event_name: "PreToolUse"; session_id: string; transcript_path: string; cwd: string; tool_name: string; tool_input: unknown; tool_use_id: string; } // Hook output (JSON on stdout) interface HookOutput { continue?: boolean; // Whether to proceed (default: true) decision?: "approve" | "block"; reason?: string; hookSpecificOutput?: { hookEventName: "PreToolUse"; permissionDecision?: "allow" | "deny" | "ask"; updatedInput?: Record; additionalContext?: string; }; } ``` -------------------------------- ### Search File Contents with Grep Source: https://context7.com/hcd233/clawd-kobe/llms.txt Powerful content search using ripgrep, supporting regex patterns, context lines, and multiple output modes. Use `output_mode` to specify 'content', 'files_with_matches', or 'count'. ```typescript // Search for pattern with context const grepInput = { pattern: "function\s+\w+", // Regex pattern path: "/path/to/project", glob: "*.ts", // Filter to TypeScript files output_mode: "content", // Show matching lines "-A": 2, // 2 lines after "-B": 2, // 2 lines before "-i": true, // Case insensitive head_limit: 50 // Limit results }; // Find files containing pattern const filesOnlyGrep = { pattern: "TODO|FIXME", output_mode: "files_with_matches", type: "js" // Use ripgrep's type filter }; // Count matches const countGrep = { pattern: "import", output_mode: "count" }; // Multiline pattern matching const multilineGrep = { pattern: "interface\s+\{[\s\S]*?\}", multiline: true }; // Result (content mode) { "mode": "content", "numFiles": 5, "numLines": 23, "content": "src/App.ts:10: function handleClick() {\nsrc/App.ts:11: console.log('clicked');\n..." } ``` -------------------------------- ### Define Permission Modes in TypeScript Source: https://context7.com/hcd233/clawd-kobe/llms.txt TypeScript type definitions for available permission modes that control how the agent handles tool usage and prompts the user. ```typescript // Permission modes type PermissionMode = | 'default' // Standard behavior, prompts for dangerous operations | 'acceptEdits' // Auto-accept file edit operations | 'bypassPermissions' // Bypass all checks (requires explicit opt-in) | 'plan' // Planning mode, no actual execution | 'dontAsk'; // Don't prompt, deny if not pre-approved // Configure via SDK options const options = { permissionMode: 'acceptEdits', allowDangerouslySkipPermissions: false }; ``` -------------------------------- ### Execute Bash Commands Source: https://context7.com/hcd233/clawd-kobe/llms.txt Executes bash commands in a persistent shell session with timeout, sandboxing, and background execution support. Use `run_in_background: true` for long-running tasks. ```typescript const bashInput = { command: "git status && git log --oneline -5", description: "Check git status and recent commits", timeout: 60000, // 60 second timeout (max 600000ms) run_in_background: false // Set true for long-running tasks }; // Example tool result { "stdout": "On branch main\nYour branch is up to date...\n\nabc1234 Fix bug\ndef5678 Add feature", "stderr": "", "exitCode": 0, "durationMs": 150 } // Background execution returns task ID for later retrieval const backgroundInput = { command: "npm run build", description: "Build the project", run_in_background: true }; // Result: { "task_id": "shell-abc123", "output_file": "/path/to/output" } ``` -------------------------------- ### Integrate LSP Tool for Code Intelligence Source: https://context7.com/hcd233/clawd-kobe/llms.txt Provides various code intelligence operations such as definition lookup, reference finding, and symbol searching. ```typescript // Go to definition const definitionInput = { operation: "goToDefinition", filePath: "/path/to/file.ts", line: 25, // 1-based line number character: 15 // 1-based character offset }; // Find all references const referencesInput = { operation: "findReferences", filePath: "/path/to/file.ts", line: 10, character: 8 }; // Get hover documentation const hoverInput = { operation: "hover", filePath: "/path/to/file.ts", line: 30, character: 12 }; // List document symbols const symbolsInput = { operation: "documentSymbol", filePath: "/path/to/file.ts", line: 1, character: 1 }; // Search workspace symbols const workspaceSymbolInput = { operation: "workspaceSymbol", filePath: "/path/to/file.ts", line: 1, character: 1 }; // Call hierarchy (incoming/outgoing calls) const callsInput = { operation: "incomingCalls", // or "outgoingCalls" filePath: "/path/to/file.ts", line: 50, character: 10 }; ``` -------------------------------- ### Read File Contents Source: https://context7.com/hcd233/clawd-kobe/llms.txt Reads files from the filesystem, supporting various formats like images, PDFs, and Jupyter notebooks. Use `offset` and `limit` for paginating large files. ```typescript // Read entire file const readInput = { file_path: "/absolute/path/to/file.ts" }; // Read specific lines (for large files) const paginatedRead = { file_path: "/path/to/large-file.ts", offset: 100, // Start at line 100 limit: 200 // Read 200 lines }; // Example result with line numbers { "content": " 1\timport React from 'react';\n 2\t\n 3\texport function App() {. பல்", "lineCount": 150, "truncated": false } // Images are returned as visual content for multimodal analysis // PDFs are extracted and converted to text // Jupyter notebooks return cells with outputs ``` -------------------------------- ### Read Session Transcript with getSessionMessages Source: https://context7.com/hcd233/clawd-kobe/llms.txt Retrieve conversation messages from a session's transcript file using `getSessionMessages`. You can filter by session ID and specify options like including system messages and limiting the number of results. ```typescript import { getSessionMessages } from '@anthropic-ai/claude-code'; // Read messages from a session const messages = await getSessionMessages( 'session-uuid-here', { dir: '/path/to/project', includeSystemMessages: true, limit: 100 } ); for (const msg of messages) { if (msg.type === 'user') { console.log('User:', msg.content); } else if (msg.type === 'assistant') { console.log('Assistant:', msg.content); } } ``` -------------------------------- ### Agent definition TypeScript interface Source: https://context7.com/hcd233/clawd-kobe/llms.txt Reference this interface to ensure type safety when defining agents programmatically. ```typescript // Agent definition schema interface AgentDefinition { description: string; // When to use this agent prompt: string; // System prompt tools?: string[]; // Allowed tools (inherits if omitted) disallowedTools?: string[]; // Explicitly blocked tools model?: string; // Model alias or full ID maxTurns?: number; // Max agentic turns mcpServers?: (string | Record)[]; skills?: string[]; // Skills to preload initialPrompt?: string; // Auto-submitted first message background?: boolean; // Run as background task memory?: 'user' | 'project' | 'local'; effort?: 'low' | 'medium' | 'high' | 'max' | number; permissionMode?: PermissionMode; } ``` -------------------------------- ### getSessionMessages - Read Session Transcript Source: https://context7.com/hcd233/clawd-kobe/llms.txt Reads conversation messages from a session's transcript file. ```APIDOC ## GET /sessions/{sessionId}/messages ### Description Reads conversation messages from a specific session's transcript file. ### Method GET ### Endpoint /sessions/{sessionId}/messages ### Parameters #### Path Parameters - **sessionId** (string) - Required - The unique identifier of the session. #### Query Parameters - **dir** (string) - Optional - The directory to scope the session lookup. - **includeSystemMessages** (boolean) - Optional - Whether to include system messages in the transcript. - **limit** (number) - Optional - The maximum number of messages to retrieve. ### Response #### Success Response (200) - **type** (string) - The type of message ('user' or 'assistant'). - **content** (string) - The content of the message. #### Response Example ```json [ { "type": "user", "content": "Create a new React component." }, { "type": "assistant", "content": "Okay, I've created a new React component named MyComponent." }, { "type": "user", "content": "Now add TypeScript types to it." } ] ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.