docs/guides/run-agents-locally.mdx
Before starting, ensure you have:
ANTHROPIC_API_KEY environment variable set```bash
touch .continue/agents/my-agent.md
```
Add content like:
```markdown
---
name: My First Agent
description: Describes what this agent does
---
You are an agent that helps with [specific task].
## Your Task
1. First, do this
2. Then, do that
3. Finally, complete this
## Guidelines
- Follow this pattern
- Avoid this anti-pattern
```
For interactive development (TUI mode):
```bash
cn --agent .continue/agents/my-agent.md
```
Agent files are markdown documents with YAML frontmatter. The frontmatter configures the agent, and the markdown body contains the prompt instructions.
| Field | Required | Description |
|---|---|---|
name | Yes | Display name for the agent |
description | Yes | Brief description of what the agent does |
For additional options like rules, model, and MCP tool configuration, see the Create & Edit Agents guide.
This agent updates pull request titles to follow conventional commit format:
---
name: Conventional Title
description: Updates PR title to follow conventional commit format
---
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
Continue provides a reusable workflow that handles agent discovery, parallel execution, and GitHub Check reporting.
Create .github/workflows/run-agents.yml:
name: Run Agents
on:
pull_request:
types: [opened, reopened, synchronize]
branches:
- main
jobs:
agents:
uses: continuedev/continue/.github/workflows/continue-agents.yml@main
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
The reusable workflow automatically:
.md files in .continue/agents/GH_TOKEN for agents using the gh CLIjobs:
agents:
uses: continuedev/continue/.github/workflows/continue-agents.yml@main
with:
agents-path: '.continue/agents' # Custom agents directory (optional)
secrets:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
Add this secret to your repository under Settings > Secrets and variables > Actions:
| Secret | Description |
|---|---|
ANTHROPIC_API_KEY | Your Anthropic API key for Claude |
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>
```bash
# Only allow specific tools
cn --allow "Read()" --allow "Grep()" --exclude "Bash()" \
--agent .continue/agents/analysis-only.md
```
Learn more in the [CLI documentation](/cli/tool-permissions).
```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>
Before enabling fully automated agents:
cn to verify behaviorWhen running agents locally, set these environment variables:
# Required: Your Anthropic API key
export ANTHROPIC_API_KEY=your-api-key
# Optional: GitHub token if your agents use the gh CLI
export GH_TOKEN=$(gh auth token)
cn --agent .continue/agents/my-agent.md
A typical setup looks like:
your-repo/
├── .continue/
│ └── agents/
│ ├── conventional-title.md
│ ├── deploy-checklist.md
│ └── security-scan.md
├── .github/
│ └── workflows/
│ └── continue-agents.yml
└── ...
```bash
ls -la .continue/agents/
```
The path must be relative to your repository root.
```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.
```bash
find .continue/agents -name "*.md" -type f
```
The workflow looks for `.md` files in `.continue/agents/`.