Generate the initial context graph from the current codebase. This is the most important command — it creates the foundation that all other context-graph commands build on.
From context-graphnpx claudepluginhub nbkm8y5/claude-plugins --plugin context-graphGenerate the initial context graph from the current codebase. This is the most important command — it creates the foundation that all other context-graph commands build on.
Check if .claude/context-graph/ already exists.
index.md as index.md.bak before proceeding..claude/context-graph/
index.md
schema.md
entities/
Read the following files for entity format and conventions:
${CLAUDE_PLUGIN_ROOT}/skills/knowledge-management/references/entity_schema.md${CLAUDE_PLUGIN_ROOT}/skills/knowledge-management/references/graph_conventions.mdUse Glob and Read to scan the codebase. Start broad, then narrow down:
Project metadata: Read package.json, Cargo.toml, pyproject.toml, go.mod, Gemfile, build.gradle, pom.xml, or equivalent — whichever exists. Extract project name, dependencies, and scripts.
Documentation: Read README.md, CLAUDE.md, ARCHITECTURE.md, docs/ directory — extract high-level architecture, conventions, and design decisions.
Source structure: Glob for top-level source directories (src/, lib/, app/, pkg/, internal/, cmd/). Identify major modules/components by directory structure.
Configuration: Glob for config files (.env.example, docker-compose.yml, k8s/, terraform/, Dockerfile, CI configs). Identify infrastructure and deployment patterns.
Database/Data models: Glob for schema files (migrations/, prisma/schema.prisma, models/, schemas/, *.graphql, *.proto). Identify data models.
External integrations: Grep for API client configurations, SDK imports, webhook handlers. Identify third-party integrations.
Tests: Glob for test directories to understand test coverage and test strategy.
If $ARGUMENTS contains --depth shallow, scan only project metadata, documentation, and top-level source directories. If --depth deep (default), perform the full scan.
If $ARGUMENTS contains --focus "area", prioritize files and directories related to that area.
From the discovered information, identify entities to create. Aim for 5-20 entities depending on project size.
Priority order:
project-context — One entity for the project overview (always created)component — One per major module, service, or subsystemdata-model — One per significant data structure or database tableinfrastructure — One per deployment target, database, cache, or queueintegration — One per external service or APIdecision — One per significant architectural decision found in docs or code commentsNaming rules:
auth-service, not AuthService or auth_servicepostgres-primary, not databaseadopt-typescript, use-monorepoFor each identified entity, create a file in .claude/context-graph/entities/ following the entity schema:
# {Entity Name}
**Type:** {type}
**Created:** {today's date YYYY-MM-DD}
**Last Updated:** {today's date YYYY-MM-DD}
**Tags:** {relevant tags}
## Summary
{2-5 sentences about this entity}
## Properties
- **Owner:** {team or "unassigned"}
- **Status:** {active|planned|in-progress}
- **Files:** {list of relevant file paths}
- **Dependencies:** {list of other entity names}
## Relations
{typed relations to other entities using [[link]] syntax}
## Notes
{gotchas, historical context, non-obvious info}
Ensure relations are bidirectional: if A depends-on B, then B should have consumed-by A.
Write .claude/context-graph/schema.md documenting the entity types and relation types used:
# Context Graph Schema
## Entity Types
- **component** — A module, service, or subsystem
- **data-model** — A database table, schema, or data structure
- **decision** — An architectural or design decision
- **infrastructure** — A deployment, hosting, or ops resource
- **integration** — An external service or API integration
- **project-context** — High-level project information
## Relation Types
- **depends-on** — Requires this entity to function
- **consumed-by** — Used by this entity
- **decided-by** — Governed by this decision
- **replaces** — Supersedes this deprecated entity
- **implements** — Realizes this specification
- **tested-by** — Has test coverage from this entity
Write .claude/context-graph/index.md listing all entities grouped by type:
# Context Graph Index
> Auto-generated by /context-bootstrap on {date}. {N} entities.
## Project Context
- [[project-overview]] — High-level project summary and conventions
## Components
- [[auth-service]] — Handles authentication and authorization
- [[api-gateway]] — Routes and rate-limits API traffic
## Data Models
- [[user-model]] — User account and profile data
## Infrastructure
- [[postgres-primary]] — Primary PostgreSQL database
## Integrations
- [[stripe-integration]] — Payment processing via Stripe API
## Decisions
- [[adopt-jwt-tokens]] — JWT tokens for API authentication
Entities within each section are sorted alphabetically.
Tell the user:
/context-map to generate the visual dependency graph