Preface

When running coding agents in DeepSeek Harness (dsh), each request from the model automatically carries a batch of injected content: AGENTS.md/CLAUDE.md layered from the git root to the current directory, each name + description in the skills directory, the currently visible tool schemas, and the tool surfaces expanded from MCP servers. This content permanently resides in the input, and the meter only shows a total count. Repeated paragraphs, skills with identical descriptions, and skills with the same name shadowing each other often only draw attention when a context warning is triggered.

The design principle of DeepSeek Harness is “everything is a plugin”: the interface, tools, and compression can all be replaced. The community directory deepseek-harness-plugin.com is an independent indexing site with no official affiliation to DeepSeek / Horizon AI, and should not be treated as an official app store. One interface enhancement plugin there specifically addresses this issue: it breaks down the permanent injections, estimates tokens item by item, and flags duplicates and conflicts.

This article is organized after cross-checking the plugin directory details page, GitHub README / package.json / agent-setup.md, and the repository source code: what dsh-context-doctor is, which objects it audits, how to install it, and how to use it.

What It Is

dsh-context-doctor is a context injection auditing plugin for DeepSeek Harness. It is categorized under “Interface Enhancements” on the directory page, maintained by Zhenyu98, with the repository at Zhenyu98/dsh-context-doctor. As of 2026-08-17, the GitHub API shows 12 stars; the current version in package.json is 0.5.0, licensed under BSD-3-Clause (consistent across LICENSE, directory page, and GitHub metadata). The primary languages are JavaScript / TypeScript.

It solves a specific problem: instead of just looking at a single number on the meter, it answers questions like “how much do the instruction chain, skills catalog, tool schemas, and MCP tools each occupy”, “which paragraphs or skill descriptions are completely duplicated”, and “which skills with the same name take precedence and which are silently shadowed”. The audit path is read-only and does not modify the files being inspected.

There are two entry points for the plugin, which can be used together:
1. The Context Doctor circular panel in the Web UI, replacing the context meter control to the left of the send button.
2. The context_audit tool callable by the model, which outputs a sectioned report and pruning suggestions sorted by severity. The tool remains available even without a Web interface.

Core Features

Circular Panel: Permanent Cost at a Glance

After installation and restarting dsh web, the Context Doctor control will appear to the left of the send button for existing sessions. The circular display shows the estimated tokens for the permanent context (instruction chain + skills catalog + tool schemas), with color grading based on thresholds given in the repository README: green for less than 10k, yellow for less than 30k, and red for 30k or more.

The panel itself uses an English monospaced interface, with indicators and suggestion cards using low-saturation semantic colors; the outer DSH shell still follows the light, dark, or system theme. Clicking it expands four detailed groups: Instruction chain, Skills catalog, Tool schemas, and MCP tools, and provides a manual refresh. The data calls GET /api/context-doctor/audit, with a default 60-second cache on the host side.

The session-level control will not appear when a new session has not yet been assigned a sessionId. The native UI replacement also requires the current DSH to provide the conversation.input.context slot; versions without this slot can still call context_audit, but will not see this UI.

Four Types of Permanent Injections, Plus Optional Skill Bodies

The README divides the audit objects into five categories, with the first four being the per-request permanent cost:

Injection Target What It Counts
Instruction chain AGENTS.md/CLAUDE.md files in each layer from the git root to the current working directory: number of files, token estimates, and completely identical repeated paragraphs across files
Skills catalog name + description of all skills in ctx.skills (the <available_skills> seen by the model per request), grouped by source, and redundant skills with completely identical descriptions identified
Tool schemas All tools currently visible to the agent in ctx.tools.schemas: count, schema tokens, and grouping into native tools and MCP tools
MCP tool surfaces MCP tool counts and schema tokens aggregated by server, used to identify tool surface bloat
Skill bodies (optional) Total tokens of the first N skill bodies; loaded on demand, not counted in permanent requests, used to compare the cost difference between “catalog summary” and “actually reading the full body”

Conflict detection targets multiple sources of skills with the same name: for example, when a project skill shadows a bundled skill, the report will list the winning skill and the shadowed one (rank shadow).

The token count is not the exact value from the model’s tokenizer. The README specifies heuristic rules: approximately 4 characters/token for ASCII, and ~1.5 characters/token for Chinese, used for relative comparison and sorting; when there is a discrepancy with the meter, the actual count from the model side shall prevail. Currently, MCP tool schemas are only estimated based on name + description, excluding JSON Schema parameter details. Instruction chain duplicate detection only recognizes completely identical paragraph blocks; rewriting the same rule in a different wording will not be flagged.

context_audit: Reports Ready for Pruning Directly

After the model calls context_audit, it receives a canonical JSON (AuditReport), which is natively rendered into five readable sections: instructions, skills, tools, conflicts, and suggestions. The suggestions are sorted by severity, and the model can modify files, disable skills, or prune tool surfaces based on the entries.

The default output is a summary: cost, conflicts, and repair suggestions. Adding detail=developer will include an additional context-audit receipt: paths, byte counts, tokens, loading order, and short previews of duplicate blocks of loaded instruction files; the name, source, provider, and description bytes of each skill in the catalog; the serialized bytes and signature of each tool schema; duplicate MCP signatures; and shadowed skill relationships. The receipt does not include full prompts or skill bodies.

The trimmed field in the report is currently fixed as unavailable. The README explains that entries will only be filled once DSH exposes the context assembly trajectory, to avoid writing “already pruned” for states that are not visible.

Installation and Activation

The installation command on the directory details page is:

dsh plugin add github:Zhenyu98/dsh-context-doctor

The dsh CLI will parse the plugin from GitHub and install it into the current configuration. The directory page also reminds users that for reproducible installations, the commit hash should be pinned, in the format dsh plugin add github:Zhenyu98/dsh-context-doctor#commit. When checking the repository for this article, the latest commit on main is a15e68d68f511db5ae4057c96ae1c727e21bf1b1 (2026-08-17):

dsh plugin add github:Zhenyu98/dsh-context-doctor#a15e68d68f511db5ae4057c96ae1c727e21bf1b1

The repository README / agent-setup.md includes --profile web for the Web UI setup and pins to the main branch; installation from the git source includes built artifacts, so no local build is required:

dsh plugin --profile web add "github:Zhenyu98/dsh-context-doctor#main"
dsh --profile web --dump-config | grep context-doctor

The synthesized tree should include an insert entry similar to the following:

- insert:
    - id: context-doctor
      name: 'dsh-context-doctor'

Then restart dsh web. There are two success signals: the circular icon appears next to the composer in existing sessions, or the model calling context_audit in a new session returns a sectioned report.

The prerequisites listed in agent-setup.md are: DeepSeek Harness is installed locally (dsh is in PATH, version ≥ snapshot0811 / 0.0.1-rc.1). Node.js ≥ 22.19 is only required for development / building. If dsh plugin reports that pnpm is not found, you need to add pnpm to PATH first – installation is an explicit package management operation.

You can also hand the installation instructions provided by the repository to Codex, Claude Code, Cursor, or an agent in DSH to have it execute according to agent-setup.md; always review the plan before modifying files, using credentials, or running destructive commands.

The default audit directory and cache for the browser panel can be configured in YAML:

context-doctor:
  defaultCwd: /path/to/project
  cacheTtlMs: 60000

defaultCwd defaults to the process startup directory; cacheTtlMs defaults to 60000 milliseconds.

Typical Usage

The model can call the tool directly. The calling formats given in the repository are as follows:

context_audit
context_audit cwd=/path/to/project
context_audit includeSkillBodies=true maxSkillBodies=20
context_audit detail=developer

When no parameters are passed, the current session’s working directory is audited. includeSkillBodies will load skill bodies one by one, which is disabled by default; maxSkillBodies defaults to 20.

The following is a sample report structure from the README (field names and nesting come from the repository, and the values are illustrative examples from the documentation, not measurements from a real session):

{
  "tool": "context_audit",
  "version": 1,
  "cwd": "/path/to/project",
  "injected": {
    "instructions": {
      "files": [{ "path": "...", "bytes": 3421, "tokens": 812 }],
      "totalTokens": 812,
      "duplicateBlocks": []
    },
    "skills": {
      "catalogCount": 177,
      "catalogDescriptionTokens": 4150,
      "bySource": [],
      "duplicateDescriptions": []
    },
    "tools": {
      "visibleCount": 42,
      "schemaTokens": 9800,
      "nativeCount": 38,
      "nativeTokens": 6100,
      "mcp": {
        "servers": [{ "server": "github", "tools": 12, "schemaTokens": 2400 }],
        "totalTools": 12,
        "totalTokens": 2400
      }
    }
  },
  "conflicts": [],
  "suggestions": []
}

Without a Web UI, you can attach the plugin to a headless profile and have the model call context_audit directly. The source code will skip HTTP route registration when there is no webServer service, and the tool is unaffected.

If the circular panel does not appear, troubleshoot in the order specified in the README: whether you have restarted dsh web, whether you have entered the composer of an existing session, whether dump-config includes context-doctor. The native UI replacement also depends on the conversation.input.context slot; if you have modified the plugin source code, you must re-run ./scripts/build.sh.

Applicable Scenarios and Notes

It is suitable for users who have stacked multiple layers of AGENTS.md, a large number of skills, and MCP servers in DSH, and see the meter turn red but cannot clearly explain where the budget is being spent. It is also suitable for maintaining shared project instructions and performing environment health checks on agents: first check how expensive the permanent catalog is, then decide whether to enable includeSkillBodies to compare the cost of full bodies. The CLI / headless usage is equally valid, just without the circular panel.

Before using it, you need to accept these boundaries (all from the v0.5 documentation and security section of the README):
- The audit is read-only: only uses ctx.fs read / stat / list operations, does not write, delete, or execute the objects being audited.
- Files larger than 256 KB will be skipped to avoid overwhelming the auditor with large files.
- The report only includes paths, statistics, and duplicate paragraph fragments, and does not contain full file contents; skill bodies are only counted in total when explicitly enabled by the user, and the bodies themselves are still not output.
- Duplicate detection does not perform semantic similarity matching; MCP schema estimates exclude parameter JSON Schema.
- Tokens are heuristic estimates used for prioritization, and should not be used as billing basis.

The directory page clearly states: the plugin runs with the permissions of the current dsh process, and may execute code during installation. You should inspect the source code repository and license before installing; for reproducible installations, pin the commit hash, and do not long-term pin to the floating main branch.

Summary

dsh-context-doctor breaks down “the context is full” into an itemized bill: how much the instruction chain, skills catalog, tool schemas, and MCP tool surfaces each occupy, which are completely duplicated, and which skills with the same name are shadowed. The Web circular panel is for quick daily checks, while context_audit provides actionable pruning suggestions; the audit itself remains read-only.

Directory page: https://deepseek-harness-plugin.com/zh-CN/plugins/dsh-context-doctor/

GitHub: https://github.com/Zhenyu98/dsh-context-doctor