phx:document
This Claude Code skill generates `@moduledoc` and `@doc` documentation strings for Elixir modules, contexts, and schemas after implementation. Use it after completing feature work and passing code review to document newly created modules and public functions, ensuring documentation covers API parameters, return values, and edge cases while preserving existing documentation that may capture design intent not visible in code alone.
git clone --depth 1 https://github.com/oliver-kriska/claude-elixir-phoenix /tmp/phx-document && cp -r /tmp/phx-document/plugins/elixir-phoenix/skills/document ~/.claude/skills/phx-documentSKILL.md
# Document
Generate documentation for newly implemented features.
## Usage
```
/phx:document .claude/plans/magic-link-auth/plan.md
/phx:document magic link authentication
/phx:document # Auto-detect from recent plan
```
## Iron Laws
1. **Never remove existing documentation** — Existing docs may reflect design intent that isn't obvious from code alone; update rather than replace
2. **@moduledoc on every public module** — Undocumented modules accumulate quickly and create onboarding friction for new team members
3. **ADRs capture the "why", not the "what"** — Code shows what was built; ADRs explain why this approach was chosen over alternatives
4. **Match @doc to function's public API** — Document parameters, return values, and edge cases; callers shouldn't need to read the implementation
5. **DO NOT add @doc to untested code** — documentation implies a stable contract; document only after tests confirm the function behaves as described
## What Gets Documented
| Output | Description |
|--------|-------------|
| `@moduledoc` | For new modules missing documentation |
| `@doc` | For public functions without docs |
| README section | For user-facing features |
| ADR | For significant architectural decisions |
## Workflow
### Step 0: Pre-check (avoid no-op runs)
Run `git diff --name-only HEAD~5 | grep '\.ex$' | head -20` to check for new `.ex` files.
If NO new `.ex` files were added (only modifications), skip the full
audit and report: "No new modules — documentation coverage unchanged."
This prevents 35-message analysis sessions that conclude "PASS" with
zero output (confirmed: session bb0a0454 wasted ~2K tokens on no-op).
1. **Identify** new modules from recent commits or plan file
2. **Check** documentation coverage (`@moduledoc`, `@doc`)
3. **Generate** missing docs using templates
4. **Add** README section if user-facing feature
5. **Create** ADR if architectural decision was made
6. **Write** report to `.claude/plans/{slug}/reviews/{feature}-docs.md`
## When to Generate ADRs
| Trigger | Create ADR |
|---------|-----------|
| New external dependency | Yes |
| New database table | Maybe (if schema non-obvious) |
| New OTP process | Yes (explain why process needed) |
| New context | Maybe (if boundaries non-obvious) |
| New auth mechanism | Yes |
| Performance optimization | Yes |
## Integration with Workflow
```text
/phx:plan → /phx:work → /phx:review
↓
/phx:document ← YOU ARE HERE (optional, suggested after review passes)
```
## References
- `${CLAUDE_SKILL_DIR}/references/doc-templates.md` — @moduledoc, @doc, README, ADR templates
- `${CLAUDE_SKILL_DIR}/references/output-format.md` — Documentation report format
- `${CLAUDE_SKILL_DIR}/references/doc-best-practices.md` — Elixir documentation best practices
- `${CLAUDE_SKILL_DIR}/references/documentation-patterns.md` — Detailed documentation patternsAsh Framework — resources, actions, policies, aggregates, calculations,
Compatibility alias for the Elixir/Phoenix plugin's LiveView assigns audit. Invoke explicitly with /lv:assigns.
Inspect LiveView socket assigns for memory bloat — missing temporary_assigns, unused assigns, unbounded lists needing streams, memory estimates. Use when LiveView memory grows or you need to add temporary_assigns.
Project health audit and health check — architecture, performance, tests, dependencies, code quality. Use when assessing overall project health, before releases, or after refactors.
Analyze Phoenix context boundaries and module coupling via mix xref. Use when checking cross-context calls, validating dependencies, before splitting modules, or reviewing architecture.
Brainstorm Elixir/Phoenix features — explore ideas, compare approaches, gather requirements. Use when vague idea, not sure how to approach, or want to discuss before plan.
Interactive briefing of a plan file — explains reasoning, schema decisions, component choices. Use when developers need to understand a plan before approving.
Summarize and review what changed while you were away. Use after a weekend, vacation, or flight to check missed PRs, git commits, Linear tickets, and meetings — one prioritized brief, not a firehose.