Add documentation for running agents locally

- Update agents overview documentation
- Add new guide for running agents locally
- Update docs.json configuration

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
Brian 'bdougie' Douglas 2026-01-13 09:33:46 -08:00
parent 4e29a94605
commit 14276f015b
4 changed files with 545 additions and 13 deletions

View file

@ -34,44 +34,59 @@ You can run Agents in three main ways:
<Tabs>
<Tab title="🌐 Mission Control">
**Interactive web interface**
Trigger from the Continue Mission Control and review results in real-time.
```bash
# Navigate to hub.continue.dev/agents
# Click "Run Agent" on any agent
# Monitor progress and review outputs
```
Perfect for: Interactive debugging, reviewing agent outputs, team collaboration
</Tab>
<Tab title="💻 TUI Mode">
**Interactive terminal mode**
Launch from terminal for live interaction and testing.
```bash
cn --agent my-org/github-pr-agent
# Interactive chat interface opens
# Type your specific request
# Review and approve actions
```
Perfect for: Local development, testing prompts, quick one-off tasks
</Tab>
<Tab title="🤖 Headless Mode">
**Automated execution**
Run one-off or scheduled tasks automatically without interaction.
```bash
cn -p --agent my-org/snyk-agent "Run weekly security scan" --auto
```
Perfect for: CI/CD pipelines, scheduled tasks, webhook integrations
</Tab>
<Tab title="📁 Local Agents">
**Version-controlled agents in your repository**
Define agents in `.continue/agents/` and run them with the CLI or GitHub Actions.
```bash
# Run a local agent file
cn --agent .continue/agents/my-agent.md
```
Perfect for: Team-shared workflows, CI/CD automation, version-controlled agent definitions
[Learn more about local agents →](/guides/run-agents-locally)
</Tab>
</Tabs>
## Pre-configured Agents
@ -213,15 +228,19 @@ The practice of using cloud agents, which we call Continuous AI, requires foreth
<Card title="Create an Agent" icon="plus" href="/hub/agents/create-and-edit">
Build your first custom agent with prompts, rules, and tools
</Card>
<Card title="Run Agents Locally" icon="folder-open" href="/guides/run-agents-locally">
Set up version-controlled agents in your repository
</Card>
<Card title="Explore Cookbooks" icon="book-open" href="/guides/overview#mcp-integration-cookbooks">
Browse pre-built agents for security, analytics, and more
</Card>
<Card title="CLI Guide" icon="terminal" href="/cli/overview">
Learn to run agents from the command line
</Card>
<Card title="Mission Control" icon="desktop" href="https://hub.continue.dev/agents">
Access the web interface to manage agents
</Card>

View file

@ -267,7 +267,11 @@
},
{
"group": "CLI Guides",
"pages": ["guides/cli", "guides/doc-writing-agent-cli"]
"pages": [
"guides/cli",
"guides/run-agents-locally",
"guides/doc-writing-agent-cli"
]
},
{
"group": "Continuous AI Guides",

View file

@ -0,0 +1,487 @@
---
title: "Run Agents Locally with .continue/agents"
sidebarTitle: "Run Agents Locally"
description: "Set up version-controlled agents in your repository and run them with Continue CLI or GitHub Actions"
---
<Card title="What You'll Build" icon="folder-open">
A local agent system that:
- Keeps agent definitions version-controlled alongside your code
- Runs agents with Continue CLI for local development
- Automates agent execution on pull requests via GitHub Actions
- Applies consistent workflows across your team
</Card>
## Why Local Agents?
<CardGroup cols={3}>
<Card title="Version Control" icon="code-branch">
Agent definitions evolve with your codebase. Track changes, review in PRs, and roll back when needed.
</Card>
<Card title="Team Consistency" icon="users">
Everyone runs the same agents with the same rules. No configuration drift across machines.
</Card>
<Card title="CI/CD Ready" icon="rotate">
Trigger agents automatically on pull requests, commits, or any GitHub event.
</Card>
</CardGroup>
## Prerequisites
Before starting, ensure you have:
- [Continue CLI installed](/cli/install) (`npm i -g @continuedev/cli`)
- An LLM API key (e.g., `ANTHROPIC_API_KEY`)
- [GitHub CLI](https://cli.github.com/) if your agents interact with GitHub
## Quick Setup
<Steps>
<Step title="Create the agents directory">
```bash
mkdir -p .continue/agents
```
</Step>
<Step title="Create your first agent">
Create a markdown file with YAML frontmatter defining the agent's behavior:
```bash
touch .continue/agents/my-agent.md
```
Add content like:
```markdown
---
name: My First Agent
description: Describes what this agent does
tools: built_in
---
You are an agent that helps with [specific task].
## Your Task
1. First, do this
2. Then, do that
3. Finally, complete this
## Rules
- Follow this guideline
- Avoid this pattern
```
</Step>
<Step title="Run the agent">
```bash
cn --agent .continue/agents/my-agent.md
```
For headless execution (useful for automation):
```bash
cn -p --agent .continue/agents/my-agent.md
```
</Step>
</Steps>
## Agent File Format
Agent files are markdown documents with YAML frontmatter. The frontmatter configures the agent, and the markdown body contains the prompt instructions.
### Frontmatter Options
| Field | Required | Description |
|-------|----------|-------------|
| `name` | Yes | Display name for the agent |
| `description` | Yes | Brief description of what the agent does |
| `tools` | No | Tool configuration (`built_in` for standard tools) |
<Info>
The markdown body is the agent's system prompt. Write clear, specific instructions with examples for best results.
</Info>
## Example: Conventional PR Title Agent
This agent updates pull request titles to follow conventional commit format:
```markdown
---
name: Conventional Title
description: Updates PR title to follow conventional commit format
tools: built_in
---
You are reviewing a pull request to format its title according to conventional commit standards.
## Your Task
1. **Get the current PR title and number:**
```bash
gh pr view --json number,title -q '{number: .number, title: .title}'
```
2. **Get the PR diff to understand changes:**
```bash
git diff origin/main...HEAD --name-only
```
3. **Analyze the changes to determine type:**
- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation only
- `refactor`: Code refactoring
- `chore`: Build, tooling, configs
4. **Update the PR title:**
```bash
gh pr edit <PR_NUMBER> --title "type: description"
```
## Rules
- If title already follows format, do NOT modify
- Keep description under 72 characters
- Use lowercase, no period at end
```
## Security Considerations
<Warning>
Agents can execute commands and modify files. Review these security practices before deploying to CI/CD.
</Warning>
### Limit Agent Permissions
When running agents in CI/CD, follow the principle of least privilege:
<Tabs>
<Tab title="GitHub Actions Permissions">
Only grant the permissions your agent needs:
```yaml
permissions:
contents: read # Read repository files
pull-requests: write # Comment on PRs
# Avoid: contents: write unless agent needs to push commits
```
<Warning>
Avoid granting `contents: write` unless your agent specifically needs to push commits. This prevents accidental or malicious code modifications.
</Warning>
</Tab>
<Tab title="CLI Tool Permissions">
Use `cn` permission flags to restrict what agents can do:
```bash
# Only allow specific tools
cn --allow "Read()" --allow "Grep()" --exclude "Bash()" \
--agent .continue/agents/analysis-only.md
# Always ask before running commands
cn --ask "Bash(*)" --agent .continue/agents/my-agent.md
```
Learn more in the [CLI documentation](/cli/overview#how-to-set-tool-permissions).
</Tab>
<Tab title="Environment Variables">
Never commit secrets. Use GitHub Actions secrets or environment variables:
```yaml
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GH_TOKEN: ${{ github.token }} # Scoped to the repo
```
<Warning>
Never hardcode API keys in agent files or workflows. Always use secrets management.
</Warning>
</Tab>
</Tabs>
### Review Agent Outputs
Before enabling fully automated agents:
1. **Test locally first** - Run agents with `cn` to verify behavior
2. **Use `--ask` mode** - Require approval for sensitive operations during testing
3. **Review CI logs** - Check what commands agents execute in your workflows
4. **Start with read-only agents** - Begin with agents that analyze rather than modify
<Tip>
For high-risk operations (like pushing commits or modifying infrastructure), consider requiring manual approval steps in your workflow.
</Tip>
## GitHub Actions Integration
Automate agent execution on pull requests with this workflow.
### Basic Workflow
Create `.github/workflows/continue-agents.yml`:
```yaml
name: Continue Agents
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
permissions:
contents: write
checks: write
pull-requests: write
jobs:
discover:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.discover.outputs.matrix }}
has-agents: ${{ steps.discover.outputs.has_agents }}
steps:
- uses: actions/checkout@v4
- name: Discover agents
id: discover
run: |
AGENTS_DIR=".continue/agents"
if [ -d "$AGENTS_DIR" ]; then
FILES=$(find "$AGENTS_DIR" -name "*.md" -type f 2>/dev/null | jq -R . | jq -sc .)
COUNT=$(echo "$FILES" | jq 'length')
HAS_AGENTS=$([[ $COUNT -gt 0 ]] && echo "true" || echo "false")
else
FILES="[]"
HAS_AGENTS="false"
fi
echo "matrix=$FILES" >> $GITHUB_OUTPUT
echo "has_agents=$HAS_AGENTS" >> $GITHUB_OUTPUT
run-agent:
needs: discover
if: needs.discover.outputs.has-agents == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
agent: ${{ fromJson(needs.discover.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Continue CLI
run: npm i -g @continuedev/cli
- name: Extract agent name
id: agent-name
run: |
AGENT_FILE="${{ matrix.agent }}"
AGENT_NAME=$(basename "$AGENT_FILE" .md)
echo "name=$AGENT_NAME" >> $GITHUB_OUTPUT
- name: Create Check Run
id: check
uses: actions/github-script@v7
env:
AGENT_NAME: ${{ steps.agent-name.outputs.name }}
with:
script: |
const { data: check } = await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: `Continue: ${process.env.AGENT_NAME}`,
head_sha: context.sha,
status: 'in_progress',
started_at: new Date().toISOString(),
});
core.setOutput('id', check.id);
- name: Run agent
id: run
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
GH_TOKEN: ${{ github.token }}
run: |
AGENT_FILE="${{ matrix.agent }}"
if OUTPUT=$(cn -p --agent "$AGENT_FILE" 2>&1); then
echo "success=true" >> $GITHUB_OUTPUT
echo "output<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "success=false" >> $GITHUB_OUTPUT
echo "error<<EOF" >> $GITHUB_OUTPUT
echo "$OUTPUT" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Update Check Run
if: always()
uses: actions/github-script@v7
env:
AGENT_OUTPUT: ${{ steps.run.outputs.output }}
AGENT_ERROR: ${{ steps.run.outputs.error }}
AGENT_SUCCESS: ${{ steps.run.outputs.success }}
CHECK_RUN_ID: ${{ steps.check.outputs.id }}
with:
script: |
const success = process.env.AGENT_SUCCESS === 'true';
const output = process.env.AGENT_OUTPUT || '';
const error = process.env.AGENT_ERROR || '';
await github.rest.checks.update({
owner: context.repo.owner,
repo: context.repo.repo,
check_run_id: parseInt(process.env.CHECK_RUN_ID, 10),
status: 'completed',
conclusion: success ? 'success' : 'failure',
completed_at: new Date().toISOString(),
output: {
title: success ? 'Agent completed' : 'Agent failed',
summary: success
? `Agent completed.\n\n\`\`\`\n${output.slice(0, 60000)}\n\`\`\``
: `Agent failed.\n\n\`\`\`\n${error.slice(0, 60000)}\n\`\`\``,
},
});
- name: Fail if agent failed
if: steps.run.outputs.success != 'true'
run: exit 1
```
### Required Secrets
Add these secrets to your repository under **Settings > Secrets and variables > Actions**:
| Secret | Description |
|--------|-------------|
| `ANTHROPIC_API_KEY` | Your Anthropic API key for Claude |
<Info>
The `GH_TOKEN` is automatically provided by GitHub Actions via `${{ github.token }}`. This token is scoped to the repository and expires after the workflow completes.
</Info>
## Environment Variables
When running agents locally that interact with GitHub, set the `GH_TOKEN`:
```bash
# Use your GitHub CLI token
export GH_TOKEN=$(gh auth token)
cn --agent .continue/agents/my-agent.md
```
## Directory Structure
A typical setup looks like:
```
your-repo/
├── .continue/
│ └── agents/
│ ├── conventional-title.md
│ ├── deploy-checklist.md
│ └── security-scan.md
├── .github/
│ └── workflows/
│ └── continue-agents.yml
└── ...
```
## Troubleshooting
<AccordionGroup>
<Accordion title="Agent not found">
Ensure the path is correct and the file exists:
```bash
ls -la .continue/agents/
```
The path must be relative to your repository root.
</Accordion>
<Accordion title="GitHub CLI authentication errors">
If agents using `gh` fail, verify authentication:
```bash
# Check auth status
gh auth status
# Set token for local testing
export GH_TOKEN=$(gh auth token)
```
In GitHub Actions, ensure `GH_TOKEN: ${{ github.token }}` is set in the environment.
</Accordion>
<Accordion title="Agent runs but doesn't complete the task">
- Simplify the prompt and add more specific instructions
- Check if the agent has access to required tools
- Enable verbose logging: `cn --verbose --agent .continue/agents/my-agent.md`
- Review logs at `~/.continue/logs/cn.log`
</Accordion>
<Accordion title="Workflow doesn't discover agents">
Verify your agents are in the correct directory:
```bash
find .continue/agents -name "*.md" -type f
```
The workflow looks for `.md` files in `.continue/agents/`.
</Accordion>
</AccordionGroup>
## Best Practices
<CardGroup cols={2}>
<Card title="Start Simple" icon="seedling">
Begin with read-only agents that analyze code before adding agents that make changes.
</Card>
<Card title="Test Locally" icon="terminal">
Always run `cn --agent` locally before enabling CI automation.
</Card>
<Card title="Use Descriptive Names" icon="tag">
Name agent files clearly: `conventional-title.md`, `security-scan.md`, `deploy-checklist.md`.
</Card>
<Card title="Keep Agents Focused" icon="bullseye">
Each agent should do one thing well. Combine multiple agents for complex workflows.
</Card>
</CardGroup>
## Next Steps
<CardGroup cols={2}>
<Card title="Agent Overview" icon="robot" href="/agents/overview">
Learn about agent components and capabilities
</Card>
<Card title="CLI Reference" icon="terminal" href="/cli/overview">
Full Continue CLI documentation
</Card>
<Card title="MCP Tools" icon="plug" href="/customize/mcp-tools">
Add external tools to your agents
</Card>
<Card title="Rules" icon="list-check" href="/customize/rules">
Configure agent behavior with rules
</Card>
</CardGroup>

22
draft_pr.md Normal file
View file

@ -0,0 +1,22 @@
## Description
[TODO: Add a brief description of what changed in this PR]
## AI Code Review
- **Team members only**: AI review runs automatically when PR is opened or marked ready for review
- Team members can also trigger a review by commenting `@continue-review`
## Checklist
- [ ] I've read the [contributing guide](https://github.com/continuedev/continue/blob/main/CONTRIBUTING.md)
- [ ] The relevant docs, if any, have been updated or created
- [ ] The relevant tests, if any, have been updated or created
## Screen recording or screenshot
[TODO: Add screen recording or screenshot if applicable - see [this PR](https://github.com/continuedev/continue/pull/6455) as a good example]
## Tests
[TODO: Describe what tests were added or updated to ensure the changes work as expected]