.cursor/skills/maintain-docs/SKILL.md
Periodic documentation maintenance audit. Finds orphaned docs, detects drift between .cursor/rules/ and docs/developer/, validates doc correctness against source code, tracks structural issues in a persistent backlog, and opens PRs to close highest-priority gaps per run. Use when the user asks to audit documentation, sync docs, or maintain the knowledge base.
npx skillsauth add grafana/grafana-pathfinder-app maintain-docsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A periodic skill that audits the documentation knowledge base, detects gaps and drift, validates correctness against the codebase, and opens PRs to incrementally close issues. Designed to be run repeatedly — each invocation checks previous PR outcomes to calibrate effort, uses a complexity budget to address the highest-priority findings, and tracks structural issues in a persistent backlog across runs.
For the architectural rationale behind this skill's design — including the materialized view concept, the distinction between code-coupled facts and human intent, and the prioritization philosophy — see intent.md.
These constraints are absolute and override any other instructions:
.md, .mdc) and text files. No .ts, .tsx, .js, .jsx, .json, .css, or any other code files — ever. This applies to all sub-agents invoked by this skill.git diff --name-only and confirm every changed file ends in .md or .mdc. If any source file appears, abort and report the violation.docs/design/ entirely. Design documents are maintained by humans using the design-review skill. They are not documentation and are not in scope.npm run prettier before committing. The CI build chain requires formatted files.The documentation has two tiers with distinct roles:
.cursor/rules/ files: Compact, prescriptive agent constraints. What agents must do or must not do when working in a domain. These are loaded into agent context.docs/developer/ files: Comprehensive reference documentation. How things work in detail, with examples and explanations. These are for deep dives.When both tiers cover the same topic, the rule file should include a "For full reference, see docs/developer/..." link. Neither should duplicate the other's content verbatim. When drift is detected, the resolution is: check the codebase to determine which version is correct, update the incorrect version, then ensure the cross-reference link exists in both directions.
Some docs/developer/ files contain design rationale — ## Key Design Decisions, ### Why X? subsections, or inline explanations of tradeoffs. This rationale is valuable context for agents making implementation decisions.
The maintain-docs skill treats design rationale as opportunistic, not systematic:
## Design notes section summarizing what was found — but only when there is substantial, citable content to extract. Every claim must cite its source (e.g., (from code comment in X) or (from design doc Y)).The file docs/_maintenance-backlog.md is the skill's persistent memory across runs. It has three sections:
Rules for the backlog file:
Backlog file template:
# Documentation maintenance backlog
Persistent tracker for the maintain-docs skill's persistent state across runs.
## Work items
<!-- Structural issues requiring dedicated effort. Format: date, description, rationale. Remove when resolved. -->
## Validated docs
<!-- Docs checked against source and found accurate. Format: date, doc path. Update date on re-validation. -->
## Exclusions
<!-- Files confirmed as not needing an AGENTS.md entry. Format: path, reason. -->
Goal: Determine whether previous skill runs produced value, and calibrate this run accordingly.
docs/_maintenance-backlog.md if it exists. Load work items, validated doc timestamps, and exclusions into memory for use in later phases.gh pr list --state all --label documentation --search "skill:maintain-docs" --limit 5 --json number,state,mergedAt,closedAt,title
Goal: Build a prioritized list of documentation issues without reading every file in full.
AGENTS.mddocs/**/*.md excluding docs/design/**. Note: docs/sources/ contains plugin documentation published to Grafana.com for external human readers. Index and maintain these like any other docs, but be aware their audience is end users, not agents — they are high-level and functionality-oriented..cursor/rules/*.cursor/skills/**/SKILL.mdFor each file in the full set, assign one status:
For each orphaned file:
For each indexed file:
.cursor/rules/ ↔ docs/developer/). If a pair exists, flag it as a drift check candidate.docs/developer/engines/context-engine.md describes src/context-engine/). Then apply a two-stage filter:
git diff --name-status --diff-filter=ADR between the doc's last commit and HEAD), or renamed exports. Cosmetic changes (formatting, typo fixes, test-only changes) are not meaningful staleness signals. Use git log --stat or git diff --stat to gauge change magnitude. Only flag the doc as a staleness candidate if structural changes are detected.| Priority | Criteria |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| HIGH | Operational doc with no discovery path that constrains a common agent task (releases, feature flags, interactive authoring, CLI tools) |
| HIGH | .cursor/rules/ ↔ docs/developer/ pair with suspected drift (both cover the same topic) |
| HIGH | Missing referenced file — broken link in AGENTS.md |
| HIGH | Indexed doc with structural source changes (new/deleted/renamed files) in a high-traffic domain |
| HIGH | Backlog work item older than 3 runs that has not been addressed |
| MEDIUM | Indexed doc with structural source changes in a lower-traffic domain |
| MEDIUM | Engine or subsystem doc that helps agents working on specific code areas (orphaned) |
| MEDIUM | Recent backlog work item (carried forward from last 1-2 runs) |
| LOW | Supplementary docs (known issues, scale testing) that agents rarely need (orphaned) |
| LOW | README files for stable, rarely-changed areas (orphaned) |
If the audit finds no orphaned docs (after applying exclusions), no staleness candidates (after checking validated timestamps and filtering for structural changes), no drift pairs, and the backlog work items section is empty — do nothing. Report that everything is clean and exit without creating a branch or PR.
If the only actionable items are in the backlog (no new findings from the filesystem audit), use the complexity budget to burn down backlog work items. The backlog is not just a record — it is a work queue. Structural issues that were too large for previous runs should be attempted when they are the highest-priority remaining work.
Before making any edits, prepare the working branch:
git checkout main && git pull origin main to ensure you have the latest main.git checkout -b docs/maintain-docs-YYYY-MM-DD-<2 unique chars>All Phase 2 edits happen on this branch. Never edit files while on main.
Select findings from the top of the scored list, using a complexity budget rather than a flat item count:
| Fix type | Cost | Examples | | --------- | -------- | ------------------------------------------------------------------------------------------------------------- | | Light | 1 point | Add an index entry to AGENTS.md, add a cross-reference link, fix a stale file path, add an exclusion entry | | Heavy | 3 points | Drift correction between rule/doc pair, new rule file creation, staleness validation with factual corrections |
Budget per run: 7 points (reduced to 4 if Phase 0 detects review burden). This allows up to 7 light fixes, or 2 heavy fixes + 1 light fix, or similar combinations. When related docs share a domain (e.g., all files under docs/developer/engines/), group them as a single finding.
For each selected finding, delegate to a sub-agent with a tightly scoped task description.
CRITICAL: Every sub-agent invocation must include this instruction: "You may ONLY modify .md and .mdc files. No source code changes are permitted under any circumstances."
Sub-agent task:
docs/sources/ may serve their purpose without agent indexing. If the doc does not constrain agent behavior or provide context agents need for implementation tasks, add it to the backlog's Exclusions section with a brief reason and move on. This is a light fix (1 point)..cursor/rules/ file if one exists for the same domainpackage.json?.cursor/rules/ counterpart exists for the same domain, add cross-reference links in both directionsSub-agent task:
.cursor/rules/ file and its docs/developer/ counterpartdocs/developer/..." pointerFor an indexed doc flagged as stale (structural source changes detected):
Sub-agent task:
## Design notes section — but only with citable, real content (see "Design rationale in docs" above).This is a heavy fix (3 points). Prioritize staleness validation for docs that constrain common agent tasks (feature flags, interactive authoring, engines) over docs for rarely-touched areas.
For a complex domain that has a docs/developer/ reference but no .cursor/rules/ constraint file:
.cursor/rules/ file with prescriptive constraints only — not a copy of the reference docdocs/developer/..." pointeralwaysApply: false, description, and glob triggers if applicable)If an issue is too large for incremental editing (e.g., a doc needs a complete rewrite, or multiple docs should be merged):
docs/_maintenance-backlog.md with the current date and a brief rationaleAfter all sub-agents have completed their work, review the combined diff before proceeding to PR creation.
git diff and read the full output.foo" to "function bar", confirm bar actually exists.git checkout -- <file>) rather than trying to fix it. A skipped fix is better than an incorrect one.git diff --name-only and verify every changed file ends in .md or .mdc. If any other file type appears, stop immediately and report the problem. Do not proceed.npm run prettier to format all markdown files per CI rules.git diff --name-only again after prettier. Prettier should only touch markdown files. If it modified anything else, abort and report.You should already be on the docs/maintain-docs-* branch created before Phase 2.
git branch --show-current and confirm it starts with docs/maintain-docs-. If you are on main, stop immediately.documentation and using the template below.skill:maintain-docs so humans can identify skill-generated PRs. Example: skill:maintain-docs index orphaned operational docs in AGENTS.mddocumentation label to the PR (e.g., gh pr create --label documentation ...)Use this structure for the PR body:
## Summary
Documentation maintenance run — [DATE].
### Changes made
- [Brief description of each change]
### Full audit findings
| Priority | Finding | Status |
| -------- | ------- | ------ |
| HIGH | [description] | Fixed in this PR |
| HIGH | [description] | Deferred |
| MEDIUM | [description] | Deferred |
| LOW | [description] | Deferred |
### Recommendations for separate work
- [Any structural recommendations that need a dedicated effort]
### Validation checklist
- [ ] All changed files are `.md` or `.mdc` (verified via `git diff --name-only`)
- [ ] Phase 2.5 verification passed (sub-agent output reviewed)
- [ ] `npm run prettier` passed
- [ ] No source code files were modified
This skill is designed to stay within context limits:
gh command — minimal contextgit diff for verification — proportional to the number of fixes attemptedThe skill self-regulates through several mechanisms:
If the skill produces no-op runs for 3+ consecutive invocations, consider reducing frequency to biweekly or trigger-based only. The skill works best when run in response to actual codebase changes, not on a fixed calendar.
development
Run typecheck, lint, and tests for both frontend and Go backend to tidy and test the code prior to committing and pushing.
tools
Optimise Grafana app plugin bundle size using React.lazy, Suspense, and webpack code splitting. Use when the user asks to reduce plugin bundle size, optimise module.js, add code splitting, improve initial plugin load performance, split plugin chunks, lazy load plugin pages, or help implement lazy loading in a Grafana app plugin. Triggers on phrases like "optimise plugin bundle size", "module.js is too large", "plugin is slow to load", "code split the plugin", "reduce initial JS payload", or "help me with Suspense in my plugin".
tools
Run E2E CLI against a JSON guide to analyze edge cases and behavior. Use when the user wants to test a guide with the e2e CLI for learning purposes, study e2e failures, analyze screenshots, or investigate edge cases in the guide runner.
development
Principal engineer level architecture design review and critique. Use when the user asks for design review, architecture feedback, design partnership, risk analysis of a design doc, or wants to drive ambiguity out of a plan. Never writes code; operates as a conversational design partner.