Run Command
Execute single tasks non interactively
The run command lets you execute a single Kodezi task without entering interactive mode, making it perfect for automation, CI/CD pipelines, shell scripts, and quick one-off actions.
When to Use kodezi run
Use run when you want:
- A single AI task (no conversation)
- Fast execution without loading the full interactive interface
- Automation inside scripts or dev workflows
- CI/CD integration (GitHub Actions, GitLab CI, Jenkins, etc.)
Usage
kodezi run [flags] "task description"Examples:
kodezi run "Run all tests and report failures"
kodezi run "Fix linting errors in src/"
kodezi run "Generate API documentation"Flags
--quiet, -q (Silent Mode)
Suppresses spinner animations and reduces output, ideal for scripts
kodezi run "run tests" --quiet
kodezi run "run tests" -qReading Input from stdin
You can pipe any text into the command:
echo "What is this code doing?" | kodezi runOr combine stdin + a custom prompt:
cat file.txt | kodezi run "Explain this"This is useful for piping file contents or logs into the AI.
How It Differs from Interactive Mode
| Feature | Interactive Mode | Run Command |
|---|---|---|
| Interface | Conversational | Single execution |
| Session | Persistent | Ephemeral |
| Use Case | Development | Automation |
| Multiple Tasks | Yes | No (one task) |
Common Use Cases
Quick One/Off Tasks
Ideal for fast, single purpose actions that don’t require entering interactive mode:
kodezi run "Find all files with TODO comments"
kodezi run "Update copyright year to 2024"
kodezi run "Remove unused imports"Use this when you need something done instantly without starting a full session.
CI/CD Pipelines
Integrate AI powered checks directly into automated workflows:
# GitHub Actions example
- name: Analyze Code
run: kodezi run "Check for security vulnerabilities"Useful for automated code reviews, security scans, and documentation generation.
Pre-commit Hooks
Automatically enforce quality checks before a commit is allowed:
#!/bin/bash
# .git/hooks/pre-commit
kodezi run "Check code style and fix issues" --yoloThis ensures consistent code quality across your team.
Scripts
Use AI tasks as part of your build, test, or deployment scripts:
#!/bin/bash
# build.sh
kodezi run "Validate all API schemas"
kodezi run "Generate TypeScript definitions"
npm run buildGreat for automating repetitive development tasks.
Global Flags
The run command supports all global flags available in Kodezi CLI.
Auto-approve permissions (use with caution)
kodezi run "fix lint errors" --yolo
kodezi run "fix lint errors" -yUse custom working directory
kodezi run "run tests" --cwd /path/to/project
kodezi run "run tests" -c /path/to/projectUse custom data directory
kodezi run "task" --data-dir /path/to/dir
kodezi run "task" -D /path/to/dirEnable debug logging
kodezi run "task" --debug
kodezi run "task" -dSee kodezi --help for all flags.
Exit Codes
Understanding Exit Codes
The run command follows standard Unix exit codes so your scripts can detect success or failure automatically.
0- Success: Task completed successfully1- Task failed: The requested task encountered an error- Non-zero - Error occurred: A system or configuration error happened
These exit codes allow you to integrate the run command into shell scripts with proper error handling.
Use in scripts:
if kodezi run "run tests"; then
echo "Tests passed"
deploy_app
else
echo "Tests failed"
exit 1
fiThis allows kodezi run to integrate cleanly with shell scripts, CI pipelines, and automation workflows.
Related Commands
- interactive mode: Interactive conversational mode
kodezi-cli logs: View execution logs