Tools

Built-in tools available to both the AI agent and CLI users.

Overview

Codiv ships with six built-in tools. Each tool is available in two ways:

  • Agent use — the AI agent calls tools during its reasoning loop
  • CLI use — you run tools directly as codiv <tool> subcommands

Common Flags

Every tool supports these flags:

FlagPurpose
--json-inRead JSON input from stdin
--json-outOutput result as JSON ({"result": ..., "error": ...})
--agent-guidePrint the agent usage guide for this tool
--helpPrint help text

Tool Reference

Bash

Execute a shell command:

codiv bash --command "cargo test --workspace"
codiv bash --command "ls -la" --timeout 5000
ParameterRequiredDescription
--commandYesThe shell command to execute
--timeoutNoTimeout in milliseconds

Read

Read file contents with line numbers:

codiv read --path ./src/main.rs
codiv read --path ./src/main.rs --offset 10 --limit 50
ParameterRequiredDescription
--pathYesFile path to read
--offsetNoLine number to start from
--limitNoMaximum number of lines

Write

Write content to a file (creates or overwrites):

codiv write --path ./output.txt --content "Hello, world!"
ParameterRequiredDescription
--pathYesFile path to write
--contentYesContent to write

Edit

Find and replace a unique string in a file:

codiv edit --path ./src/main.rs --old-string "fn old_name" --new-string "fn new_name"
ParameterRequiredDescription
--pathYesFile path to edit
--old-stringYesText to find (must be unique in the file)
--new-stringYesReplacement text

Glob

Find files matching a pattern:

codiv glob --pattern "**/*.rs"
codiv glob --pattern "src/**/*.toml" --path ./my-project
ParameterRequiredDescription
--patternYesGlob pattern
--pathNoDirectory to search in (defaults to cwd)

Grep

Search file contents with regex:

codiv grep --pattern "fn main" --path ./src
codiv grep --pattern "TODO" --include "*.rs"
ParameterRequiredDescription
--patternYesRegex pattern to search for
--pathNoFile or directory to search in
--includeNoGlob to filter files

JSON Mode

For programmatic or scripted use, combine --json-in and --json-out:

echo '{"file_path":"./Cargo.toml"}' | codiv read --json-in --json-out

Output:

{
  "result": "     1\t[workspace]\n     2\tmembers = [\"codiv\", \"codivd\", ...]\n",
  "error": null
}