cursor/.cursor/skills/kb-generation/SKILL.md
Core generation protocol for Knowledge Base documents. Analyzes project structure, generates Obsidian-compatible markdown with mermaid diagrams, builds relationship graphs, and tracks manifests for incremental updates.
npx skillsauth add akshay-na/dotfiles kb-generationInstall 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.
Generates Obsidian-compatible KB docs from project source code.
1. kb-identity → project_name, kb_path
2. Analyze project → modules, services, deps, edges
3. Generate docs → README, architecture, modules/*, services/*, deps, graph.json
4. Update meta → manifest.json, identity.json
5. Update Home.md
Invoke kb-identity(project_root) → Returns project_name, kb_path, identity_hash.
| Mode | Behavior |
|------|----------|
| full | Clear existing docs (except .meta/identity.json), regenerate all |
| incremental | Compare file hashes via manifest, regenerate only changed |
| refresh-stale | Check frontmatter stale: true, regenerate those docs |
| Category | Files |
|----------|-------|
| Manifests | package.json, Cargo.toml, pyproject.toml, go.mod, pom.xml, build.gradle, Gemfile, composer.json |
| Config | tsconfig.json, .eslintrc, docker-compose.yml, Dockerfile |
| Entry points | index.*, main.*, app.*, mod.rs, __init__.py |
node_modules/, vendor/, .git/, build/, dist/, target/, __pycache__/, lock files, generated files, binaries.
Use templates from ~/.cursor/docs/knowledge-base/templates/.
IMPORTANT: The main project file is named {project_name}.md (NOT README.md) so it appears as the project name in Obsidian's graph.
| Document | Template | Content |
|----------|----------|---------|
| {project_name}.md | project-readme.md | Overview, tech stack, module/service links, stats |
| architecture.md | architecture-doc.md | System diagram, layers, boundaries |
| dependencies.md | dependencies-doc.md | Dep table, graph, security notes |
| modules/_index.md | modules-index.md | Module inventory, dependency matrix |
| modules/<name>.md | module-doc.md | Purpose, API, deps, dependents |
| services/_index.md | services-index.md | Service inventory, communication matrix |
| services/<name>.md | service-doc.md | Purpose, endpoints, deployment |
| graph.json | (schema) | Nodes + edges for programmatic queries |
Fill templates with: {{project_name}}, {{timestamp}}, {{confidence}}, {{module_nodes}}, {{service_nodes}}, etc.
{
"version": 1,
"project": "<name>",
"generated_at": "<ISO8601>",
"nodes": [{ "id": "", "label": "", "type": "module|service|external_dep", "kb_doc": "" }],
"edges": [{ "source": "", "target": "", "relation": "imports|depends_on|calls", "confidence": "EXTRACTED|INFERRED" }]
}
Validate against _schema/graph.schema.json.
Write to .meta/manifest.json:
{
"version": 1,
"project": "<name>",
"generated_at": "<ISO8601>",
"files": {
"<path>": { "sha256": "<hash>", "last_analyzed": "<ISO8601>", "contributed_to": ["README.md"] }
}
}
MANDATORY — Update ~/.cursor/docs/knowledge-base/Home.md after every generation.
templates/home.mdAll docs link TO {project_name}.md (hub). Hub links OUT to all children.
IMPORTANT: Hub file is named {project_name}.md so it shows as the project name in Obsidian's graph.
| Document | Must Link To |
|----------|-------------|
| All non-hub docs | [[{project_name}\|{project_name}]] (REQUIRED) |
| {project_name}.md (hub) | All modules, services, architecture, deps, connected projects |
| Module/Service | Hub + related siblings + cross-project deps |
| Type | Syntax |
|------|--------|
| Hub-to-hub | [[../other-project/other-project\|other-project]] |
| Module-to-module | [[../other-project/modules/api\|Other API]] |
1. Read manifest.json
2. For each source file:
- New → analyze, add to manifest
- Changed hash → analyze, mark contributed_to docs stale
- Deleted → remove from manifest, mark docs stale
- Unchanged → skip
3. Regenerate stale docs
4. Update manifest
| Condition | Behavior | |-----------|----------| | kb-identity fails | Return error immediately | | Cannot read file | Skip, continue, log | | Corrupted manifest | Regenerate from scratch | | Missing template | Use inline default | | Schema validation fails | Log warning, write anyway |
{
"status": "success",
"project_name": "myapp",
"kb_path": "~/.cursor/docs/knowledge-base/projects/myapp/",
"documents_generated": 12,
"stats": { "modules": 5, "services": 2, "dependencies": 23, "edges": 47 }
}
development
Discovery + naming convention reference for typed dev/SME/QA/devops team members in any workspace folder. Primary consumer: `tech-lead` (org-tier).
devops
Automated task classification, agent selection, and state tracking. Use when routing tasks to agents, selecting pipelines, or managing task state.
testing
Use when designing scalable systems, evaluating consistency models, planning state management, making architectural decisions, or when trade-offs around coupling, failure isolation, and reversibility need explicit reasoning before implementation.
tools
CTO/tech-lead helper — split work into disjoint shard briefs with caps (instance_cap, partition_basis, determinism keys).