|
| 1 | +--- |
| 2 | +name: al-docs |
| 3 | +description: This skill should be used when the user asks to "document AL code", "generate docs for this app", "create documentation for this extension", "document this BC app", "set up docs for this AL project", "refresh my docs after code changes", "what documentation is missing", or wants to bootstrap, update, or audit documentation for a Business Central AL codebase. Generates hierarchical docs (CLAUDE.md, data-model.md, business-logic.md, extensibility.md, patterns.md) tailored to AL object types, table relationships, event architecture, and extension patterns. |
| 4 | +allowed-tools: Read, Write, Edit, Glob, Grep, Bash(*) |
| 5 | +argument-hint: "[init|update|audit] [path]" |
| 6 | +--- |
| 7 | + |
| 8 | +# AL Documentation Generator |
| 9 | + |
| 10 | +Generate, update, and audit hierarchical documentation for Business Central AL codebases. Produces documentation adapted to AL object types, table relationships, event-driven architecture, and extension patterns. |
| 11 | + |
| 12 | +## Usage |
| 13 | + |
| 14 | +``` |
| 15 | +/al-docs # Bootstrap docs (same as /al-docs init) |
| 16 | +/al-docs init # Bootstrap documentation for AL app or folder |
| 17 | +/al-docs init "path/to/app" # Bootstrap docs for a specific path |
| 18 | +/al-docs update # Incrementally refresh docs based on changes |
| 19 | +/al-docs audit # Read-only gap analysis without writing files |
| 20 | +``` |
| 21 | + |
| 22 | +## Routing |
| 23 | + |
| 24 | +Based on the argument provided, load and follow the appropriate mode file. Always read the full mode file before executing -- never run from memory. |
| 25 | + |
| 26 | +### If argument starts with "init" (or no argument) |
| 27 | + |
| 28 | +Read and follow `skills/al-docs/al-docs-init.md` from the plugin directory. Pass any remaining text as the target path. |
| 29 | + |
| 30 | +### If argument starts with "update" |
| 31 | + |
| 32 | +Read and follow `skills/al-docs/al-docs-update.md` from the plugin directory. Pass any remaining text as options (baseline commit, path filter). |
| 33 | + |
| 34 | +### If argument starts with "audit" |
| 35 | + |
| 36 | +Read and follow `skills/al-docs/al-docs-audit.md` from the plugin directory. Pass any remaining text as the target path. |
| 37 | + |
| 38 | +## Mode files |
| 39 | + |
| 40 | +| Mode | Command | File | |
| 41 | +|------|---------|------| |
| 42 | +| Init | `/al-docs init` | `skills/al-docs/al-docs-init.md` | |
| 43 | +| Update | `/al-docs update` | `skills/al-docs/al-docs-update.md` | |
| 44 | +| Audit | `/al-docs audit` | `skills/al-docs/al-docs-audit.md` | |
| 45 | + |
| 46 | +## What gets generated |
| 47 | + |
| 48 | +Documentation is hierarchical -- more general at the app level, more specific deeper in the tree. |
| 49 | + |
| 50 | +### Doc types |
| 51 | + |
| 52 | +| File | Purpose | |
| 53 | +|------|---------| |
| 54 | +| `CLAUDE.md` | Mental model: what this area does, how it works, and non-obvious things to know | |
| 55 | +| `data-model.md` | How tables relate and why -- intent, design decisions, gotchas (not field lists). Always includes a mermaid ER diagram. | |
| 56 | +| `business-logic.md` | Processing flows as narrative -- decision points, error handling. Includes mermaid flowcharts for processes with branching. | |
| 57 | +| `extensibility.md` | Extension points, events, interfaces -- how to customize without modifying core code | |
| 58 | +| `patterns.md` | Non-obvious coding patterns (including legacy patterns to avoid in new code) | |
| 59 | + |
| 60 | +### Documentation levels |
| 61 | + |
| 62 | +| Level | Location | Content | |
| 63 | +|-------|----------|---------| |
| 64 | +| App (has `app.json`) | `/CLAUDE.md`, `/docs/` | App-wide overview, full data model, cross-cutting logic, extensibility, and patterns | |
| 65 | +| Subfolder at any depth (scored 7+) | `/[path]/docs/` | CLAUDE.md + at least one of data-model/business-logic/extensibility/patterns | |
| 66 | +| Subfolder at any depth (scored 4-6) | `/[path]/docs/` | CLAUDE.md only | |
| 67 | + |
| 68 | +### Scope detection |
| 69 | + |
| 70 | +1. **Target has `app.json`** -- document the entire app as the project level |
| 71 | +2. **Target is a folder without `app.json`** -- document that folder; if subfolders at any depth have enough substance, they get their own docs |
| 72 | +3. **Recursive evaluation** -- subfolders are evaluated recursively; a subfolder's subfolder can be documented independently if it scores high enough |
| 73 | +4. **Locality principle** -- deeper docs are more specific; higher docs are more general, pointing down to specifics |
| 74 | + |
| 75 | +## AL object types and scoring |
| 76 | + |
| 77 | +For the full list of AL object types, subfolder scoring criteria, and change-to-doc mapping, read `skills/al-docs/references/al-scoring.md`. |
| 78 | + |
| 79 | +Summary of scoring classifications: |
| 80 | + |
| 81 | +- **MUST_DOCUMENT (7+)**: CLAUDE.md + at least one of data-model/business-logic/extensibility/patterns |
| 82 | +- **SHOULD_DOCUMENT (4-6)**: CLAUDE.md only |
| 83 | +- **OPTIONAL (1-3)**: Skip |
| 84 | + |
| 85 | +## Microsoft Docs MCP |
| 86 | + |
| 87 | +During discovery, use the Microsoft Learn MCP tools (`microsoft_docs_search`, `microsoft_docs_fetch`, `microsoft_code_sample_search`) to research the feature area being documented. This provides context about the intended behavior, official terminology, and design rationale that may not be obvious from the source code alone. |
| 88 | + |
| 89 | +- Search for the app's feature area (e.g., "Business Central Shopify connector", "Business Central inventory management") to understand what the feature is supposed to do |
| 90 | +- Use this context to write better "How it works" and "Things to know" sections |
| 91 | +- **Source code is the source of truth.** Microsoft docs may be outdated or describe planned behavior that differs from the implementation. When docs conflict with what the code actually does, trust the code. Note the discrepancy in documentation if it's meaningful (e.g., "the docs describe X, but the implementation does Y"). |
| 92 | + |
| 93 | +## Critical rules |
| 94 | + |
| 95 | +1. **Always read the mode file** -- never attempt to run a mode from memory |
| 96 | +2. **User approves before writing** -- present the documentation map or update plan first |
| 97 | +3. **Based on real analysis** -- every statement must trace back to actual AL code read during discovery |
| 98 | +4. **Preserve existing content** -- when updating, add/edit sections, never delete human-written content |
| 99 | +5. **Locality** -- document as locally as possible, getting more general going up the tree |
| 100 | +6. **No mechanical listings** -- never list fields, procedures, or AL objects that an LLM can read from code. Capture intent, relationships, gotchas, and design decisions. |
| 101 | +7. **Concise over comprehensive** -- shorter docs with real knowledge beat longer docs that list everything |
| 102 | +8. **Use Microsoft Docs MCP** -- query Microsoft Learn during discovery to understand feature intent, but always trust source code over docs when they conflict |
0 commit comments