From rapid
Analyze codebase and generate project context files (CLAUDE.md, style guide, conventions)
npx claudepluginhub pragnition/pragnition-public-plugins --plugin rapidThis skill is limited to using the following tools:
You are the RAPID context generator. This skill analyzes an existing codebase and generates context files that agents use to understand project conventions, architecture, and style. Follow these steps IN ORDER. Do not skip steps.
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
You are the RAPID context generator. This skill analyzes an existing codebase and generates context files that agents use to understand project conventions, architecture, and style. Follow these steps IN ORDER. Do not skip steps.
Run the brownfield detector to check if source code exists:
if [ -z "${RAPID_TOOLS:-}" ] && [ -n "${CLAUDE_SKILL_DIR:-}" ] && [ -f "${CLAUDE_SKILL_DIR}/../../.env" ]; then export $(grep -v '^#' "${CLAUDE_SKILL_DIR}/../../.env" | xargs); fi
if [ -z "${RAPID_TOOLS}" ]; then echo "[RAPID ERROR] RAPID_TOOLS is not set. Run /rapid:install or ./setup.sh to configure RAPID."; exit 1; fi
node "${RAPID_TOOLS}" context detect
Parse the JSON output. The response contains hasSourceCode (boolean) and either a message (when false) or manifest (when true).
Decision logic:
hasSourceCode is false: Use AskUserQuestion with:
hasSourceCode is true: Store the manifest data for use in Step 3. Continue to Step 2.The manifest contains:
codebase: Detected languages, frameworks, config files, and source file statsconfigFiles: Array of config files with their categories and parsed contentsstructure: Directory tree of the projectsampleFiles: Prioritized list of source files for deep analysis (entry points first, then tests, then source)Run the context directory setup:
node "${RAPID_TOOLS}" context generate
Parse the JSON output. The response contains contextDir (path to .planning/context/) and ready (boolean).
If the command fails (e.g., no .planning/ exists), tell the user: "No RAPID project found. Run /rapid:init first to initialize the project, then run /rapid:context to generate context files." End the skill.
Store the contextDir path for use in Step 5.
Spawn the context-generator subagent using the Agent tool to perform deep codebase analysis. The subagent analyzes source code patterns without writing any files.
Print progress banner before spawning the analysis subagent:
Scanning project...
Use the Agent tool with these instructions:
Spawn the rapid-context-generator agent with this task:
Run in analysis-only mode. Read the sample files listed in the manifest. Analyze the codebase for architecture patterns, code conventions, naming patterns, error handling, test infrastructure, and style rules. Return your analysis as structured text. Do NOT write any files.
## Scan Manifest
{scan manifest JSON from Step 1}
## Working Directory
{project root path from Step 2}
The agent should:
sampleFiles arrayconfigFiles array (read any with parsed: null that seem important -- linting configs, formatting configs, TypeScript configs)Wait for the subagent to complete and capture its response.
Print progress banner after analysis returns:
Analyzing patterns...
Auto-trigger note: If this context generation was auto-triggered from /rapid:init brownfield flow, skip the confirmation prompt below and proceed directly to Step 5. The user already consented to codebase analysis when they chose Brownfield during init.
Present the subagent's analysis summary to the user in a clear, organized format:
## Codebase Analysis Results
**Detected Stack:**
- Languages: {from analysis}
- Frameworks: {from analysis}
- Key Dependencies: {from analysis}
**Context Files to Generate:**
| File | Location | Description |
|------|----------|-------------|
| CLAUDE.md | project root | Lean project context (under 80 lines) |
| CODEBASE.md | .planning/context/ | Brownfield analysis report |
| ARCHITECTURE.md | .planning/context/ | Architecture patterns and structure |
| CONVENTIONS.md | .planning/context/ | Code conventions |
| STYLE_GUIDE.md | .planning/context/ | Style rules (descriptive tone) |
| {additional} | .planning/context/ | {if recommended by analysis} |
**Key Findings Preview:**
{Show 2-3 bullet points per planned file from the analysis}
Then use AskUserQuestion with:
Print progress banner before spawning the write subagent:
Generating files...
Spawn the context-generator subagent again using the Agent tool, this time in write mode.
Spawn the rapid-context-generator agent with this task:
Run in write mode. Using the analysis findings provided, write all context files. Write CLAUDE.md to the project root. Write all other context files to .planning/context/. Follow the file specifications in your role instructions. Ensure CLAUDE.md is under 80 lines. Use descriptive tone in STYLE_GUIDE.md.
## Analysis Findings
{full analysis findings from Step 3}
## User Modifications
{any user modifications from Step 4 -- files to skip, content adjustments}
## Working Directory
{project root path}
## Context Directory
{context directory path from Step 2}
Wait for the subagent to complete.
After the write-mode subagent completes, verify the files were created:
ls -la .planning/context/
Also check CLAUDE.md exists at the project root and count its lines:
wc -l CLAUDE.md
Display a completion summary to the user:
## Context Generation Complete
**Files Generated:**
| File | Location | Lines |
|------|----------|-------|
| CLAUDE.md | ./CLAUDE.md | {N} |
| CODEBASE.md | .planning/context/CODEBASE.md | {N} |
| ARCHITECTURE.md | .planning/context/ARCHITECTURE.md | {N} |
| CONVENTIONS.md | .planning/context/CONVENTIONS.md | {N} |
| STYLE_GUIDE.md | .planning/context/STYLE_GUIDE.md | {N} |
| {additional files...} | ... | ... |
**Agent Context Injection:**
Agents will automatically receive relevant context files based on their role:
- Planners: CONVENTIONS.md, ARCHITECTURE.md
- Executors: STYLE_GUIDE.md, CONVENTIONS.md
- Reviewers: STYLE_GUIDE.md, CONVENTIONS.md, ARCHITECTURE.md
- Orchestrators: ARCHITECTURE.md
- Verifiers: (no context files -- lightweight verification only)
Re-run `/rapid:context` at any time to regenerate from the current codebase state.
/rapid:context again regenerates all context files from scratch. There is no diffing or incremental update -- the current codebase state is always the source of truth..planning/context/ files, not in CLAUDE.md.