From 9a701e28f1bc2831fe4d187d2bc89634851c4481 Mon Sep 17 00:00:00 2001 From: Brian 'bdougie' Douglas Date: Thu, 15 Jan 2026 09:45:05 -0800 Subject: [PATCH] docs: address review feedback on run-agents-locally guide - Add clarifying note distinguishing local vs cloud agents - Remove redundant CardGroup section - Fix API key naming to ANTHROPIC_API_KEY - Clarify GitHub CLI pre-installed on runners - Remove unnecessary tools: built_in from examples - Rename "Rules" to "Guidelines" to avoid frontmatter confusion - Flip headless/TUI order (headless is typical) - Simplify frontmatter table, link to reference - Move GitHub Actions section before Security - Remove --ask from CI guidance (requires user intervention) - Fix mac-only log path - Add ANTHROPIC_API_KEY to local env vars section - Clarify name field vs filename in best practices Co-Authored-By: Claude Opus 4.5 --- docs/guides/run-agents-locally.mdx | 189 ++++++++++++++--------------- 1 file changed, 88 insertions(+), 101 deletions(-) diff --git a/docs/guides/run-agents-locally.mdx b/docs/guides/run-agents-locally.mdx index 472eebb47..444ba7ff7 100644 --- a/docs/guides/run-agents-locally.mdx +++ b/docs/guides/run-agents-locally.mdx @@ -4,6 +4,10 @@ sidebarTitle: "Run Agents Locally" description: "Set up version-controlled agents in your repository and run them with Continue CLI or GitHub Actions" --- + + Looking for the easiest way to create and manage agents? [Cloud Agents in Mission Control](/agents/overview#pre-configured-agents) are recommended for most teams. This guide covers **local agents**—agent files stored in your repository—for open source users or teams needing version-controlled definitions. + + A local agent system that: - Keeps agent definitions version-controlled alongside your code @@ -12,29 +16,13 @@ description: "Set up version-controlled agents in your repository and run them w - Applies consistent workflows across your team -## Why Local Agents? - - - - Agent definitions evolve with your codebase. Track changes, review in PRs, and roll back when needed. - - - - Everyone runs the same agents with the same rules. No configuration drift across machines. - - - - Trigger agents automatically on pull requests, commits, or any GitHub event. - - - ## 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 +- `ANTHROPIC_API_KEY` environment variable set +- [GitHub CLI](https://cli.github.com/) installed locally if your agents interact with GitHub (pre-installed on GitHub-hosted runners) ## Quick Setup @@ -58,7 +46,6 @@ Before starting, ensure you have: --- name: My First Agent description: Describes what this agent does - tools: built_in --- You are an agent that helps with [specific task]. @@ -69,22 +56,22 @@ Before starting, ensure you have: 2. Then, do that 3. Finally, complete this - ## Rules + ## Guidelines - - Follow this guideline - - Avoid this pattern + - Follow this pattern + - Avoid this anti-pattern ``` ```bash - cn --agent .continue/agents/my-agent.md + cn -p --agent .continue/agents/my-agent.md ``` - For headless execution (useful for automation): + For interactive development (TUI mode): ```bash - cn -p --agent .continue/agents/my-agent.md + cn --agent .continue/agents/my-agent.md ``` @@ -99,12 +86,13 @@ Agent files are markdown documents with YAML frontmatter. The frontmatter config |-------|----------|-------------| | `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) | The markdown body is the agent's system prompt. Write clear, specific instructions with examples for best results. +For additional options like `rules`, `model`, and MCP tool configuration, see the [Agent Configuration Reference](/agents/agent-file-reference). + ## Example: Conventional PR Title Agent This agent updates pull request titles to follow conventional commit format: @@ -113,7 +101,6 @@ This agent updates pull request titles to follow conventional commit format: --- 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. @@ -149,80 +136,11 @@ You are reviewing a pull request to format its title according to conventional c - Use lowercase, no period at end ```` -## Security Considerations - - - Agents can execute commands and modify files. Review these security practices before deploying to CI/CD. - - -### Limit Agent Permissions - -When running agents in CI/CD, follow the principle of least privilege: - - - - 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 - ``` - - - Avoid granting `contents: write` unless your agent specifically needs to push commits. This prevents accidental or malicious code modifications. - - - - - 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). - - - - 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 - ``` - - - Never hardcode API keys in agent files or workflows. Always use secrets management. - - - - -### 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 - - - For high-risk operations (like pushing commits or modifying infrastructure), consider requiring manual approval steps in your workflow. - - ## GitHub Actions Integration Continue provides a [reusable workflow](https://github.com/continuedev/continue/blob/main/.github/workflows/continue-agents.yml) that handles agent discovery, parallel execution, and GitHub Check reporting. -### Using the Reusable Workflow (Recommended) +### Using the Reusable Workflow Create `.github/workflows/run-agents.yml`: @@ -273,13 +191,82 @@ Add this secret to your repository under **Settings > Secrets and variables > Ac The reusable workflow automatically provides `GH_TOKEN` via `${{ github.token }}`, so agents using the `gh` CLI work out of the box. +## Security Considerations + + + Agents can execute commands and modify files. Review these security practices before deploying to CI/CD. + + +### Limit Agent Permissions + +When running agents in CI/CD, follow the principle of least privilege: + + + + 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 + ``` + + + Avoid granting `contents: write` unless your agent specifically needs to push commits. This prevents accidental or malicious code modifications. + + + + + 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 + ``` + + Learn more in the [CLI documentation](/cli/overview#how-to-set-tool-permissions). + + + + 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 + ``` + + + Never hardcode API keys in agent files or workflows. Always use secrets management. + + + + +### Review Agent Outputs + +Before enabling fully automated agents: + +1. **Test locally first** - Run agents with `cn` to verify behavior +2. **Review CI logs** - Check what commands agents execute in your workflows +3. **Start with read-only agents** - Begin with agents that analyze rather than modify + + + For high-risk operations (like pushing commits or modifying infrastructure), consider requiring manual approval steps in your workflow. + + ## Environment Variables -When running agents locally that interact with GitHub, set the `GH_TOKEN`: +When running agents locally, set these environment variables: ```bash -# Use your GitHub CLI token +# 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 ``` @@ -331,7 +318,7 @@ your-repo/ - 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` + - Review logs with `cn --verbose` or check the Continue logs directory @@ -357,7 +344,7 @@ your-repo/ - Name agent files clearly: `conventional-title.md`, `security-scan.md`, `deploy-checklist.md`. + The `name` field in frontmatter is displayed to users. Use descriptive filenames for organization: `conventional-title.md`, `security-scan.md`.