Agent skill
draft-docs
Generate first-draft technical documentation from code analysis
Install this agent skill to your Project
npx add-skill https://github.com/existential-birds/beagle/tree/main/plugins/beagle-docs/skills/draft-docs
SKILL.md
Draft Docs
Generate Reference or How-To documentation drafts to docs/drafts/ for review before publishing.
Arguments
- Topic prompt: Description of what to document (e.g., "Document the WebSocket API")
- --publish [file]: Move reviewed draft to final location and update navigation
Mode 1: Generate Draft
/beagle-docs:draft-docs "Document the authentication middleware"
Step 0: Gather Context
Before parsing input, gather project context:
# Check for existing docs structure
ls -la docs/ 2>/dev/null || echo "No docs/ directory found"
# Identify documentation framework
ls docs/navigation.json docs/mint.json docs/docusaurus.config.js docs/mkdocs.yml 2>/dev/null | head -1
# Check for existing drafts
ls docs/drafts/*.md 2>/dev/null || echo "No existing drafts"
# Get recent code changes for context
git diff --name-only $(git merge-base HEAD main)..HEAD 2>/dev/null | head -20
Capture:
- Docs structure:
docs/subdirectories present - Navigation system:
navigation.json,mint.json, or other config - Tech stack hints: from file extensions and imports in changed files
- Existing drafts: to avoid duplicates
Step 1: Parse Input
Extract from the prompt:
- Topic: What to document (e.g., "authentication middleware")
- Content type: Detect from keywords:
| Keywords | Type | Skill |
|---|---|---|
| "how to", "guide", "steps", "configure", "set up" | How-To | howto-docs |
| "API", "reference", "parameters", "function", "endpoint" | Reference | reference-docs |
If ambiguous, ask: "Should this be a Reference doc (technical lookup) or How-To guide (task completion)?"
Step 2: Load Skills
Always load both:
beagle-docs:docs-style- Core writing principles- Detected type skill:
beagle-docs:reference-docsfor Referencebeagle-docs:howto-docsfor How-To
Step 3: Analyze Code
Search the codebase for relevant code:
- Symbol search: Find functions, classes, types matching the topic
- File search: Locate related files by name patterns
- Reference search: Find usage examples
Gather:
- Function/method signatures
- Type definitions
- Existing comments/docstrings
- Usage patterns in tests or examples
Step 4: Generate Draft
Apply the loaded skills to generate documentation:
For Reference docs:
- Follow
reference-docstemplate structure - Document all parameters with types
- Include complete, runnable examples from actual code
- Add Related section linking to connected symbols
For How-To docs:
- Follow
howto-docstemplate structure - Start title with "How to"
- List concrete prerequisites
- Break into single-action steps
- Include verification section
Step 5: Write Draft
-
Create output path:
docs/drafts/{slug}.md- Slug from topic: "WebSocket API" →
websocket-api.md
-
Ensure directory exists:
bashmkdir -p docs/drafts -
Write the draft file
-
Report to user:
markdown## Draft Created **File:** `docs/drafts/{slug}.md` **Type:** Reference | How-To **Based on:** [list of analyzed symbols/files] ### Next Steps 1. Review the draft for accuracy 2. Add any missing context or examples 3. When ready, publish with:/beagle-docs:draft-docs --publish docs/drafts/{slug}.md
Step 6: End-of-Run Verification
Verify draft generation completed successfully:
# Confirm draft file exists
ls -la docs/drafts/{slug}.md
# Validate frontmatter (YAML header)
head -10 docs/drafts/{slug}.md | grep -E "^---$|^title:|^description:"
# Check markdown syntax (if markdownlint available)
markdownlint docs/drafts/{slug}.md 2>/dev/null || echo "markdownlint not available"
Verification Checklist:
- Draft file created at
docs/drafts/{slug}.md - Frontmatter includes
titleanddescription - Content type matches detected type (Reference or How-To)
- Code examples are complete and runnable
- All analyzed symbols referenced in draft
If any verification fails, report the specific issue and offer to regenerate.
Mode 2: Publish Draft
/beagle-docs:draft-docs --publish docs/drafts/websocket-api.md
Step 1: Read Draft
Read the draft file and extract:
- Title
- Content type (from frontmatter or structure)
Step 2: Determine Destination
Ask user which section:
Where should this document go?
1. **API Reference** → `docs/api/{slug}.md`
2. **Guides** → `docs/guides/{slug}.md`
3. **How-To** → `docs/how-to/{slug}.md`
4. **Other** → Specify path
Step 3: Move File
mv docs/drafts/{slug}.md {destination}/{slug}.md
Step 4: Update Navigation
Check for docs/navigation.json and update navigation:
- Read current navigation.json
- Find appropriate navigation group
- Add new page entry
- Write updated navigation.json
Example update:
{
"navigation": [
{
"group": "API Reference",
"pages": [
"api/existing-page",
"api/websocket-api"
]
}
]
}
Step 5: Report
## Published
**From:** `docs/drafts/{slug}.md`
**To:** `{destination}/{slug}.md`
**Navigation:** Updated `docs/navigation.json`
The document is now live in your docs.
Step 6: End-of-Run Verification
Verify publish completed successfully:
# Confirm file moved to destination
ls -la {destination}/{slug}.md
# Confirm draft removed
ls docs/drafts/{slug}.md 2>/dev/null && echo "WARNING: Draft still exists" || echo "Draft cleaned up"
# Verify navigation updated
grep -q "{slug}" docs/navigation.json && echo "Navigation includes new page" || echo "WARNING: Navigation may need manual update"
# Check markdown syntax at final location
markdownlint {destination}/{slug}.md 2>/dev/null || echo "markdownlint not available"
Verification Checklist:
- Document moved to
{destination}/{slug}.md - Draft removed from
docs/drafts/ - Navigation file updated with new page entry
- No broken links in navigation structure
- Document accessible at expected URL path
If any verification fails, report the specific issue and offer remediation steps.
Content Type Detection
Reference Indicators
- Prompt mentions: API, endpoint, function, method, class, type, parameters, returns
- Target is a specific symbol or set of symbols
- User wants technical specification
How-To Indicators
- Prompt mentions: how to, guide, steps, configure, set up, integrate
- Target is a task or workflow
- User wants procedural instructions
Rules
- Always load
docs-styleskill for every draft - Generate to
docs/drafts/- never directly to final location - Include frontmatter with title and description
- Use realistic examples from actual codebase
- Reference analyzed symbols in draft metadata
- Preserve existing navigation structure when publishing
- Ask before overwriting existing files
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
review-python
Comprehensive Python/FastAPI backend code review with optional parallel agents
review-verification-protocol
Mandatory verification steps for all code reviews to reduce false positives. Load this skill before reporting ANY code review findings.
sqlalchemy-code-review
Reviews SQLAlchemy code for session management, relationships, N+1 queries, and migration patterns. Use when reviewing SQLAlchemy 2.0 code, checking session lifecycle, relationship() usage, or Alembic migrations.
fastapi-code-review
Reviews FastAPI code for routing patterns, dependency injection, validation, and async handlers. Use when reviewing FastAPI apps, checking APIRouter setup, Depends() usage, or response models.
pytest-code-review
Reviews pytest test code for async patterns, fixtures, parametrize, and mocking. Use when reviewing test_*.py files, checking async test functions, fixture usage, or mock patterns.
postgres-code-review
Reviews PostgreSQL code for indexing strategies, JSONB operations, connection pooling, and transaction safety. Use when reviewing SQL queries, database schemas, JSONB usage, or connection management.
Didn't find tool you were looking for?