skills/codebase-teach/SKILL.md
Analyzes project bounded contexts, extracts business rules and domain knowledge, writes ai-context/features/<context>.md files, and produces a teach-report.md with documentation coverage metrics. Trigger: /codebase-teach, teach codebase, extract domain knowledge, update feature docs.
npx skillsauth add fearovex/claude-config codebase-teachInstall 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.
Analyzes bounded contexts from the project's source tree, extracts domain knowledge per context, writes
ai-context/features/<context>.mdfiles, and producesteach-report.mdwith coverage metrics.
Triggers: /codebase-teach, teach codebase, extract domain knowledge, update feature docs, analyze bounded contexts
codebase-teach fills the ai-context/features/ layer with structured domain knowledge derived from reading source code. It is the deep-read complement to memory-update (which records session decisions) and memory-init (which scaffolds empty stubs). It MUST only be invoked manually by the user.
This step is non-blocking: any failure (missing file, unreadable file) MUST produce at most an INFO-level note. This step MUST NOT produce status: blocked or status: failed.
ai-context/stack.md — tech stack, versions, key tools.ai-context/architecture.md — architectural decisions and rationale.ai-context/conventions.md — naming patterns, code conventions.CLAUDE.md (at project root) and extract the ## Skills Registry section.For each file:
INFO: [filename] not found — proceeding without it.Last updated: or Last analyzed: date. If date is older than 30 days: log NOTE: [filename] last updated [date] — context may be stale. Consider running /memory-update or /project-analyze.Also read project config file (config.yaml at project root) if it exists, and extract teach_max_files_per_context if present:
max_files = teach_max_files_per_contextmax_files = 10 (default)Log: "File cap per context: [max_files] (source: config.yaml)" or "File cap per context: 10 (default)"
Identify bounded context candidates by scanning the project directory tree at depth ≤ 2 under these root directories (in order):
src/ — subdirectories at depth 1 (e.g., src/auth/, src/payments/)app/ — subdirectories at depth 1features/ — subdirectories at depth 1domain/ — subdirectories at depth 1ai-context/features/ — existing feature file names (each file stem is treated as a context name)Exclusion rules — skip directories named: shared, utils, common, lib, types, hooks, components, __tests__, test, tests, node_modules, .git
Cross-reference with existing feature files:
Read the ai-context/features/ directory (if it exists) and list all .md files, excluding files whose names begin with _ (e.g., _template.md).
For each detected context candidate, build a record:
{ slug: kebab-case of directory name, dir_path, existing_feature_file: bool }
Slug convention: lowercase the directory name; replace spaces and underscores with hyphens. Example: UserProfile → user-profile, auth_service → auth-service.
If no context candidates are found:
"No bounded context directories detected."teach-report.md with a Summary noting "No bounded context directories detected" and a recommendation to run /memory-init first.If ai-context/features/ does not exist:
"INFO: ai-context/features/ not found — feature files will be created if possible."teach-report.md: "ai-context/features/ was absent at run time. Recommend running /memory-init to scaffold the directory before re-running /codebase-teach."Output: context_list = [{ slug, dir_path, existing_feature_file: bool }, ...]
Log each context found: "Detected context: [slug] — [dir_path] (feature file: [exists|absent])"
Process contexts one at a time. For each context in context_list:
Enumerate implementation files in dir_path (recursive), filtering for file extensions: .ts, .tsx, .js, .jsx, .py, .java, .kt, .rb, .go, .ex, .exs, .cs, .rs, .php, .swift
*.test.*, *.spec.*, test_*, *_test.*, *.d.ts, *.min.*Apply file cap: read at most max_files files. If total enumerated > max_files, log: "[slug]: [total] files found — sampling [max_files] (cap applied)"
For each file to read:
skipped_files with reasonAccumulate: context_knowledge = { slug, rules[], invariants[], entities[], integrations[], files_read[], skipped[] }
ai-context/features/<slug>.mdFor each context processed in Step 2:
If ai-context/features/<slug>.md does not exist (or ai-context/features/ is absent):
[auto-updated] markersIf ai-context/features/<slug>.md already exists:
<!-- [auto-updated]: codebase-teach ... --> ... <!-- [/auto-updated] --> blocks[auto-updated] blocks[auto-updated] block[auto-updated] block exists for a section, append the section at the end of the file inside a new [auto-updated] blockSix-section feature file structure:
# [Context Name] — Domain Knowledge
Last updated by: codebase-teach
Last run: YYYY-MM-DD
---
## Domain Overview
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
[AI-extracted 2–4 sentence summary of what this bounded context does and its primary responsibilities]
<!-- [/auto-updated] -->
---
## Business Rules and Invariants
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
[AI-extracted explicit conditional constraints and always-true invariants from the source]
- Rule: [description]
- Invariant: [description]
<!-- [/auto-updated] -->
---
## Data Model Summary
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
Key entities detected:
| Entity | Key Fields |
|--------|-----------|
| [Name] | [field1, field2, ...] |
<!-- [/auto-updated] -->
---
## Integration Points
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
External dependencies and integration touchpoints:
- [service/API name]: [what it is used for]
<!-- [/auto-updated] -->
---
## Decision Log
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
<!-- Append new AI-detected decisions below. Human entries above this marker are preserved. -->
<!-- [/auto-updated] -->
---
## Known Gotchas
<!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD -->
<!-- Append new AI-detected gotchas below. Human entries above this marker are preserved. -->
<!-- [/auto-updated] -->
_template.md guard: never read, write, or treat any file whose name begins with _ as a feature context. Skip entirely.
teach-report.mdCoverage calculation:
documented_contexts = count of contexts that have an ai-context/features/<slug>.md file after Step 3
total_contexts = count of contexts in context_list
coverage_pct = (documented_contexts / total_contexts) * 100 (0 if total_contexts == 0)
gap_list = contexts in context_list where existing_feature_file was false before Step 3
AND no file was created in Step 3
Write teach-report.md in the project working directory root (same level as analysis-report.md). Overwrite if it exists.
# Teach Report — [Project Name]
Last run: YYYY-MM-DD
Skill: codebase-teach
## Summary
Contexts detected: [total_contexts]
Contexts documented: [documented_contexts]
Coverage: [coverage_pct]%
## Coverage
[coverage_pct]% — [documented_contexts] of [total_contexts] contexts documented.
## Gaps
Contexts detected in code but not documented in ai-context/features/:
- [context-slug] — [dir_path]
[If no gaps: "None — all detected contexts are documented."]
## Files Read
### [context-slug]
- [file path] — sampled
- [file path] — sampled
- [file path] — SKIPPED: [reason]
[Repeat for each context]
## Sections Written / Updated
- ai-context/features/[context].md — [created|updated] — sections: [list of sections written]
If ai-context/features/ was absent at run time, append to the Summary section:
Note: ai-context/features/ was absent at run time. Recommend running /memory-init to scaffold the directory before re-running /codebase-teach.
ai-context/stack.md, ai-context/architecture.md, ai-context/conventions.md, ai-context/known-issues.md, or ai-context/changelog-ai.mddocs/_ in ai-context/features/[auto-updated] markers when updating existing feature filesteach_max_files_per_context cap (default 10) to every contextteach-report.md under the "Files Read" section for the relevant contextteach-report.md on every successful run[auto-updated] marker format: <!-- [auto-updated]: codebase-teach — last run: YYYY-MM-DD --> ... <!-- [/auto-updated] --> — consistent with project-analyze conventionteach-report.md (mandatory — written to project root on every run)Required sections:
| Section | Content | |---------|---------| | Summary | Contexts detected, documented, coverage % | | Coverage | Percentage and ratio | | Gaps | Contexts found in code but undocumented (or "None") | | Files Read | Per-context list of files sampled and skipped | | Sections Written / Updated | Per-feature-file: created or updated, which sections |
ai-context/features/<context>.md (one per bounded context)Written or updated during Step 3. Six sections with [auto-updated] markers on all AI-generated content.
business
Turns an already-investigated customer issue into a short, non-technical engineering-to-CS brief: one natural message that leads with the finding (root cause, real scope, open question), ready to paste into Slack for the support team. Trigger: /support-brief, support brief, brief for support, resumen soporte.
development
Parks the current Claude Code session before going to sleep. Analyzes the conversation, writes a handoff document to docs/handoffs/ in the current project, mirrors the same summary to engram tagged with the session ID, and prints the exact `claude --resume <id>` command for tomorrow. Zero interaction — runs end-to-end on a single invocation. Trigger: /night-park, night park, park session, me voy a dormir, guardar sesion.
testing
Interactive creator for a project feature: scaffolds the domain knowledge markdown at ai-context/features/<slug>.md AND the antenna skill at .claude/skills/<slug>/SKILL.md, both from the canonical templates. Also registers the antenna in the project's CLAUDE.md. Trigger: /feature-define <name>, define feature, documentar funcionalidad, nueva feature.
data-ai
Generates a short, non-technical, informal English summary of an already-investigated customer issue, ready to paste into Slack/email for support, CX, or ops teammates. Trigger: /customer-summary, customer summary, resumir customer issue, slack summary.