Skip to content

Tools Reference

Tools are the building blocks that allow the Kuse Cowork agent to interact with your system and codebase.

Overview

The agent can use tools to:

  • Read and modify files
  • Execute shell commands
  • Search and navigate codebases
  • Run code in isolated containers

File Operations

read_file

Read the contents of a file.

Parameters:

ParameterTypeRequiredDescription
pathstringYesPath to the file

Example:

json
{
  "name": "read_file",
  "input": {
    "path": "src/components/Button.tsx"
  }
}

Features:

  • Supports ~ expansion for home directory
  • Handles large files with truncation
  • Returns line numbers for easy reference

write_file

Create or overwrite a file.

Parameters:

ParameterTypeRequiredDescription
pathstringYesPath to the file
contentstringYesContent to write

Example:

json
{
  "name": "write_file",
  "input": {
    "path": "src/utils/helpers.ts",
    "content": "export function helper() {\n  return true;\n}"
  }
}

Features:

  • Creates parent directories if needed
  • Overwrites existing files
  • Supports any text content

edit_file

Make targeted edits to an existing file.

Parameters:

ParameterTypeRequiredDescription
pathstringYesPath to the file
old_contentstringYesText to find and replace
new_contentstringYesReplacement text

Example:

json
{
  "name": "edit_file",
  "input": {
    "path": "src/config.ts",
    "old_content": "const DEBUG = false;",
    "new_content": "const DEBUG = true;"
  }
}

Features:

  • Precise search-and-replace
  • Preserves file formatting
  • Supports multi-line edits
  • Reports if match not found

list_dir

List contents of a directory.

Parameters:

ParameterTypeRequiredDescription
pathstringYesDirectory path

Example:

json
{
  "name": "list_dir",
  "input": {
    "path": "src/components"
  }
}

Output:

Button.tsx
Card.tsx
Modal/
  index.tsx
  styles.css

Search Operations

glob

Find files matching a pattern.

Parameters:

ParameterTypeRequiredDescription
patternstringYesGlob pattern
pathstringNoBase directory (default: project root)

Example:

json
{
  "name": "glob",
  "input": {
    "pattern": "**/*.test.ts",
    "path": "src"
  }
}

Pattern Examples:

PatternMatches
*.tsTypeScript files in current dir
**/*.tsAll TypeScript files recursively
src/**/*.{ts,tsx}TS/TSX files in src
!**/node_modules/**Exclude node_modules

grep

Search file contents.

Parameters:

ParameterTypeRequiredDescription
patternstringYesRegex pattern to search
pathstringNoDirectory or file to search
includestringNoFile pattern to include

Example:

json
{
  "name": "grep",
  "input": {
    "pattern": "function handleSubmit",
    "path": "src",
    "include": "*.tsx"
  }
}

Output:

src/components/Form.tsx:45: function handleSubmit(event) {
src/components/Login.tsx:23: function handleSubmit() {

Command Execution

bash

Execute shell commands.

Parameters:

ParameterTypeRequiredDescription
commandstringYesCommand to execute
cwdstringNoWorking directory

Example:

json
{
  "name": "bash",
  "input": {
    "command": "npm test -- --coverage",
    "cwd": "/workspace"
  }
}

Features:

  • Runs in project context
  • Captures stdout and stderr
  • Has timeout protection
  • Returns exit code

Security

Commands run on your local system. Be cautious with destructive commands.

docker_run

Run commands in Docker containers.

Parameters:

ParameterTypeRequiredDescription
commandstringYesCommand to run
imagestringNoDocker image (default: python:3.11-alpine)
workdirstringNoWorking directory (default: /workspace)

Example:

json
{
  "name": "docker_run",
  "input": {
    "command": "python script.py",
    "image": "python:3.11-alpine",
    "workdir": "/workspace"
  }
}

Available Images:

ImageUse Case
python:3.11-alpinePython scripts (default)
node:20Node.js scripts
ubuntu:latestGeneral purpose
rust:alpineRust compilation

Mount Points:

Host PathContainer PathAccess
Project folder/workspaceRead/Write
Skills directory/skillsRead-only

docker_list

List running Docker containers.

Parameters: None

Example:

json
{
  "name": "docker_list",
  "input": {}
}

docker_images

List available Docker images.

Parameters: None

Example:

json
{
  "name": "docker_images",
  "input": {}
}

MCP Tools

When MCP servers are connected, additional tools become available dynamically:

json
{
  "name": "mcp_servername_toolname",
  "input": {
    "param1": "value1"
  }
}

See MCP Protocol for details.

Tool Execution Flow

Error Handling

Common Errors

ErrorCauseSolution
File not foundInvalid pathCheck path with list_dir or glob
Permission deniedAccess restrictedCheck file permissions
Container failedDocker issueVerify Docker is running
Match not foundEdit target missingVerify exact match exists
TimeoutLong-running commandBreak into smaller operations

Error Response Format

json
{
  "tool_use_id": "tool_123",
  "content": "Error: File not found: /path/to/file.txt",
  "is_error": true
}

Best Practices

File Operations

Read Before Edit

Always read a file before editing to understand its current state.

Use Exact Matches

For `edit_file`, use the exact text including whitespace.

Prefer edit_file

Use `edit_file` for modifications, `write_file` only for new files.

Search Operations

Start Broad

Use `glob` to find files, then `grep` to search within them.

Use Specific Patterns

More specific patterns are faster and produce fewer results.

Command Execution

Prefer Docker

Use `docker_run` for risky or experimental commands.

Check Exit Codes

Tool results include exit codes for command success/failure.

Performance

Batch Operations

Combine related operations to reduce API calls.

Use Working Directory

Set `cwd` to avoid long absolute paths.

Tool Configuration

Allowed Tools

Tools can be restricted per task:

rust
AgentConfig {
    allowed_tools: vec![
        "read_file".to_string(),
        "glob".to_string(),
        "grep".to_string(),
    ],
}

Docker Settings

Container resource limits:

  • Memory: Default unlimited
  • CPU: Default unlimited
  • Timeout: 5 minutes per command
  • Network: Host network by default

Next Steps

Released under the MIT License.