| 1 | --- |
| 2 | title: "How to Use Continue CLI (cn)" |
| 3 | sidebarTitle: "Continue CLI (cn)" |
| 4 | description: "Learn how to use Continue's command-line interface for context engineering, automated coding tasks, and headless development workflows with customizable models, rules, and tools" |
| 5 | --- |
| 6 | |
| 7 | <Warning>Continue CLI (cn) is currently in Beta</Warning> |
| 8 | |
| 9 | `cn` is an open-source, modular coding agent for the command line. |
| 10 | |
| 11 | It provides a battle-tested agent loop so you can simply plug in your model, rules, and tools. |
| 12 | |
| 13 |  |
| 14 | |
| 15 | ## Quick start |
| 16 | |
| 17 | <Info> |
| 18 | Make sure you have [Node.js 18 or higher |
| 19 | installed](https://nodejs.org/en/download/). |
| 20 | </Info> |
| 21 | |
| 22 | ```bash |
| 23 | # Install |
| 24 | npm i -g @continuedev/cli |
| 25 | |
| 26 | # Interactive mode |
| 27 | cn |
| 28 | |
| 29 | # Headless mode |
| 30 | cn -p "Generate a conventional commit name for the current git changes" |
| 31 | ``` |
| 32 | |
| 33 | ## How to Use Continue CLI - Basic Usage |
| 34 | |
| 35 | Out of the box, `cn` comes with tools that let it understand your codebase, edit files, run terminal commands, and more (if you approve). You can ask `cn` to: |
| 36 | |
| 37 | - Fix failing tests |
| 38 | - Find something in the codebase |
| 39 | - Execute a refactor |
| 40 | - Write a new feature |
| 41 | - And a lot more |
| 42 | |
| 43 | Use '@' to give it file context, or '/' to run slash commands. |
| 44 | |
| 45 | If you want to resume a previous conversation, run `cn --resume`. |
| 46 | |
| 47 | ## How to Use Headless Mode (`-p` flag) |
| 48 | |
| 49 | In headless mode, `cn` will only output its final response, making it perfect for Unix Philosophy-style scripting and automation. For example, you could pipe your git diff into `cn` to generate a commit message, and write this to a file: |
| 50 | |
| 51 | ```bash |
| 52 | echo "$(git diff) Generate a conventional commit name for the current git changes" | cn -p > commit-message.txt |
| 53 | ``` |
| 54 | |
| 55 | ## How to Configure Continue CLI |
| 56 | |
| 57 | `cn` uses [`config.yaml`](/reference), the exact same configuration file as Continue. This means that you can log in to [Continue Hub](/hub/introduction) or use your existing local configuration. |
| 58 | |
| 59 | To switch between configurations, you can use the `/config` slash command in `cn`, or you can start it with the `--config` flag (e.g. `cn --config continuedev/default-agent` or `cn --config ~/.continue/config.yaml`). |
| 60 | |
| 61 | ### How to Add Custom Models |
| 62 | |
| 63 | Learn how to add custom models [here](/customize/overview). Then, you can use the `/model` slash command to switch between them in `cn`. |
| 64 | |
| 65 | ### How to Configure Rules |
| 66 | |
| 67 | `cn` supports [rules](/customize/deep-dives/rules) in the same way as the Continue IDE extensions. You can also use the `--rule` flag to manually include a rule from the hub. For example, `cn --rule nate/spanish` will tell `cn` to use [this rule](https://hub.continue.dev/nate/spanish) to always speak in Spanish. |
| 68 | |
| 69 | ### How to Configure Tools |
| 70 | |
| 71 | `cn` supports MCP tools, which can be configured in the [same way](/customize/deep-dives/mcp) as with the Continue IDE extensions. |
| 72 | |
| 73 | #### How to Set Tool Permissions |
| 74 | |
| 75 | `cn` includes a tool permission system to make sure you approve of the agent's actions. It will begin with minimal permissions but as you approve tool calls, it will add policies to `~/.continue/permissions.yaml` to remember your preferences. |
| 76 | |
| 77 | If you want to explicitly allow or deny tools for a single session, you can use the command line flags `--allow`, `--ask`, and `--exclude`. For example: |
| 78 | |
| 79 | ```bash |
| 80 | # Always allow the Write tool |
| 81 | cn --allow Write() |
| 82 | |
| 83 | # Always ask before running curl |
| 84 | cn --ask Bash(curl*) |
| 85 | |
| 86 | # Never use the Fetch tool |
| 87 | cn --exclude Fetch |
| 88 | ``` |
| 89 | |
| 90 | ## API Key Authentication |
| 91 | |
| 92 | For automation in CI or other headless environments, you can use an API key to authenticate with Continue. First, obtain your personal API key [here](https://hub.continue.dev/settings/api-keys). Then, set it as the `CONTINUE_API_KEY` environment variable. You can now use `cn -p` (headless mode) without needing to log in. |
| 93 | |
| 94 | If you wish to run an automation on behalf of your organization you can obtain an organization-scoped API key by going to [your organization's settings](https://hub.continue.dev/settings/organizations) -> API Keys. |
| 95 | |
| 96 | ## Troubleshooting |
| 97 | |
| 98 | Run `cn` with the `--verbose` flag to see more detailed logs. These will be output to `~/.continue/logs/cn.log`. |
| 99 | |
| 100 | If you have feedback on the beta, please [share in our Discord](https://discord.com/invite/EfJEfdFnDQ) or [leave feedback in the GitHub discussion](https://github.com/continuedev/continue/discussions/7307). |