Autohand Code CLI Quick Start
Master the Autohand Code command-line interface in minutes. Learn essential commands and productivity workflows for AI-assisted coding.
Your First Commands
Start with these essential commands to get familiar with the Autohand Code CLI:
Check Installation
# Install Autohand Code
curl -fsSL https://autohand.ai/install.sh | bash
# Or install with npm
npm install -g autohand-cli
# Check the installed version
autohand --version
# Check runtime, config, tools, and account
autohand doctor
# Show help
autohand --help
Authentication
# Sign in to your account
autohand login
# Check account and installation status
autohand doctor
# Sign out
autohand logout
Quick Code Generation
# Start an interactive session in your project
cd my-project
autohand
# Run a single instruction and exit
autohand -p "Create a function that validates email addresses in src/utils/email.ts"
# Choose a model for one run
autohand -p "Write a Python function that sorts a list of objects by date" --model your-model
Essential Workflows
Master these common workflows to boost your productivity:
1. Rapid Prototyping
# Create a project folder and describe what you want
mkdir my-project && cd my-project
autohand -p "Create an Express.js server with CORS and middleware in server.js, a package.json, and a React dashboard component in components/Dashboard.jsx"
# Create an AGENTS.md file with project instructions
autohand init
# Install dependencies
npm install
# Start development
npm run dev
2. Code Refactoring
# Refactor legacy code
autohand -p "Refactor old-code.js to modern ES modules and async/await"
# Add error handling
autohand -p "Add error handling to app.js"
# Add logging
autohand -p "Add structured logging to service.js"
# Plan a larger change before editing
autohand --plan -p "Plan how to speed up the queries in database.js"
3. Test Generation
# Generate unit tests
autohand -p "Write unit tests for user-service.js and run them"
# Generate integration tests
autohand -p "Add integration tests for the routes in api.js"
# Generate test data
autohand -p "Create a fixture file with 100 sample users that match the user schema"
4. Documentation Generation
# Generate API documentation
autohand -p "Document the public API in docs/api.md"
# Add code documentation
autohand -p "Add doc comments to the exported functions in src/"
# Generate a README
autohand -p "Write a README.md for this project"
# Generate a changelog
git log v1.0.0..v1.1.0 --oneline | autohand -p "Write a changelog for these commits"
Productivity Tips
Use Aliases for Common Commands
# Add to your .bashrc or .zshrc
alias ahp='autohand -p'
alias ahr='autohand --restricted -p'
# Usage
ahp "Create a React Button component in Button.jsx"
ahr "Explain what utils.js does"
Pipe Mode for Workflows
# Pipe a file into a prompt
cat requirements.txt | autohand -p "Create an installation script for these requirements"
# Review recent changes
git diff | autohand -p "Review this diff for bugs"
# Work on the files changed most recently
git diff --name-only | head -5 | autohand -p "Modernize the syntax in these files"
Batch Operations
# Process a directory
autohand -p "Refactor the files in src/legacy to modern syntax"
# Generate tests for a directory
autohand -p "Add unit tests for every module in src/ that has none"
# Run a longer task in an autonomous loop with limits
autohand --auto-mode "Document every module in the project" --max-iterations 20 --max-cost 5
Configuration Files
# Open the settings menu
autohand config
# Use a different model for one run
autohand --model your-model -p "Summarize this project"
# Use a specific config file
autohand --config .autohand/config.json
# Show current permission settings
autohand --permissions
Command Reference
Core Commands
| Command | Description | Example |
|---|---|---|
-p, --prompt |
Run one instruction and exit | autohand -p "Create an API server" |
--plan |
Start in read-only plan mode | autohand --plan |
--auto-mode |
Run an autonomous loop with limits | autohand --auto-mode "Add unit tests" |
review |
Run Autohand Review | autohand review changes --base main |
init |
Create an AGENTS.md file | autohand init |
resume |
Resume a saved session | autohand resume |
Utility Commands
| Command | Description | Example |
|---|---|---|
doctor |
Check the installation and account | autohand doctor |
config |
Manage configuration | autohand config |
sessions |
List saved sessions | autohand sessions |
mcp |
Manage MCP servers | autohand mcp |
update |
Update the CLI | autohand update |
Advanced Features
Reusable Skills
# Analyze the project and install recommended skills
autohand --learn
# Browse and install a community skill
autohand --skill-install
# Use a skill in a single instruction
autohand -p "Use the frontend-ui skill to create a Button component"
Integration with Git
# Write a commit message for staged changes
git diff --staged | autohand -p "Write a conventional commit message for these changes"
# Write a pull request description
git log main..HEAD --oneline | autohand -p "Write a pull request description for these commits"
# Review the changes on this branch
autohand review changes --base main
# Commit with a generated message after lint and tests pass
autohand -c -p "Fix the lint errors in src/"
Headless Mode
On a machine where you signed in with autohand login, command mode needs no extra setup. CI runners and containers have no stored sign-in, so they use an API key with --bare. See Authenticate in CI and containers.
# Run one instruction in command mode\nautohand -p "Create a test suite for src/" --yes\n\n# CI runner or container: authenticate with an API key and --bare\nexport AUTOHAND_PROVIDER=autohandai\nexport AUTOHAND_API_KEY=your_key\nexport AUTOHAND_AI_API_KEY="$AUTOHAND_API_KEY"\nautohand --bare -p "Refactor the code in src/"\n\n# Write JSON Lines events to a log\nautohand -p "Generate API docs in docs/api.md" --output-format stream-json > run.jsonl
Common Issues
Command Not Found
# Check if autohand is in PATH\nwhich autohand\n\n# Add to PATH (temporary)\nexport PATH="$HOME/.local/bin:$PATH"\n\n# Add to PATH permanently (zsh)\necho 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc\nsource ~/.zshrc
Authentication Errors
# Check account and installation status\nautohand doctor\n\n# Re-authenticate\nautohand logout\nautohand login\n\n# Use an API key on a machine without a sign-in (requires --bare)\nexport AUTOHAND_PROVIDER=autohandai\nexport AUTOHAND_API_KEY=your_api_key\nexport AUTOHAND_AI_API_KEY="$AUTOHAND_API_KEY"\nautohand --bare -p "Say hello"
Slow Performance
# Check the installation\nautohand doctor\n\n# Use a faster model for one run\nautohand --model your-fast-model -p "Summarize this file"\n\n# Update the CLI and model catalog\nautohand update
Next Steps
Now that you’re comfortable with the CLI, explore these advanced topics: