docs-context — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited docs-context (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
Manages reading and writing of project documentation, ensuring correct contextual constraints during development and keeping docs in sync with code afterward.
docs/)docs-context is the Super Base Context for Agent Coding — structured project docs, task-aware Read Mode, bidirectional Write Mode. The remainder of this file specifies each.
Conflict priority (when this skill's guidance collides with other instructions in the same turn): explicit user instruction > docs-context.
Three scenarios in which docs-context restores the agent's project context — combined documents + code/comment scanning fills the gap when docs alone are insufficient.
All documents are located under the workspace docs/ directory:
| Document | Path | Content |
|---|---|---|
| Architecture | docs/architecture.md | Workspace directory structure, project background, system architecture, service-level topology, constraints, future plans |
| Tech Stack | docs/tech-stack.md | Framework versions, dependency constraints, environment requirements, AI code generation limits |
| Coding Standards | docs/coding.md | Coding standards, naming conventions, API design standards, error handling, logging standards, testing standards |
| Module Registry | docs/modules/<bcu-slug>.md | One file per Business Capability Unit (BCU). Each BCU file holds a single business capability's implementation list (HTTP / RPC / MQ / scheduled tasks / third-party callbacks / DB tables / frontend pages), flow, state transitions, local upstream/downstream, external dependencies, related business flows. Slug names a business capability (e.g. create-order, refund, consumer-pay), NOT a microservice / Controller / package / table |
| Decision Records | docs/decisions/ADR-<slug>.md | One file per architecture decision (ADR). Slug-only filenames (no numeric prefix, no date prefix). Date lives in frontmatter |
No README / index files underdocs/modules/ordocs/decisions/. UseGlobto enumerate; read frontmatter / first-line responsibility on demand.
A docs/modules/<bcu-slug>.md file represents one Business Capability Unit (BCU). A BCU must satisfy all 7 conditions:
Do NOT split by: microservice · Controller · API · technical module · database table. DO split by: real business chain · actual development task boundary · parallel-development unit.
When in doubt whether to merge or split, run this 3-question test:
| Q | If answer is "no" → |
|---|---|
| Q1: When modifying A, do you usually NOT need to touch B/C/D? | merge into one BCU |
| Q2: Can A deliver business value standalone, decoupled from B/C/D? | merge |
| Q3: Does A have a separate owner / schedule / test suite? | merge |
Any "no" → merge. All three "yes" → split. Default to conservative merging — splitting later is cheap (BCU files are independent); splitting too early creates orphaned tiny files. Split only when independent-evolution signals show up: separate owner, separate schedule, separate test suite, modifications no longer cascade.
Worked example — consumer-side payment: a typical "consumer pay" BCU bundles {payment initiation API + sync order query + upstream async callback + scheduled / MQ status reconciliation} into ONE file (e.g. consumer-pay.md) — they share one business goal and one state machine, and they are almost always modified together. Split out to a separate BCU only when "reconciliation crosses multiple BCUs", "order query is independently productized", or "callback routing is independently maintained" — i.e. when the merge condition stops holding.
A BCU file uses two layers of diagrams, each with its own purpose. Both layers respect the section-omission rule — never draw a diagram for its own sake.
Layer 1 — Per-entry tracing diagrams (live inside ## Implementation)
Each entry-point item — HTTP API (inbound), MQ Consumption, Scheduled Task, Third-party Callback — MAY carry a tracing diagram of this entry's full call chain (services / RPC / MQ Production / DB / external systems / resources).
Format — primary: ASCII span tree, supplementary: Mermaid `sequenceDiagram`:
├── / └── / │) or plain ASCII (+--).sequenceDiagram BELOW the tree for global overview. Don't replace the tree — add alongside. The tree is the factual chain; the sequence diagram is the temporal overview.Two rules apply together — optional + complete-when-present:
| Entry-point complexity | Format |
|---|---|
| Trivial single-step (read-and-return / single insert) | Omit |
| Linear / synchronous chain (any depth) | ASCII span tree |
| Async / multi-roundtrip / external callbacks where temporal order matters | ASCII span tree + supplementary Mermaid sequenceDiagram |
ASCII span tree shape:
ENTRY: [protocol/method] [name]
├── [Service.method] (this service)
│ ├── DB.[table] insert/update
│ └── [DownstreamService].[op] (RPC) → [result]
├── [ExternalGateway].[op] (HTTP/SDK) → [result]
└── MQ produce [topic]Non-entry items NEVER carry their own diagram: outbound RPC, MQ Production, Database tables touched, Frontend page, State management. They appear as nodes inside the calling entry's tree. A separate diagram for these is redundant and is forbidden.
Layer 2 — BCU business flow(s) (the ## Flow section, 0 / 1 / N diagrams)
The business-level view: how front-end interactions, business steps, and state transitions weave through the entry points to deliver the BCU's value. This is the business view, NOT a technical hop trace.
A BCU may carry 0, 1, or N business-flow diagrams (1-to-many relationship):
| BCU business-flow situation | Shape |
|---|---|
Single-entry BCU, business flow already obvious from ## Implementation | 0 — omit the entire ## Flow section |
| One coherent business flow | 1 — one diagram directly under ## Flow |
| Multiple distinct business sub-flows (e.g. passive-scan vs aggregated-scan vs refund) | N — ### <Sub-flow name> headings, one diagram per sub-flow. Don't bloat one diagram with mutually exclusive branches. |
Format per diagram: Mermaid sequenceDiagram or flowchart describing business steps; numbered text when truly simple.
Non-redundancy contract:
POST /pay/passive-scan"); it does NOT redraw the entry's internal hopsInclusion boundary (both layers):
docs/architecture.mdWhy this split: a multi-entry BCU (e.g. consumer pay with passive-scan / aggregated-scan / async callback / reconciliation job) needs per-entry tracing for technical clarity AND business-flow diagrams for business clarity. Forcing both into one diagram either bloats it beyond reading or loses one of the two views. Splitting cleanly maps to "what each entry does technically" + "how the business strings them together".
Inside a BCU file, only the skeleton sections are mandatory: title (# <Capability Name>), header lines (Status / Owning service), ## Business Goal, ## Implementation (with at least one entry). All other sections are conditional: ## Flow, ## State Transitions, ## Upstream / Downstream, ## External Dependencies, ## Related Business Flows, ## Risks / Constraints, ## Notes / Gotchas — omit the entire section if the BCU has no relevant content. Do NOT keep empty headings, do NOT write N/A / TBD, do NOT leave placeholder bullets. Same rule applies to ## Implementation sub-bullets — list only what actually exists.
| Mode | When | Responsibility |
|---|---|---|
| Read | Before any project-related work | Load relevant docs, establish constraints |
| Write | After code/decisions land / before commit | Sync affected docs (forward AND reverse) |
Root criterion: does the task need to reference how the project actually works today? If yes, trigger Read Mode.
Triggers on any of:
Does NOT trigger Read Mode: brainstorming with no project reference, generic-knowledge questions (e.g. "how does HashMap work in Java"), pure read-only code explanations. When uncertain, default to Read Mode (defensive).
Single criterion: current code/decision state has a net delta vs. the last-synced doc state.
Net delta scope (bidirectional):
When it fires:
Does NOT fire on (any one match → skip):
docs-context syncs in both directions: when code is added, docs grow; when code or decisions are removed / rolled back, docs shrink to match.
| Code or decision change | Doc action |
|---|---|
| Delete a BCU's code entirely | Delete docs/modules/<bcu-slug>.md |
| Delete a single HTTP API / RPC / MQ producer-consumer / scheduled task / third-party callback inside a BCU | Update the BCU file's ## Implementation section |
| Drop a database table or column | Update affected BCU file's ## Implementation (Database tables touched line) and the header **Database tables touched** line |
| Overturn a previously-merged decision | Delete docs/decisions/ADR-<old>.md (history lives in git) |
| Roll back a previously-recorded refactor | Restore the affected sections (or whole BCU file) to the rolled-back state |
| Remove a cross-BCU dependency | Bidirectional sync: delete this BCU file's ## Upstream / Downstream entry AND the counterpart BCU file's ## Upstream / Downstream entry |
Distinguishing removal from in-session try-and-undo:
| Scenario | Net delta | Write Mode |
|---|---|---|
| Code was synced → now removed | Yes | Triggers (reverse sync) |
| In-session add → in-session delete → net delta zero | No | Skips |
| In-session add → in-session delete, but other parts still have net delta | Yes | Triggers (only for landed parts) |
Detection method: git diff against the last-synced commit; or working tree vs HEAD.
Do not maintain Deprecated / Superseded states. Removal means the doc section is deleted (ADR file deleted, capability section deleted). History is recoverable via git log -- docs/.Every time read mode is triggered, MUST load:
docs/coding.md — Coding standards are the baseline constraint for all tasksmodules/* and decisions/* shortcuts are resolved per the algorithms in §Module / ADR Resolution Strategy below.
| Task Type | Additional Docs | Trigger Criteria |
|---|---|---|
| New feature/module | architecture.md + tech-stack.md + modules/* | add/create/implement new, creating new modules |
| Modify/optimize existing | modules/* + architecture.md | modify/adjust/optimize/refactor/update, or refactoring steps in a plan |
| Bug fix | modules/* | bug/fix/error/exception/debug, or during systematic-debugging flow |
| Tech selection/dependency change | tech-stack.md + decisions/* | introduce new lib/upgrade version/install/upgrade/migrate |
| Architecture discussion/design review | architecture.md + decisions/ + modules/ | architecture/design comparison/design review |
| API design/development | architecture.md + modules/* + tech-stack.md | design new API/modify API params/integration/API design |
| Testing/QA | modules/* + coding.md | writing tests/unit test/integration test/test/spec |
| Database migration | modules/* + tech-stack.md | add field/alter table/migration/schema/DDL/database change |
| Performance optimization | architecture.md + modules/* + tech-stack.md | slow query/performance/bottleneck/slow/perf/optimize query |
| Security fix/audit | coding.md + tech-stack.md + modules/* | security/XSS/injection/vulnerability/CVE/security audit |
When a task spans multiple types (e.g., "add module and introduce new library"), merge and deduplicate all matching document sets.
Because docs/modules/ and docs/decisions/ have no README / index, the agent must resolve which BCU files to load. Use the algorithms below to keep loads precise and bounded — one BCU per file means each load corresponds to one business capability.
Upstream / Downstream Convention (mandatory, do not invert): - Upstream (this BCU calls) — outbound dependencies: APIs / RPCs / MQ topics this BCU invokes. - Downstream (depends on this BCU) — inbound consumers: callers, MQ consumers, frontend pages that depend on this BCU.
>
When reading existing fixtures or projects, if a ## Upstream / Downstream section appears to use the inverse convention, halt and ask the user to confirm direction before bidirectional sync — do not silently re-invert.Glob docs/modules/*.md to get the BCU slug list.create-order, refund, consumer-pay).docs/modules/*.md for those keywords (title line / Business Goal section / Implementation entries).docs/architecture.md service topology to reverse-locate, then ask the user.Glob docs/decisions/ADR-*.md to get the slug list.tags, and title.docs/decisions/ to detect a pre-existing decision on the same topic — see Write Mode §"ADR Write Flow".A — Reconstruction (new session, project unfamiliar): Fixed sequence, ≤ 6–8 files.
docs/coding.mddocs/architecture.mddocs/tech-stack.mdGlob docs/modules/*.md (BCU slug list only)Glob docs/decisions/ADR-*.md (slug list only)ADR-*.mdAfter loading, emit a Reconstruction Summary table so the user (and future sessions) can see exactly what was loaded and why:
## Reconstruction Summary
| File | Why loaded |
|------|-----------|
| docs/coding.md | Mandatory standards |
| docs/architecture.md | Service topology |
| docs/tech-stack.md | Framework / version constraints |
| docs/modules/create-order.md | Owning BCU for this task |
| docs/decisions/ (Glob, none read) | No ADRs matched task keywords |Keep the table compact (one row per file/Glob). If a Glob returned a list but no file was opened, state that explicitly — transparency about non-loads is as important as transparency about loads.
B — Completion (already in a BCU, need upstream/downstream):
## Upstream / Downstream section (cheapest, most precise).docs/modules/*.md for the business keyword or endpoint path.C — Correction (long-conversation attention drift): Fastest restore path.
docs/coding.md (standards drift the fastest).ADR-*.md.architecture.md — it would re-blow the window.coding.md## Upstream / Downstream) with code scanning to confirm impact scopedocs/modules/When to HALT and present an A/B/C menu (must meet at least one trigger):
coding.md (or other docs) is marked with strong language: MUST, STRICTLY ENFORCED, PROHIBITED, MANDATORY, 非强制例外 (e.g. type conventions for money / rate / time, security rules, error-handling contracts).When to PROCEED without halting (note in Doc Sync Summary instead):
Needs User Confirmation in the Doc Sync Summary so the team can decide separately whether to update coding.md, write an ADR, or migrate the existing code.The A/B/C menu (used only when HALT is required):
coding.md should be updated or an ADR recorded.coding.md defines specific comment standards, follow those standards as the primary guideline.When documents contain conflicting guidance, higher-priority documents take precedence:
coding.md (mandatory standards) > architecture.md (architecture constraints) > tech-stack.md (technology limits) > modules/* (module & capability descriptions) > decisions/* (decision rationale)
Check each item against the current code changes. Only update affected docs; skip unaffected ones.
The unit of edit is one BCU file. Each BCU file represents one Business Capability Unit; one code change resolves to one or more BCU files (never to a sub-section of a multi-capability file, since each file is already one BCU).
Identifying the owning BCU: For each change, ask "which user-visible business capability does this code change support?" and locate the matching docs/modules/<bcu-slug>.md file. Three cases:
assets/templates/module.md. Never silently bury new business behavior inside an unrelated BCU.Forward sync bullets only below. Removals / rollbacks are covered in the Removal & Rollback Sync section earlier — do not duplicate here.
docs/modules/<bcu-slug>.md from assets/templates/module.md (slug must be Glob-deduplicated and user-confirmed first; see "Slug Selection" below). Apply the section-omission rule: only emit sections that have actual content this round.planned BCU to live (the planned BCU's implementation just landed) → flip the file's **Status**: planned header line to **Status**: live, then fill in / update the now-real Implementation / Flow / State Transitions etc. Do NOT create a duplicate file.## Implementation section of the owning BCU file## Flow section of the owning BCU file## State Transitions section of the owning BCU file (create the section if it didn't exist before — it's a conditional section per the section-omission rule)## Implementation section of the BCU the page serves**Database tables touched** header line + the relevant ## Implementation table-touch entry of affected BCU(s)## Upstream / Downstream AND the counterpart BCU file's ## Upstream / Downstream. If either side previously omitted the section (no relationships before), create it now.## External Dependencies of the owning BCU file## Related Business Flows of each BCU on the chainSection-omission rule reminder: when writing or updating a BCU file, do NOT add sections that have no content. Conversely, when content first appears, create the section. Empty headings,N/A, andTBDplaceholders are forbidden.
ADR sync follows the CODE, not the moment of decision. A decision being made (in chat, doc, or planning) does NOT trigger ADR creation on its own. The ADR is recorded only when the decision lands in code and changes behavior — same threshold as a capability or module entry. This keepsdocs/decisions/consistent withdocs/modules/and the codebase. Pure planning / brainstorming about a future decision belongs in a plan or spec, not indecisions/.
docs/decisions/ADR-<slug>.md from assets/templates/decision.md (slug user-confirmed; see "ADR Write Flow")Superseded / Deprecated states. History remains accessible via git log -- docs/decisions/.decisions/ this round.Before creating any new file under docs/modules/ or docs/decisions/:
create-order, refund, consumer-pay, merchant-settle). For ADRs use decision keywords. Do NOT name BCU slugs after a Controller, package, microservice, or table.Glob the target directory and compare candidates against existing slugs — pay special attention to synonyms (e.g. notify vs notification) to avoid orphan files.docs/decisions/ (frontmatter tags, title, Background section) using the decision's keywords. If a topic match is found, ask the user: "Topic already covered by ADR-<old>.md — replace or supplement?"rm docs/decisions/ADR-<old>.md, then create docs/decisions/ADR-<new>.md.docs/decisions/ADR-<new>.md with frontmatter.git diff / file state to detect prior unsynced landed changesarchitecture.md service topology; a cross-BCU dependency change must update both BCU files' ## Upstream / Downstream sections)architecture.md, multiple BCU files in cross-BCU changes) — list them explicitly in the sync summary so reviewers can preempt merge conflictsWhen a required document is missing, initiate the template-based creation flow. Silent creation is forbidden — always confirm with the user first.
Do NOT preemptively create the full 5-doc set when only one is needed. Create only the files this task actually touches:
coding.md missing → ask + create coding.md (it is the always-load gate).architecture.md / tech-stack.md / decisions/ uncreated.docs/, docs/modules/, docs/decisions/), then create the UTF-8 file from the matching template populated with this task's content.### Declined / Skipped — silent omission is dishonest.| File | Template |
|---|---|
[workspace]/docs/architecture.md | [skills]/assets/templates/architecture.md |
[workspace]/docs/tech-stack.md | [skills]/assets/templates/tech-stack.md |
[workspace]/docs/coding.md | [skills]/assets/templates/coding.md |
[workspace]/docs/modules/<slug>.md | [skills]/assets/templates/module.md |
[workspace]/docs/decisions/ADR-<slug>.md | [skills]/assets/templates/decision.md |
Thedocs/modules/anddocs/decisions/directories themselves are auto-created on first use (they have no README / index files of their own). Each new business module or decision is its own file derived from the corresponding template.
After completing sync, output in the following format:
## Doc Sync Summary
Code changes: [brief description of changes]
### Updated
- modules/<bcu-slug>.md → Implementation: [what was updated]
- modules/<bcu-slug>.md → Upstream/Downstream: [what was updated]
- modules/<bcu-slug>.md → External Dependencies: [what was updated]
- architecture.md: [what was updated]
- ...
> When a task ran but produced **no net delta** (e.g. tried-and-reverted, or only logging tweaks with zero doc-relevant impact), still emit the summary with `Updated: (none)` so reviewers can see the sync ran and consciously found nothing to change. Silence is not the same as a clean pass.
### Created / Deleted
- Created: docs/modules/<new-slug>.md (user-confirmed)
- Deleted: docs/decisions/ADR-<old-slug>.md (replaced by ADR-<new-slug>.md)
### Declined / Skipped
- docs/coding.md: creation offered, user declined — not synced this round
### No Update Needed
- tech-stack.md: Tech stack unchanged
- coding.md: Standards unchanged
- ...
### Shared files touched (watch for merge conflicts)
- docs/architecture.md
- docs/modules/<bcu-slug-A>.md (also touched by another change today)
### Needs User Confirmation
- decisions/: Chose xxx approach this time, should an ADR be recorded? Suggested slug: `ADR-...`
- modules/: New module candidate slug `notification`; closest existing slugs: [...]~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.