packages/kilo-docs/pages/automate/tools/execute-command.md
The execute_command tool runs CLI commands on the user's system. It allows Kilo Code to perform system operations, install dependencies, build projects, start servers, and execute other terminal-based tasks needed to accomplish user objectives.
The tool accepts these parameters:
command (required): The CLI command to execute. Must be valid for the user's operating system.cwd (optional): The working directory to execute the command in. If not provided, the current working directory is used.This tool executes terminal commands directly on the user's system, enabling a wide range of operations from file manipulations to running development servers. Commands run in managed terminal instances with real-time output capture, integrated with VS Code's terminal system for optimal performance and security.
When the execute_command tool is invoked, it follows this process:
Command Validation and Security Checks:
Terminal Management:
Command Execution and Monitoring:
Result Processing:
The tool uses a sophisticated terminal management system:
First Priority: Terminal Reuse
Second Priority: Security Validation
$(...) and backticks are blockedPerformance Optimizations
Error and Signal Handling
npm init -y followed by installing dependencies.npm run build to compile assets.npm start).Running a simple command in the current directory:
<execute_command>
<command>npm run dev</command>
</execute_command>
Installing dependencies for a project:
<execute_command>
<command>npm install express mongodb mongoose dotenv</command>
</execute_command>
Running multiple commands in sequence:
<execute_command>
<command>mkdir -p src/components && touch src/components/App.js</command>
</execute_command>
Executing a command in a specific directory:
<execute_command>
<command>git status</command>
<cwd>./my-project</cwd>
</execute_command>
Building and then starting a project:
<execute_command>
<command>npm run build && npm start</command>
</execute_command>