Skip to content
Esc
↑↓navigate↵open⌘Jpreview
Start
On this page

Dynamic Meta-Tools

Save a shell command as a named, reusable tool that persists across sessions. Meta-tools let you extend Autohand's capabilities without writing code.

What are meta-tools?

A meta-tool is a single shell command template with a name, a description, and a JSON Schema for its inputs. The agent can create one during a session and it stays available in this and future sessions. They’re useful for:

  • Repetitive tasks: Create a tool once, use it forever
  • Project-specific workflows: Encode your project’s unique commands
  • Team standardization: Share tools across your organization

Meta-tools are stored as one JSON file per tool. User-scope tools live in ~/.autohand/tools/ (or $AUTOHAND_HOME/tools/). Project-scope tools live in .autohand/tools/ at the workspace root. See Scopes.

Creating a meta-tool

Ask Autohand for a tool. The agent calls the built-in create_meta_tool tool:

# Ask Autohand to create a tool
"Create a tool called deploy_staging that runs our staging deployment script"

# Autohand calls create_meta_tool and writes:
# ~/.autohand/tools/deploy_staging.json

create_meta_tool takes these fields:

Field Required Rules
name Yes snake_case. Must match ^[a-z][a-z0-9_]*$, for example deploy_staging
description Yes 1 to 300 characters. Shown to the model and in /tools
parameters Yes A JSON Schema object. The top level must have "type": "object"
handler Yes One shell command string, 1 to 2,000 characters after trimming
scope No user (default) or project

A new tool is registered at once and can be called in the same session.

Tool structure

A saved meta-tool file looks like this. Autohand adds schemaVersion, source, timestamps and a fingerprint (a SHA-256 of the name, description, parameters and handler) when it writes the file:

{
  "name": "deploy_staging",
  "description": "Deploy a branch to the staging environment",
  "parameters": {
    "type": "object",
    "properties": {
      "branch": {
        "type": "string",
        "description": "Git branch to deploy"
      }
    },
    "required": ["branch"]
  },
  "handler": "npm run deploy:staging -- --branch {{branch}}",
  "source": "agent",
  "scope": "user",
  "schemaVersion": 1,
  "createdAt": "2026-10-15T09:00:00.000Z",
  "updatedAt": "2026-10-15T09:00:00.000Z",
  "fingerprint": "3f1c..."
}

The handler is always a string. There are no handler objects and no file or composite handler types. To run several steps, chain them in the one command, for example npm run build && npm test.

Files that fail validation are skipped at load time and reported by /tools doctor.

Handler templates

The only template syntax is {{param}}. Each placeholder is replaced with the value of the argument of the same name. There are no conditionals, loops or helpers.

Syntax Description Example
{{param}} Insert the argument value, shell-escaped git checkout {{branch}}
  • Escaping: Every value is wrapped in single quotes, with embedded single quotes escaped, so the shell treats it as one literal argument.
  • Quoted placeholders: "{{param}}" and '{{param}}' are replaced as a whole by the escaped value, so you do not get double quoting.
  • Every placeholder is required: If an argument for any placeholder is missing or null, the call fails with Missing required parameter "<name>". List every placeholder in the schema’s required array so the model knows to supply it.

Execution and limits

Limit Value
Handler length 2,000 characters
Description length 300 characters
Working directory The workspace root
Shell Runs through the system shell, so pipes and && work
Timeout 120 seconds per call
Output stdout and stderr are each truncated at 200,000 characters
Exit code A non-zero exit is reported to the agent as a failed tool call

Duplicate tools

Autohand nudges the agent to reuse tools rather than pile up near-copies. create_meta_tool checks, in order:

  • Same name, same definition: The existing tool is reused and nothing is written.
  • Same name, different definition: Rejected with already exists with a different definition.
  • Name of a built-in or other registered tool: Rejected with conflicts with existing tool.
  • Same handler: Rejected if another meta-tool has the same handler after whitespace is collapsed.
  • Similar tool: Rejected if the name or description overlaps an existing tool’s by 75% or more of meaningful words. The error names the tool to reuse.

Scopes

Scope Directory Available in
user (default) ~/.autohand/tools/ Every workspace
project <workspace>/.autohand/tools/ That repository only

If the same name exists in both scopes, the project tool is used. Standalone meta-tools also take precedence over tools contributed by CLI extensions. Disabled tools are not loaded.

--plugin-dir <path> replaces the user tools directory for that run.

Security

  • Parameter escaping: Argument values are single-quoted before substitution (see Handler templates).
  • Dangerous pattern detection: The handler is checked against a fixed list of patterns when a tool is created, saved and loaded. A match rejects the tool.
  • Permission inheritance: Each call is authorized as run_command with the fully expanded command, so your allow and deny lists, approval prompts and permission hooks apply.

The blocked patterns are these case-insensitive regular expressions, matched against the handler template:

Pattern Blocks
rm\s+(-[rf]+\s+)*\/(?!\w) rm with root path
rm\s+.*--no-preserve-root rm –no-preserve-root
dd\s+.*(?:of|if)=\/dev\/[sh]d dd to disk device
mkfs\. filesystem format
wipefs disk wipe
\bsudo\s sudo command
\bsu\s+-?\s*\w su command
chmod\s+[0-7]*7[0-7]* world-writable chmod
chown\s+root chown to root
`curl\s+.*\ \s*(ba)?sh`
`wget\s+.*\ \s*(ba)?sh`
\beval\s+[`$] eval with expansion
`:()\s*{\s*:\s*\ \s*:\s*&\s*}\s*;`
while\s+true.*do.*done infinite loop
nc\s+.*-e\s*\/bin netcat reverse shell
ncat\s+.*-e\s*\/bin ncat reverse shell
bash\s+-i\s+>&?\s*\/dev\/tcp bash reverse shell
iptables\s+-F flush firewall rules
gpg\s+.*--encrypt.*-r\s+\S+\s+\/ gpg encrypt root

The list catches known destructive shapes. It is not a sandbox, so review every handler before you rely on it.

Managing meta-tools

Use the /tools slash command:

/tools list                              # name, scope, enabled/disabled, description
/tools show deploy_staging               # full definition, handler and parameters
/tools doctor                            # files that were skipped and why
/tools disable deploy_staging            # keep the file, stop loading the tool
/tools enable deploy_staging
/tools rename deploy_staging deploy_stg  # new name must be snake_case
/tools delete deploy_staging

/tools with no argument runs list. When a name exists in both scopes, disable, enable, rename and delete act on the project copy.

You can also edit the JSON files directly. Autohand reloads the tool directories at the start of each prompt, so hand edits apply from your next message without a restart.

Example meta-tools

Changed files since a branch

{
  "name": "changed_files_since",
  "description": "List files changed between a base branch and HEAD",
  "parameters": {
    "type": "object",
    "properties": {
      "base": {
        "type": "string",
        "description": "Base branch or commit, for example main"
      }
    },
    "required": ["base"]
  },
  "handler": "git diff --name-only {{base}}...HEAD",
  "scope": "project"
}

Run one test file

{
  "name": "run_test_file",
  "description": "Run the test suite for a single file",
  "parameters": {
    "type": "object",
    "properties": {
      "file": {
        "type": "string",
        "description": "Path to the test file"
      }
    },
    "required": ["file"]
  },
  "handler": "npx vitest run {{file}} 2>&1 | tail -n 100"
}

Last updated on

Was this helpful?

Send Feedback

Help us improve this documentation page. Your feedback is valuable.

We'll only contact you if we need clarification