DuanAPI
An open-source AI programming assistant for VS Code — chat, agent, inline edit and autocomplete in one place
DuanAPI turns your editor into a full development environment. It answers questions about
your codebase, plans and executes multi-file changes, and writes inline completions — all
without leaving VS Code. Every proposed change is shown as a reviewable diff that you
approve or reject, so the model never edits your code silently.
Table of contents
Features
Agent
The Agent is DuanAPI's autonomous mode. Give it an instruction and it plans the work,
reads the files it needs, creates or edits multiple files, runs terminal commands and
verifies the result before reporting back.
- Reviewable diffs. Every file change appears as a diff you can accept or reject
individually — or accept the whole set at once.
- Checkpoint & restore. DuanAPI snapshots files before it touches them. The restore
icon next to a file in the chat reverts that file to its previous state.
- Auto-accept mode. Turn it on to let the agent apply its own changes without
prompting, and keep reviewing the transcript afterwards.
- Plan mode. Switch to Plan when you want a proposal first and no file writes yet.
Chat
Chat is for questions, explanations and exploration. It has full read access to the
files you mention with @, the files you select in the editor, and the indexed contents
of your workspace.
- Slash commands for repeatable prompts (
/help lists everything available).
- Context references with
@ to pull in files, folders, symbols, terminal output
or web pages.
- Session history so you can pick up a previous conversation where you left it.
Edit
Edit rewrites the selection you are looking at, right where it sits. Select code, press
Ctrl/Cmd + I, describe the change, and review the inline diff without leaving the
editor.
Autocomplete
Autocomplete offers inline suggestions as you type, in the model of your choice.
- Tab autocomplete for multi-line suggestions.
- Next Edit predicts the edit you are most likely to want next, based on the code
you just changed.
- Force autocomplete (
Ctrl+Alt+Space) to request a suggestion on demand.
Codebase indexing
DuanAPI indexes your workspace so answers can cite real code instead of guessing.
Indexing runs locally in the background and can be paused or rebuilt at any time from
Settings → Indexing.
Rules, prompts and MCP
Fine-tune the assistant's behaviour:
- Rules — persistent instructions applied to every request (coding conventions,
architecture notes, "always use pnpm", and so on). Add them globally under
~/.duanapi/rules/ or per project in .duanapi/rules/, or write them in an
AGENTS.md file at the root of your workspace.
- Prompts — reusable slash commands you can invoke from the chat box, stored in
~/.duanapi/prompts/ or .duanapi/prompts/.
- MCP servers — connect external tools and data sources in
.duanapi/mcpServers/;
their tools become available to the agent automatically.
.duanapiignore — exclude paths from indexing and block the agent from writing
to them.
Installation
Option 1 — Visual Studio Marketplace (recommended)
Open the extension page on the
Visual Studio Marketplace
and click Install. VS Code downloads and installs it for you — no manual download
required. When a new version is released, click Update in the Extensions view.
You can also install it from the command line:
code --install-extension DuanAPI-AIcodeagent.duanapi
Getting started
- Open the DuanAPI panel in the Secondary Side Bar (right-hand side).
- Click the gear icon to open Settings, then go to API Key and paste your
DuanAPI API key.
- Go to Models and pick the model you want to use for each role (Chat, Apply,
Edit). You can also bring your own key for any supported provider.
- Start typing in the chat box. Use
@ to add files or symbols to the context, and
/ to open the list of slash commands.
Everything is stored locally under ~/.duanapi:
| Path |
Purpose |
config.yaml |
Models, providers and roles |
.env |
API keys (never leaves your machine) |
rules/ |
Global rules applied to every session |
prompts/ |
Global slash commands |
sessions/ |
Chat history |
index/ |
Codebase index |
The same folders work per-project. Drop a .duanapi/ directory next to your code and
DuanAPI will pick it up:
your-project/
├── .duanapi/
│ ├── rules/ → instructions applied to every request in this project
│ ├── prompts/ → project-specific slash commands
│ ├── context/ → context providers
│ └── mcpServers/ → MCP server definitions
├── AGENTS.md → project instructions (also read from AGENT.md / CLAUDE.md)
└── .duanapiignore → paths the agent must not touch
Modes
DuanAPI has three modes, switched with the mode button next to the model picker.
| Mode |
What it does |
| Chat |
Answers questions and explains code. Never writes to disk. |
| Plan |
Investigates the codebase and proposes a plan before any change is made. |
| Agent |
Executes the work: creates files, applies edits, runs commands. |
Keyboard shortcuts
| Shortcut |
Action |
Ctrl/Cmd + I |
Add the selection to the chat and switch to Edit mode |
Ctrl/Cmd + L |
Add the selection to the chat context and clear the input |
Ctrl/Cmd + Shift + L |
Add the selection to the chat context, keeping the input |
Ctrl/Cmd + K Ctrl/Cmd + A |
Toggle tab autocomplete |
Ctrl/Cmd + K Ctrl/Cmd + N |
Toggle Next Edit suggestions |
Ctrl/Cmd + Alt + Space |
Force an autocomplete suggestion |
Ctrl/Cmd + Shift + Enter |
Accept the current diff |
Ctrl/Cmd + Shift + Backspace |
Reject the current diff |
Ctrl/Cmd + Alt + Y / Ctrl/Cmd + Alt + N |
Accept / reject a single diff block |
Alt + A |
Apply the code from the chat to the file |
Escape |
Exit Edit mode |
Commands
All commands are available in the Command Palette under the DuanAPI category.
| Command |
Description |
DuanAPI: New Session |
Start a fresh chat |
DuanAPI: Open Settings |
Open the configuration page |
DuanAPI: Update DuanAPI API Key |
Set or replace your API key |
DuanAPI: View History |
Browse previous sessions |
DuanAPI: View Logs |
Open the extension log |
DuanAPI: Select Files as Context |
Add files to the context of the next request |
DuanAPI: Rebuild codebase index |
Re-index the workspace from scratch |
DuanAPI: Codebase Force Re-Index |
Force a re-index of the current workspace |
DuanAPI: Docs Index / Docs Force Re-Index |
Index documentation links |
DuanAPI: Share Current Chat Session as Markdown |
Export the conversation |
DuanAPI: Write Comments for this Code |
Add explanatory comments |
DuanAPI: Write a Docstring for this Code |
Generate documentation for the selection |
DuanAPI: Fix this Code |
Repair the selected code |
DuanAPI: Optimize this Code |
Improve the selected code |
DuanAPI: Fix Grammar / Spelling |
Correct text in the selection |
DuanAPI: Debug Terminal |
Open the DuanAPI console panel |
DuanAPI: Open in new window |
Detach the panel into its own window |
Configuration
Press Ctrl/Cmd + , and search for DuanAPI, or use DuanAPI: Open Settings.
| Setting |
Description |
DuanAPI: Language |
Interface language — English or Vietnamese |
DuanAPI: Enable Tab Autocomplete |
Turn inline completions on or off |
DuanAPI: Enable Next Edit |
Turn Next Edit suggestions on or off |
DuanAPI: Pause Tab Autocomplete On Battery |
Suspend completions on low battery |
DuanAPI: Pause Codebase Index On Start |
Skip indexing when VS Code launches |
DuanAPI: Enable Console |
Show the DuanAPI console panel at the bottom |
DuanAPI: Show Inline Tip |
Display the shortcut hint bar |
DuanAPI: Enable Quick Actions |
Experimental quick actions in the editor |
DuanAPI: Disable Quick Fix |
Turn the quick-fix action off |
DuanAPI: Remote Config Server URL |
Shared configuration server for teams |
DuanAPI: User Token |
Token used to authenticate against that server |
Privacy and telemetry
- Your API key and code never leave your machine except in requests to the model
provider you configured. The codebase index is stored locally under
~/.duanapi.
- Anonymous usage data is collected to help improve the extension. It follows VS Code's
own telemetry setting, so you can disable it globally with
Settings → Telemetry → Allow Anonymous Telemetry (or in the Privacy section of
the VS Code settings).
Troubleshooting
The panel is empty or the model does not respond
Check that an API key is set under Settings → API Key and that a model is selected
for the role you are using.
Autocomplete does not appear
Make sure Enable Tab Autocomplete is on, and that no extension is intercepting the
same keybinding. Use Ctrl/Cmd + Alt + Space to request a suggestion manually.
The agent seems stuck
Open the console with DuanAPI: Debug Terminal to see live model input and output.
Long operations (installing dependencies, running builds) are normal and will show
progress in the chat.
The codebase index looks stale
Run DuanAPI: Rebuild codebase index from the Command Palette.
Changes are not being applied
Check that auto-accept mode is disabled if you want to review each diff, and make sure
the file is not listed in .duanapiignore.
License
Apache 2.0 © 2023-2026 DuanAPI