Skip to main content
Tool constraints define what actions an agent can perform. Use whitelists (tools) or blacklists (disallowedTools) to enforce read-only access, prevent shell execution, or block file creation.

Available Tools

Read Tools

Read
tool
Read files from the filesystem. Line ranges and offsets supported.
Glob
tool
Pattern-based file search. Example: **/*.ts.
Grep
tool
Content search with regex. Fast full-text search.

Write Tools

Edit
tool
Edit existing files with string replacement. Requires prior Read.
Write
tool
Create new files or overwrite existing ones.

Execution Tools

Bash
tool
Execute shell commands. Can read/write files, install packages, run tests.

Other Tools

Task
tool
Delegate to subagents or specialized tools.
WebFetch
tool
Fetch web content (documentation, APIs, etc.).
Skill
tool
Invoke user-defined skills.

Tool Whitelisting

Use tools to explicitly allow specific tools:
---
name: planner
tools: ["Read", "Glob", "Grep"]
---

Agent can explore code but not make changes.
When tools is specified, only those tools are available. All others are blocked.

Tool Blacklisting

Use disallowedTools to block specific tools:
---
name: safe-explorer
disallowedTools: ["Bash"]
---

Agent can use all tools except shell execution.
disallowedTools overrides tools. If a tool is in both lists, it’s blocked.

Common Tool Sets

Exploration Agents

---
name: explorer
tools: ["Read", "Glob", "Grep", "WebFetch"]
model: haiku
permissionMode: auto
---

Fast exploration without modifying code.
Use for: Understanding codebases, finding patterns, generating reports.

Planning Agents

---
name: planner
tools: ["Read", "Glob", "Grep"]
model: opus
---

Deep analysis and plan generation without code changes.
Use for: Architecture decisions, task breakdowns, risk assessment.

Review Agents

---
name: reviewer
tools: ["Read", "Glob", "Grep", "Bash"]
---

Code review with test execution but no modifications.
Use for: PR reviews, security audits, quality checks.

Implementation Agents

---
name: implementer
tools: ["Read", "Glob", "Grep", "Edit", "Bash"]
---

Implementation with editing and testing. No new file creation.
Use for: Refactoring, bug fixes, incremental features.

Full-Access Agents

---
name: orchestrator
tools: ["Read", "Glob", "Grep", "Bash", "Edit", "Write"]
model: opus
memory: project
---

Complete tool access for complex features.
Use for: Multi-phase development, new features, major refactors.

Tool Combinations

Read + Edit (No Create)

---
name: safe-refactor
tools: ["Read", "Edit"]
---
Allows:
  • Read existing files
  • Edit existing files
Blocks:
  • Create new files (no Write)
  • Run shell commands (no Bash)
  • Search files (no Glob/Grep)

Read + Grep + Edit (Pattern-Based Editing)

---
name: pattern-refactor
tools: ["Read", "Grep", "Edit"]
---
Allows:
  • Search for patterns
  • Read matching files
  • Edit matching files
Blocks:
  • Create new files
  • Run tests
  • File system traversal (no Glob)

Read + Bash (Validation)

---
name: validator
tools: ["Read", "Bash"]
---
Allows:
  • Read files
  • Run lint, typecheck, tests
Blocks:
  • Edit files
  • Create files
  • Search (must know file paths)

Security Considerations

Dangerous Tool: Bash

Bash has full shell access:
  • Can read/write any file
  • Can install packages
  • Can delete files
  • Can make network requests
Only grant Bash to trusted agents. Use permissionMode: ask for human oversight.

Safe Alternative: Read + Edit

For code modifications without shell access:
---
name: safe-implementer
tools: ["Read", "Glob", "Grep", "Edit"]
---

Agent can modify code but not run arbitrary shell commands.

Write Tool Risks

Write can:
  • Overwrite critical files (e.g., package.json, .env)
  • Create files outside project directory
  • Bypass git tracking
Use Edit instead of Write when possible. Edit requires reading the file first, providing a safety check.

Permission Modes

Control approval flow with permissionMode:
---
name: careful-agent
permissionMode: ask
---

Ask before every tool use.
Combine tools constraints with permissionMode: auto for fully autonomous read-only agents.

Examples by Use Case

---
name: explorer
description: Fast read-only codebase exploration
tools: ["Read", "Glob", "Grep"]
model: haiku
permissionMode: auto
background: true
---

Explore codebase in background without blocking main session.

Workflow:
1. Glob for file patterns
2. Grep for content matches
3. Read relevant files
4. Summarize findings
---
name: refactor
description: Apply safe refactorings to existing code
tools: ["Read", "Glob", "Grep", "Edit"]
permissionMode: dangerous-only
---

Refactor code without creating new files or running shell commands.

Workflow:
1. Grep for pattern to refactor
2. Read each matching file
3. Edit with transformation
4. Present summary for review
---
name: quality-gate
description: Run quality checks without modifying code
tools: ["Read", "Bash"]
permissionMode: auto
---

Run lint, typecheck, and tests.

Workflow:
1. npm run lint
2. npm run typecheck
3. npm test -- --related
4. Report results
---
name: doc-gen
description: Generate documentation from source code
tools: ["Read", "Glob", "Write", "WebFetch"]
---

Generate docs from code.

Workflow:
1. Glob for source files
2. Read each file
3. Extract types, interfaces, functions
4. WebFetch for external API docs
5. Write markdown documentation

Tool Performance

ToolSpeedContext Cost
GlobFast (<10ms)Low (paths only)
GrepFast (<50ms)Low (matches only)
ReadMedium (10-100ms)High (full file)
EditMedium (50-200ms)Medium (diff only)
WriteFast (<50ms)Medium (new content)
BashVariableVariable
Use Glob/Grep for discovery, then Read only the files you need. Avoid reading entire codebases.

Debugging Tool Constraints

If an agent can’t use a tool:
# Check agent configuration
cat .claude/agents/my-agent.md | grep -A 5 'tools:'

# Verify tool name (case-sensitive)
echo "Tools: Read, Glob, Grep, Bash, Edit, Write"

# Test with minimal agent
cat > .claude/agents/test.md <<EOF
---
name: test
tools: ["Read"]
---

Test agent with only Read tool.
EOF

Next Steps

Agent Frontmatter

Complete agent configuration

Agent Skills

Preload domain knowledge

Agent Memory

Configure memory scope

Security Guide

Agent security best practices

Build docs developers (and LLMs) love