The Dosu CLI is the dosu command, published on npm as @dosu/cli. It connects your local coding agents to Dosu so they pull relevant team knowledge into context automatically and can save what they learn back to the knowledge base. This page covers what the CLI does, how to install it, and how to set up knowledge-injection hooks.
What the CLI does#
The CLI does two related jobs.
- Set up the Dosu MCP Server for the coding agents you already run, so an agent can query your Libraries on demand (the
init_knowledge,search_documentation,ask, andsave_topictools). See Dosu MCP Server for what the server exposes. - Install knowledge-injection hooks for Claude Code so Dosu pushes relevant context into the session at the right moments without you having to ask. Hooks are the focus of the rest of this page.
The difference is that an MCP Server is something your agent can call when it decides to. Hooks make Dosu proactive, firing on the agent's lifecycle events and injecting context in the background.
Prerequisites#
- Node.js with
npxavailable, so you can run@dosu/cliwithout a global install. - A Dosu account and at least one Library with Sources connected. Create one at Libraries.
- A deployment API key for authentication. The CLI uses a long-lived deployment API key (the same key the MCP Server uses), which avoids session token expiry during long agent runs. Manage keys in Settings, Account, API keys.
Install and connect#
Run the guided setup:
npx @dosu/cli setup
Setup detects the coding agents installed on your machine (Claude Code, Cursor, VS Code, and others) and lets you choose which ones to connect to the Dosu MCP Server. It also installs the Dosu skill, a set of agent instructions that tell the agent how to use Dosu well.
To connect an agent that was not auto-detected, add it by name:
dosu mcp add <agent>
Install knowledge-injection hooks (Claude Code)#
Hooks let Dosu inject context into a live Claude Code session in the background. From a repository where you run Claude Code:
npx @dosu/cli hooks install claude-code
This writes Dosu hook entries into .claude/settings.local.json. The entries carry Dosu ownership markers, so re-running the install is safe, and uninstalling removes only Dosu's hooks, leaving any hooks you added alone.
Related hook commands:
dosu hooks uninstall claude-code # remove Dosu's hooks
dosu hooks doctor # check that hooks are installed and healthy
How hooks work#
Once installed, the hooks fire on three points in the Claude Code lifecycle. They run against an asynchronous Dosu API so they never block the agent, and if anything fails they fall back to doing nothing rather than interrupting your session.
- On prompt submit. When you send a prompt, Dosu kicks off a knowledge lookup in the background and returns immediately. The agent keeps working while Dosu searches.
- After tool use. Dosu checks whether the lookup is ready (with a short cooldown between checks). When results are ready, it injects the relevant knowledge into the agent's context once, with attribution, so the agent can treat it as a team-knowledge cross-check.
- At turn end. If results have not landed yet, Dosu waits briefly for a last-chance delivery before the turn closes.
The result is that you no longer have to copy documentation into prompts by hand. Relevant context from your Libraries appears when the agent needs it, and your team remains the source of truth.
Saving learnings back#
When Dosu notices a gap worth documenting, it can nudge the agent to save the new knowledge to your Library. Writing to the knowledge base goes through the Dosu MCP Server's save_topic tool, so the MCP Server must be installed and connected for saving to work. The hooks read and inject knowledge, though they do not write it. Running dosu setup first (above) covers this.
Availability and notes#
- Knowledge-injection hooks are generally available for Claude Code. Support for other coding agents is in progress and not yet broadly available. Connecting an agent to the Dosu MCP Server (via
dosu setupordosu mcp add) works for a wider set of agents than hooks do. - Hooks read from the Libraries your deployment can access. Connect Sources in a Library first so there is knowledge to inject. See Sources.
- Hooks fail silently by design. If you expect injection and see none, run
dosu hooks doctorand confirm your API key is set. - Usage tied to hooks and MCP queries counts toward your plan. For current plans and limits, see plans, billing, and access or Settings, Organization, Billing.