description: "Workspace-instruction context for users and maintainers enabling, sizing, or debugging AGENTS.md/CLAUDE.md loading and refresh."
English | 中文
dsh-agent-instructions gives agents workspace guidance from user-global and project-level AGENTS.md-compatible files. It loads the applicable chain for the first request. It does not watch external edits continuously: successful filesystem operations discover newly relevant nested files and make later changes or removals visible, while session resume reconciles the baseline. dsh-base enables this behavior by default, while profiles can disable it. A byte budget bounds the injected context: broader files are omitted before the most specific file is truncated, and an empty chain adds nothing.
Mount this plugin when agents should work from the workspace's own instruction files. dsh-base already includes it with a 65,536-byte budget, so base-backed profiles only need to replace the row when they want another maxBytes; providerless trees load nothing until a filesystem provider is present.
The first request includes one durable baseline message with the user-global $DSH_HOME/AGENTS.md followed by the project chain — every existing candidate file from the project root down to the session working directory, in broad-to-specific order. Sibling files whose content matches after trimming render once, so a CLAUDE.md that duplicates its AGENTS.md is not repeated. After a successful read, write, or edit call reaches a deeper directory, the next request includes the newly applicable instruction file; a changed file replaces its content, and a file that disappears or duplicates an earlier candidate produces a removal notice.
The defaults suit a typical checkout: .git marks the project root, AGENTS.md and CLAUDE.md are the base candidates, and AGENTS.local.md and CLAUDE.local.md are additive local overlays. Only maxBytes is required — it caps the complete rendered baseline so each deployment chooses its prompt budget explicitly.
Root discovery climbs only when a marker probe confirms that the marker is absent. A permission or I/O failure stops discovery and surfaces the host or filesystem-provider error instead of selecting an ancestor project. The root-marker metadata decision records why discovery fails instead of substituting another root.
- name: '@deepseek-ai/dsh-agent-instructions'
config:
maxBytes: 65536
The accepted fields, at a glance:
export interface Config {
dshHome?: string
projectRootMarkers?: string[]
maxBytes: number
maxSourceBytes?: number
instructionFileCandidates?: string[]
localInstructionFileCandidates?: string[]
}
| Field | Default | Meaning |
|---|---|---|
maxBytes |
required | Cap on the complete rendered baseline message, in bytes |
maxSourceBytes |
1048576 |
Cap on one source instruction file before rendering |
projectRootMarkers |
['.git'] |
Directory names that mark the project root |
instructionFileCandidates |
['AGENTS.md', 'CLAUDE.md'] |
Base file names loaded in each project directory |
localInstructionFileCandidates |
['AGENTS.local.md', 'CLAUDE.local.md'] |
Local overlay file names loaded after the base files |
dshHome |
$DSH_HOME or ~/.dsh |
Directory containing the user-global AGENTS.md |
The generated configuration catalog is the exhaustive source for every accepted field and its JSDoc.
Rendering keeps the most specific files first: it drops whole broader files before truncating the most-specific file, and emits a visible Workspace instruction budget ... notice naming the omitted and truncated paths. The rendered bytes never exceed maxBytes. An over-budget broad file is ignored; during refresh it is treated as temporarily unavailable rather than removed.
Read these pages when the package-level contract is not enough. They move from the instruction-file format to the design decision and the exhaustive configuration.
AGENTS.md instruction files contain and how they are maintained.At the first request, derived history contains one durable user-role message with the bounded user-global and project instruction chain in broad-to-specific order. Resume reuses that message when its visible baseline is compatible.
<system-reminder>
The following workspace instructions may be relevant to your work. Use them as guidance when applicable. More specific instructions take precedence over broader ones. They do not override system, developer, or direct user instructions.
Instructions from: ~/.dsh/AGENTS.md
<user-global-instructions>
Instructions from: AGENTS.md
<project-instructions>
</system-reminder>
The rendered baseline is appended once and remains in derived history until compaction. maxBytes bounds the complete message, broader files are omitted before the most-specific file is truncated, and an empty chain contributes zero tokens.
Append-only after the existing reusable prefix. Resume preserves reuse when the visible baseline identity is compatible; an incompatible identity appends a complete replacement, so discovery, precedence, project-root, or budget changes affect reuse only from that history position.
After a successful first-party filesystem call reaches a deeper directory, the next request includes one retained sourced user/message with the newly applicable instruction file.
<system-reminder>
Additional instructions from: packages/app/AGENTS.md
These instructions apply to work under `packages/app`. Use them as guidance when relevant; more specific instructions take precedence. They do not override system, developer, or direct user instructions.
<nested-instructions>
</system-reminder>
Each discovered scope adds bounded history tokens until compaction. Unchanged content is suppressed by visible session state plus version/digest comparison, and PTC mode defers the same message until after the outer run_code result and its enclosing durable step.
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
A changed file produces Updated instructions from: <path> plus its replacement content. A candidate that disappears or becomes a per-directory duplicate of an earlier candidate produces the removal notice below.
<system-reminder>
Instructions removed: packages/app/AGENTS.md
The previously loaded instructions from this file no longer apply.
</system-reminder>
Each confirmed change or removal is one retained history message bounded by maxBytes. Provider failures add no message, and an update omitted by the budget remains eligible for a later filesystem touch.
Append-only; newly visible content follows the reusable request prefix and does not invalidate existing KV-cache entries.
These limits define when instruction loading is a poor fit or needs operational awareness. They are current package constraints, not a task backlog.
bash command that changes directories does not trigger nested instruction discovery because shell syntax and per-call shell state are not a reliable filesystem seam.read, write, or edit, when resume reconciles a visible baseline, or when an entering pre-step restores a shadowed baseline..claude/rules/, and @path imports are not interpreted; project scopes load AGENTS.local.md/CLAUDE.local.md overlays by default, but the user-global $DSH_HOME scope has no local overlay and other custom names require explicit candidate configuration.CLAUDE.md that symlinks its sibling AGENTS.md resolves to the same content and collapses like any duplicate, while a distinct real copy that has drifted from AGENTS.md loads in full alongside it.ctx.fs with the filesystem policy gate or an OS sandbox when loading untrusted repositories.