skills/devel/serve-md-by-mkdocs/SKILL.md
Serve markdown/docs/text notes with MkDocs using a specified work directory as the output folder (scripts/config/site).
npx skillsauth add igamenovoer/magic-context serve-md-by-mkdocsInstall 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.
Use this skill when you want a quick, web-based viewer for Markdown scattered across a repo (not necessarily docs/), while preserving the original directory structure.
Typical user phrasing that should trigger this skill:
<work_dir> as the work dir”Interpretation:
<work_dir> is the work directory (create it if missing; reuse it if it exists). This folder holds the refresh script, a scanner script, a YAML manifest, the MkDocs config (if needed), a staged symlink tree, and site/ build output.<work_dir>/_staged/) so you can ignore them with a local <work_dir>/.gitignore while keeping scripts/config tracked if you want.This skill’s default approach is:
<work_dir>/_staged/ (typically symlinks; can be adapted to copying)<work_dir>/mkdocs.yml only if missing (existing config is preserved)pymdown-extensions + KaTeX/Mermaid JS/CSS includes)<mkdocs_cmd> serve (use MkDocs defaults unless you specify otherwise)This skill must locate an existing mkdocs first. Do not auto-install it.
Resolution order (stop at the first one that works):
pixi run mkdocs --version
If that works, use <mkdocs_cmd> = pixi run mkdocs.
mkdocs --version
python -m mkdocs --version
If either works, use <mkdocs_cmd> = mkdocs (or python -m mkdocs if the console script is not available).
pixi global and exposed them on PATH):pixi global list
mkdocs --version
If that works, use <mkdocs_cmd> = mkdocs.
mkdocs is already installed as a tool; do not trigger installs):uv tool list
uv tool dir
mkdocs --version
If uv tool list shows mkdocs but mkdocs is not on PATH, run it via the uv tools directory:
tool_dir="$(uv tool dir)"
"${tool_dir}/mkdocs/bin/mkdocs" --version
If that works, use <mkdocs_cmd> = mkdocs (or use the explicit path from above).
python3 -m mkdocs --version
python -m mkdocs --version
If either works, use <mkdocs_cmd> = python3 -m mkdocs (or python -m mkdocs).
If none of the above finds a working mkdocs, fail fast and report “missing dependency: mkdocs”. Never attempt to install mkdocs automatically; let the user install it in their preferred environment manager.
Once mkdocs is found, the agent may auto-install any MkDocs plugins/themes/markdown extensions needed by <work_dir>/mkdocs.yml, but must install them into the same environment that provides <mkdocs_cmd>.
Guidance:
<mkdocs_cmd> build -f <work_dir>/mkdocs.yml (or <mkdocs_cmd> serve -f <work_dir>/mkdocs.yml) and look for missing-module errors (for example: No module named ..., missing mkdocs-material, missing pymdown-extensions, missing mkdocs-extrafiles, etc).mkdocs itself automatically.Notes:
extra_javascript/extra_css plus pymdown-extensions (pymdownx.superfences and pymdownx.arithmatex).Environment-specific install strategy:
<mkdocs_cmd> is pixi run mkdocs (project Pixi):pip install directly):pixi add --pypi mkdocs-material pymdown-extensions
Add other required plugins similarly (example):
pixi add --pypi mkdocs-extrafiles mkdocs-include-markdown-plugin
Then re-run <mkdocs_cmd> build -f <work_dir>/mkdocs.yml to verify.
<mkdocs_cmd> comes from a venv / system Python:python -m pip install mkdocs-material pymdown-extensions
Then re-run <mkdocs_cmd> build -f <work_dir>/mkdocs.yml to verify.
<mkdocs_cmd> comes from a uv tool install:tool_dir="$(uv tool dir)"
ls -la "${tool_dir}/mkdocs/bin" # inspect this directory to find the tool's python
"${tool_dir}/mkdocs/bin/python" -m pip install mkdocs-material pymdown-extensions
Then re-run the uv-provided MkDocs command to verify.
nav: in the main mkdocs.yml.docview-prd, docview-reports, tmp/docview-issuesPRD View127.0.0.1:8000)0.0.0.0 (for example 0.0.0.0:8000 or 0.0.0.0:<port>)<docs_dir> <notes_dir> or <docs_dir>/** or **/*.md<work_dir> already exists, look for “refresh” cues firstIf the user points to an existing <work_dir>, they may mean “refresh/rebuild” rather than “re-scaffold”.
Before generating anything, check for these files inside <work_dir>:
refresh-docs-tree.sh: if present, prefer running it to recreate the staged tree (typically under _staged/, or your chosen --staging-dir), while preserving existing rules and defaults.mkdocs.yml: if present, prefer reusing it (preserves dev_addr / ports, theme/plugins, etc).docview.yml: if present, prefer reusing it (preserves the default scan patterns, exclusions, and gitignore policy).README.md: often documents the env var names (like *_DIRS / *_REPO_ROOT) and default scan patterns.Typical “refresh intent” actions:
bash <work_dir>/refresh-docs-tree.sh
<mkdocs_cmd> serve -f <work_dir>/mkdocs.yml
Only re-scaffold (and overwrite) if the user explicitly asks to “regenerate config/script” (use --force).
Run the scaffolder (writes a new service folder with a refresh-docs-tree.sh, .gitignore, and README):
pixi run python magic-context/skills/devel/serve-md-by-mkdocs/scripts/scaffold_docview_service.py \
--work-dir <work_dir> \
--site-name "Reports View" \
--staging-dir _staged \
--default-target .
Then run:
bash <work_dir>/refresh-docs-tree.sh
<mkdocs_cmd> serve -f <work_dir>/mkdocs.yml
If you want a non-default bind address/port, either:
--dev-addr <addr:port> (bakes it into <work_dir>/mkdocs.yml), or--public (bakes 0.0.0.0:8000 into <work_dir>/mkdocs.yml), or<mkdocs_cmd> serve -f <work_dir>/mkdocs.yml -a 0.0.0.0:<port>Once <work_dir>/refresh-docs-tree.sh exists, you can point it at specific paths:
bash <work_dir>/refresh-docs-tree.sh <docs_dir> <notes_dir>*_DIRS env var shown in <work_dir>/README.md<work_dir>/docview.yml to change the default patterns used when you run bash <work_dir>/refresh-docs-tree.sh with no args/env override<work_dir>/docview.yml)<work_dir>/docview.yml captures your “what should be staged” intent for symlink creation.
Schema:
magic-context/skills/devel/serve-md-by-mkdocs/schemas/docview.schema.jsonKey fields:
mkdocs.dev_addr: records the intended bind address/port (and is used to generate <work_dir>/mkdocs.yml only when that file is missing)scan.include_globs: glob patterns used to discover Markdown (repo-relative)scan.exclude_globs: glob patterns excluded from Markdown discoveryscan.force_globs: glob patterns to scan even if gitignored (explicit user intent)scan.auto_exclude_generated: if true (default), avoid scanning DocView/MDView workdirs and their generated treesscan.respect_gitignore: default true (do not scan gitignored dirs/files for Markdown discovery)assets.include_images: default true (stage local images referenced by selected Markdown)Example (abridged):
version: 1
scan:
auto_exclude_generated: true
respect_gitignore: true
include_globs: ["**/*.md"]
exclude_globs: ["<big_dir>/**"]
force_globs: ["<gitignored_dir>/**"]
assets:
include_images: true
Rules:
.gitignore and uses scan.include_globs from the manifest.. (controlled by scan.include_hidden: false)._staged/ or docs/, and site/) using file/dir-structure heuristics, to avoid self-indexing loops and duplicate pages.scan.force_globs (or pass it as an explicit arg to refresh-docs-tree.sh, which is treated as strong intent).Default scan behavior (when you don’t specify scan locations): the scaffolder writes scan.include_globs so the refresh script scans the whole workspace for Markdown (for example **/*.md) while respecting .gitignore.
Add three tasks under [tool.pixi.tasks]:
<task_prefix>-refresh: bash <work_dir>/refresh-docs-tree.sh<task_prefix>-serve: bash <work_dir>/refresh-docs-tree.sh && mkdocs serve -f <work_dir>/mkdocs.yml<task_prefix>-build: bash <work_dir>/refresh-docs-tree.sh && mkdocs build -f <work_dir>/mkdocs.ymlPick a port based on your local context (or rely on MkDocs defaults).
Note: Pixi tasks run inside the project Pixi environment. Only add these tasks if mkdocs (and any referenced theme/plugins/extensions from <work_dir>/mkdocs.yml) are available in that environment.
After running bash <work_dir>/refresh-docs-tree.sh, verify that all symlinks under the staging directory are valid (no broken links):
find <work_dir>/<staging_dir> -xtype l -print
Expected: no output.
<staging_dir> is usually _staged (or whatever you set via --staging-dir; it should match docs_dir in <work_dir>/mkdocs.yml).
If there is output, rerun the refresh and/or check whether the target source files were moved/deleted, or whether your selected paths/patterns (*_DIRS or CLI args) include paths that no longer exist.
Note: refresh may emit warnings like “missing asset referenced by …” when Markdown references images that don’t exist on disk; those files won’t be staged.
Also verify that the work dir contains the scanner script which decides what gets staged (Markdown + referenced image assets):
<work_dir>/scan-files-to-stage.py<work_dir>/.gitignore ignores the staging subdir (like _staged/), site/, mkdocs.yml, and repo-root.txt. Keep or change this based on whether you want staged symlinks tracked..gitignore (gitignored files/dirs won’t be scanned). However, if a selected Markdown page references a gitignored image file, it will still be staged (symlinked) as long as the file exists.scan.auto_exclude_generated: false in <work_dir>/docview.yml if you intentionally want to index those directories.<work_dir>/docview.yml is always created by this skill, and <work_dir>/scan-files-to-stage.py treats a missing manifest as an error.mkdocs-extrafiles plugin to map external src paths into virtual dest paths under docs_dir.pymdownx.superfences with a mermaid fence + Material integration (the scaffolder emits this).pymdownx.arithmatex + KaTeX auto-render via extra_javascript/extra_css (you can swap to MathJax if preferred).<work_dir>/javascripts/mermaid-init.js and <work_dir>/javascripts/katex-init.js, and refresh-docs-tree.sh stages them into docs_dir so MkDocs can serve them.data-ai
Create readable Mermaid diagrams inside Markdown files. Use for flowcharts and sequence diagrams that must render cleanly in common Markdown renderers (e.g., GitHub) without horizontal scrolling. Covers fenced mermaid blocks, init/theme styling, label wrapping with <br/>, and sequenceDiagram layout rules (short IDs, wrapped labels, don’t break identifiers).
development
Manual invocation only; use only when the user explicitly requests `make-program-tutorial` by exact name, OR when the user asks to use a skill to create an SDK/API/library tutorial. Create a clear, reproducible, step-by-step tutorial for a specific API/SDK/library (or a set of functions/classes), with runnable examples, expected outputs, and basic troubleshooting.
testing
Use when the user wants to create a self-hosted, offline-installable Conda channel (mirror) containing a specific subset of packages using Pixi.
tools
Guides the agent to setup a new or existing Pixi environment for compiling C++ and CUDA code. It ensures the correct compilers, toolkits, and CMake configurations are in place for a robust user-space build.