Scans the codebase to generate project-doc.md and AGENTS.md
Codebase Scanner

Scans the codebase to generate project-doc.md and AGENTS.md. Use when bootstrapping a new agent-driven repo, refreshing project documentation after architectural changes, or running a delta scan to detect drift.
--- name: scan description: Scans the codebase to generate project-doc.md and AGENTS.md. Use when bootstrapping a new agent-driven repo, refreshing project documentation after architectural changes, or running a delta scan to detect drift. Runs a full scan on first use and a smart delta scan on subsequent runs. Uses understand-anything + context-mode when available, falls back to native tools otherwise. Only updates AGENTS.md on detected architectural changes with human confirmation. --- # Codebase Scanner You are a technical analyst. Your job is to scan the project codebase and produce accurate, project-specific documentation used by all downstream agents. ## Step 1: Check Optional Plugin Dependencies Check whether the two optional enhancement plugins are available: ``` understand-anything → /plugin list | grep understand-anything context-mode → /plugin list | grep context-mode ```
Overview
You are a technical analyst. Your job is to scan the project codebase and produce accurate, project-specific documentation used by all downstream agents.
Manual install (npx, ZIP)
npx skills add wshobson/agents --skill scan -g -a claude-codemkdir -p ~/.claude/skills && curl -sL https://codeload.github.com/wshobson/agents/tar.gz/4236bb91f839 \
| tar -xz -C ~/.claude/skills --strip-components=4 agents-4236bb91f839/plugins/ship-mate/skills/scanNew-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Invoke-WebRequest "https://m.agentalley.io/zip/70fdc7836235c6a5a566/scan.zip" -OutFile "$env:TEMP\scan.zip"; Expand-Archive "$env:TEMP\scan.zip" -DestinationPath "$HOME\.claude\skills" -ForceConnects with Agent Alley MCP · agentalley.io/mcp
Files included
SKILL.md8.7 KB
Read the files here
wshobson/
Shared references1SKILL.md reads these from elsewhere in the repo. Not in the ZIP.
Get them on GitHub ↗Show the full text219 lines
Codebase Scanner
You are a technical analyst. Your job is to scan the project codebase and produce accurate, project-specific documentation used by all downstream agents.
Step 1: Check Optional Plugin Dependencies
Check whether the two optional enhancement plugins are available:
understand-anything → /plugin list | grep understand-anything
context-mode → /plugin list | grep context-mode
These plugins are optional. They improve scan quality but are not required:
- understand-anything (Lum1104/Understand-Anything) — provides deeper semantic code analysis
- context-mode (mksglu/context-mode) — routes large outputs through a sandbox to protect the context window
If both are present, use them in Steps 3–4 as described below. If either or both are missing, proceed with the native fallback approach: use find, grep, cat, and git commands directly, routing large outputs through ctx_execute / ctx_execute_file if context-mode is available, otherwise summarise inline.
Note: To install the optional plugins manually:
/plugin marketplace add Lum1104/Understand-Anything && /plugin install understand-anything /plugin marketplace add mksglu/context-mode && /plugin install context-mode@context-mode
Step 2: Determine Scan Mode
Check if .claude/pipeline/project-doc.md exists.
- Does not exist → FULL SCAN (first run)
- Exists → DELTA SCAN
Step 3A: Full Scan
Use understand-anything to analyse the entire codebase. If context-mode is available (verified in Step 1), route ALL output through its tools (ctx_batch_execute / ctx_execute_file) — never dump raw file contents into the main context window. If context-mode is not available, summarise each file's findings inline and avoid printing raw file contents.
Produce .claude/pipeline/project-doc.md using the following structure (based on the architecture-blueprint-generator pattern):
# Project Documentation
> Generated: [timestamp] | Mode: FULL
## Tech Stack
- Runtime: [e.g. Node.js 20, Python 3.11]
- Language: [e.g. TypeScript, Python]
- Framework: [e.g. Next.js 14 App Router, FastAPI]
- Database: [e.g. PostgreSQL via Prisma]
- Styling: [e.g. Tailwind CSS]
- State Management: [e.g. Zustand, Redux]
## Dependencies
[Key libraries with versions, grouped by: core / dev / testing]
## Architecture Pattern
[e.g. Feature-based, Layered MVC, Clean Architecture]
[Describe how the project is structured and why]
## Folder Structure
[Top-level directory map with purpose of each folder]
## Code Style Conventions
[Naming patterns, file naming, import ordering, export patterns]
[Inferred from actual code — not guessed]
## Modularity Practices
[How concerns are separated, shared module locations, service patterns]
## Data Architecture
[Entity relationships, data access patterns, ORM usage]
## Cross-Cutting Concerns
[Auth/authz approach, error handling patterns, logging, validation]
## Service Communication
[REST / GraphQL / event-driven — document what actually exists]
## Test Coverage
- Overall coverage: [X%]
- Testing framework: [e.g. Jest, Vitest, Pytest]
- Key untested areas: [list]
- Test patterns used: [unit / integration / e2e]
## Entry Points
[Main files, key config files, environment setup]
## Changed Files
[Only present in delta scans — list of files re-scanned]
## Last Scanned
[ISO timestamp]
After writing project-doc.md, proceed to Step 4 to generate AGENTS.md.
Step 3B: Delta Scan
- Run
git diff HEAD~1 --name-onlyto get changed files - If no changed files, report "No changes detected — project-doc.md is current" and exit
- Use
understand-anythingto re-analyse only the changed files; route output throughctx_execute_fileif context-mode is available, otherwise summarise inline - Patch only the affected sections of
.claude/pipeline/project-doc.md - Update the
Last ScannedandChanged Filesfields - Proceed to Step 4B (architectural change detection)
Step 4A: Generate AGENTS.md (First Run Only)
Write AGENTS.md to the repo root. This is NOT a copy of project-doc.md — it is rewritten as agent instructions, tailored to this specific project. Every agent reads this file first.
Structure:
# AGENTS.md — [Project Name]
> Auto-generated by the dev pipeline scanner. Do not edit manually.
> Last updated: [timestamp]
> ⚠️ To update this file, architectural changes must be detected by the scanner and confirmed by a human.
## How to Read This File
Every agent in this pipeline reads this file before doing any work.
It defines the rules, patterns, and guardrails specific to this project.
## Stack Context
[One-line summary: e.g. "Next.js 14 App Router + Prisma + PostgreSQL + Tailwind + Vitest"]
## Code Style Rules
[Written as DO/DON'T instructions inferred from actual codebase patterns]
Example:
- DO use named exports. Default exports are not used in this project.
- DON'T add business logic to API route handlers — delegate to /lib/services/
- DO use [naming convention] for [file type]
## Architecture Guardrails
[Rules derived from the actual architecture — not generic advice]
Example:
- This project uses the Repository pattern. Never query the DB directly from components.
- All API responses must go through the [ResponseWrapper] utility.
## Testing Requirements
[Coverage stat + specific rules for this project]
Example:
- Current coverage: 67%. All new code must include unit tests.
- QA agent: flag any feature with <80% coverage on new code.
- Integration tests use [real DB / mock DB] — do not change this.
## Modularity Conventions
[Specific rules about where code goes]
Example:
- Shared UI components → /components/ui
- Business logic → /lib/services/[domain]/
- Types → /types/[domain].ts
## Security Rules (All Agents)
- Never hardcode secrets, tokens, or credentials
- Use environment variables for all sensitive config
- Flag any auth-adjacent code changes immediately
## Agent-Specific Instructions
### Orchestrator
[Project-specific questions to always ask — e.g. "Does this touch the payment flow?"]
### Architect
[Known complexity areas, performance constraints, patterns to prefer]
[e.g. "This project has a known N+1 issue in /lib/services/orders — avoid adding more eager loading"]
### Developer
[Specific libraries to use, anti-patterns banned in this codebase]
[e.g. "Use dayjs — moment is banned", "Use React Query for all data fetching — no raw fetch()"]
### PR Reviewer
[What counts as 🔴 Critical vs 🟡 Should Fix in this project]
[e.g. "Any change to /lib/auth/ is automatically 🔴 Critical — requires human approval"]
### QA Agent
[Known edge cases for this domain, critical user paths to always test]
[e.g. "Always test empty state, loading state, and error state for every UI feature"]
If the project is MERN stack (MongoDB + Express + React + Node.js — detected from package.json / requirements), append a ### MERN Stack Notes section to AGENTS.md covering: use Mongoose middleware over raw queries, handle async errors in Express with a central error handler, avoid storing JWT tokens in localStorage (use httpOnly cookies), and never expose Mongoose error objects directly in API responses.
Step 4B: Architectural Change Detection (Delta Runs Only)
After patching project-doc.md, compare the new version against the previous. Check for:
- New framework or major library added
- New architectural directory pattern created (e.g. new
/lib/hooks/,/services/) - Major dependency swap (e.g. axios → fetch, moment → dayjs)
- New auth or session handling pattern
If any detected, show:
⚠️ Architectural change detected in delta scan:
[List specific changes found]
AGENTS.md may need updating. Review and confirm:
[y] Update AGENTS.md — patch affected sections only
[n] Skip — this is not an architectural change
Only on [y] confirmation: patch the relevant sections of AGENTS.md. Never rewrite the full file.
Step 5: Report
Print a summary:
✅ Scan complete ([FULL/DELTA])
project-doc.md → updated
AGENTS.md → [generated / patched / unchanged]
Changed files → [N files re-scanned / N/A for full scan]
Coverage → [X%]
Update state.json field checkpoints.scan = "completed".
| 1 | |
| 2 | name scan |
| 3 | description Scans the codebase to generate project-doc.md and AGENTS.md. Use when bootstrapping a new agent-driven repo, refreshing project documentation after architectural changes, or running a delta scan to detect drift. Runs a full scan on first use and a smart delta scan on subsequent runs. Uses understand-anything + context-mode when available, falls back to native tools otherwise. Only updates AGENTS.md on detected architectural changes with human confirmation. |
| 4 | |
| 5 | |
| 6 | # Codebase Scanner |
| 7 | |
| 8 | You are a technical analyst. Your job is to scan the project codebase and produce accurate, project-specific documentation used by all downstream agents. |
| 9 | |
| 10 | ## Step 1: Check Optional Plugin Dependencies |
| 11 | |
| 12 | Check whether the two optional enhancement plugins are available: |
| 13 | |
| 14 | |
| 15 | understand-anything → /plugin list | grep understand-anything |
| 16 | context-mode → /plugin list | grep context-mode |
| 17 | |
| 18 | |
| 19 | These plugins are **optional**. They improve scan quality but are not required: |
| 20 | |
| 21 | **understand-anything** (Lum1104/Understand-Anything) — provides deeper semantic code analysis |
| 22 | **context-mode** (mksglu/context-mode) — routes large outputs through a sandbox to protect the context window |
| 23 | |
| 24 | If both are present, use them in Steps 3–4 as described below. If either or both are missing, proceed with the **native fallback** approach: use `find`, `grep`, `cat`, and `git` commands directly, routing large outputs through `ctx_execute` / `ctx_execute_file` if context-mode is available, otherwise summarise inline. |
| 25 | |
| 26 | > **Note:** To install the optional plugins manually: |
| 27 | > ``` |
| 28 | > /plugin marketplace add Lum1104/Understand-Anything && /plugin install understand-anything |
| 29 | > /plugin marketplace add mksglu/context-mode && /plugin install context-mode@context-mode |
| 30 | > ``` |
| 31 | |
| 32 | ## Step 2: Determine Scan Mode |
| 33 | |
| 34 | Check if `.claude/pipeline/project-doc.md` exists. |
| 35 | |
| 36 | **Does not exist** → FULL SCAN (first run) |
| 37 | **Exists** → DELTA SCAN |
| 38 | |
| 39 | ## Step 3A: Full Scan |
| 40 | |
| 41 | Use `understand-anything` to analyse the entire codebase. If **context-mode** is available (verified in Step 1), route ALL output through its tools (`ctx_batch_execute` / `ctx_execute_file`) — never dump raw file contents into the main context window. If context-mode is not available, summarise each file's findings inline and avoid printing raw file contents. |
| 42 | |
| 43 | Produce `.claude/pipeline/project-doc.md` using the following structure (based on the architecture-blueprint-generator pattern): |
| 44 | |
| 45 | |
| 46 | # Project Documentation |
| 47 | > Generated: [timestamp] | Mode: FULL |
| 48 | |
| 49 | ## Tech Stack |
| 50 | - Runtime: [e.g. Node.js 20, Python 3.11] |
| 51 | - Language: [e.g. TypeScript, Python] |
| 52 | - Framework: [e.g. Next.js 14 App Router, FastAPI] |
| 53 | - Database: [e.g. PostgreSQL via Prisma] |
| 54 | - Styling: [e.g. Tailwind CSS] |
| 55 | - State Management: [e.g. Zustand, Redux] |
| 56 | |
| 57 | ## Dependencies |
| 58 | [Key libraries with versions, grouped by: core / dev / testing] |
| 59 | |
| 60 | ## Architecture Pattern |
| 61 | [e.g. Feature-based, Layered MVC, Clean Architecture] |
| 62 | [Describe how the project is structured and why] |
| 63 | |
| 64 | ## Folder Structure |
| 65 | [Top-level directory map with purpose of each folder] |
| 66 | |
| 67 | ## Code Style Conventions |
| 68 | [Naming patterns, file naming, import ordering, export patterns] |
| 69 | [Inferred from actual code — not guessed] |
| 70 | |
| 71 | ## Modularity Practices |
| 72 | [How concerns are separated, shared module locations, service patterns] |
| 73 | |
| 74 | ## Data Architecture |
| 75 | [Entity relationships, data access patterns, ORM usage] |
| 76 | |
| 77 | ## Cross-Cutting Concerns |
| 78 | [Auth/authz approach, error handling patterns, logging, validation] |
| 79 | |
| 80 | ## Service Communication |
| 81 | [REST / GraphQL / event-driven — document what actually exists] |
| 82 | |
| 83 | ## Test Coverage |
| 84 | - Overall coverage: [X%] |
| 85 | - Testing framework: [e.g. Jest, Vitest, Pytest] |
| 86 | - Key untested areas: [list] |
| 87 | - Test patterns used: [unit / integration / e2e] |
| 88 | |
| 89 | ## Entry Points |
| 90 | [Main files, key config files, environment setup] |
| 91 | |
| 92 | ## Changed Files |
| 93 | [Only present in delta scans — list of files re-scanned] |
| 94 | |
| 95 | ## Last Scanned |
| 96 | [ISO timestamp] |
| 97 | |
| 98 | |
| 99 | After writing `project-doc.md`, proceed to **Step 4** to generate `AGENTS.md`. |
| 100 | |
| 101 | ## Step 3B: Delta Scan |
| 102 | |
| 103 | Run `git diff HEAD~1 --name-only` to get changed files |
| 104 | If no changed files, report "No changes detected — project-doc.md is current" and exit |
| 105 | Use `understand-anything` to re-analyse only the changed files; route output through `ctx_execute_file` if context-mode is available, otherwise summarise inline |
| 106 | Patch only the affected sections of `.claude/pipeline/project-doc.md` |
| 107 | Update the `Last Scanned` and `Changed Files` fields |
| 108 | Proceed to **Step 4B** (architectural change detection) |
| 109 | |
| 110 | ## Step 4A: Generate AGENTS.md (First Run Only) |
| 111 | |
| 112 | Write `AGENTS.md` to the repo root. This is NOT a copy of `project-doc.md` — it is rewritten as agent instructions, tailored to this specific project. Every agent reads this file first. |
| 113 | |
| 114 | Structure: |
| 115 | |
| 116 | |
| 117 | # AGENTS.md — [Project Name] |
| 118 | > Auto-generated by the dev pipeline scanner. Do not edit manually. |
| 119 | > Last updated: [timestamp] |
| 120 | > ⚠️ To update this file, architectural changes must be detected by the scanner and confirmed by a human. |
| 121 | |
| 122 | ## How to Read This File |
| 123 | Every agent in this pipeline reads this file before doing any work. |
| 124 | It defines the rules, patterns, and guardrails specific to this project. |
| 125 | |
| 126 | ## Stack Context |
| 127 | [One-line summary: e.g. "Next.js 14 App Router + Prisma + PostgreSQL + Tailwind + Vitest"] |
| 128 | |
| 129 | ## Code Style Rules |
| 130 | [Written as DO/DON'T instructions inferred from actual codebase patterns] |
| 131 | Example: |
| 132 | - DO use named exports. Default exports are not used in this project. |
| 133 | - DON'T add business logic to API route handlers — delegate to /lib/services/ |
| 134 | - DO use [naming convention] for [file type] |
| 135 | |
| 136 | ## Architecture Guardrails |
| 137 | [Rules derived from the actual architecture — not generic advice] |
| 138 | Example: |
| 139 | - This project uses the Repository pattern. Never query the DB directly from components. |
| 140 | - All API responses must go through the [ResponseWrapper] utility. |
| 141 | |
| 142 | ## Testing Requirements |
| 143 | [Coverage stat + specific rules for this project] |
| 144 | Example: |
| 145 | - Current coverage: 67%. All new code must include unit tests. |
| 146 | - QA agent: flag any feature with <80% coverage on new code. |
| 147 | - Integration tests use [real DB / mock DB] — do not change this. |
| 148 | |
| 149 | ## Modularity Conventions |
| 150 | [Specific rules about where code goes] |
| 151 | Example: |
| 152 | - Shared UI components → /components/ui |
| 153 | - Business logic → /lib/services/[domain]/ |
| 154 | - Types → /types/[domain].ts |
| 155 | |
| 156 | ## Security Rules (All Agents) |
| 157 | - Never hardcode secrets, tokens, or credentials |
| 158 | - Use environment variables for all sensitive config |
| 159 | - Flag any auth-adjacent code changes immediately |
| 160 | |
| 161 | ## Agent-Specific Instructions |
| 162 | |
| 163 | ### Orchestrator |
| 164 | [Project-specific questions to always ask — e.g. "Does this touch the payment flow?"] |
| 165 | |
| 166 | ### Architect |
| 167 | [Known complexity areas, performance constraints, patterns to prefer] |
| 168 | [e.g. "This project has a known N+1 issue in /lib/services/orders — avoid adding more eager loading"] |
| 169 | |
| 170 | ### Developer |
| 171 | [Specific libraries to use, anti-patterns banned in this codebase] |
| 172 | [e.g. "Use dayjs — moment is banned", "Use React Query for all data fetching — no raw fetch()"] |
| 173 | |
| 174 | ### PR Reviewer |
| 175 | [What counts as 🔴 Critical vs 🟡 Should Fix in this project] |
| 176 | [e.g. "Any change to /lib/auth/ is automatically 🔴 Critical — requires human approval"] |
| 177 | |
| 178 | ### QA Agent |
| 179 | [Known edge cases for this domain, critical user paths to always test] |
| 180 | [e.g. "Always test empty state, loading state, and error state for every UI feature"] |
| 181 | |
| 182 | |
| 183 | If the project is MERN stack (MongoDB + Express + React + Node.js — detected from package.json / requirements), append a `### MERN Stack Notes` section to AGENTS.md covering: use Mongoose middleware over raw queries, handle async errors in Express with a central error handler, avoid storing JWT tokens in localStorage (use httpOnly cookies), and never expose Mongoose error objects directly in API responses. |
| 184 | |
| 185 | ## Step 4B: Architectural Change Detection (Delta Runs Only) |
| 186 | |
| 187 | After patching `project-doc.md`, compare the new version against the previous. Check for: |
| 188 | New framework or major library added |
| 189 | New architectural directory pattern created (e.g. new `/lib/hooks/`, `/services/`) |
| 190 | Major dependency swap (e.g. axios → fetch, moment → dayjs) |
| 191 | New auth or session handling pattern |
| 192 | |
| 193 | If any detected, show: |
| 194 | |
| 195 | |
| 196 | ⚠️ Architectural change detected in delta scan: |
| 197 | [List specific changes found] |
| 198 | |
| 199 | AGENTS.md may need updating. Review and confirm: |
| 200 | [y] Update AGENTS.md — patch affected sections only |
| 201 | [n] Skip — this is not an architectural change |
| 202 | |
| 203 | |
| 204 | Only on `[y]` confirmation: patch the relevant sections of `AGENTS.md`. Never rewrite the full file. |
| 205 | |
| 206 | ## Step 5: Report |
| 207 | |
| 208 | Print a summary: |
| 209 | |
| 210 | |
| 211 | ✅ Scan complete ([FULL/DELTA]) |
| 212 | project-doc.md → updated |
| 213 | AGENTS.md → [generated / patched / unchanged] |
| 214 | Changed files → [N files re-scanned / N/A for full scan] |
| 215 | Coverage → [X%] |
| 216 | |
| 217 | |
| 218 | Update `state.json` field `checkpoints.scan = "completed"`. |
| 219 |
Details
- Updated
- Sep 21, 2026
- License
- MIT
- Stars on the repo
- ★ 39,857
- Checked
- Source
- wshobson/agents ↗
- Creator
- wshobson · 179 listings
Similar skills
See all →
SkillGenerate CHANGELOG.md entry from recent commitsSkillshare changelog
SkillUpdate website docs to match recent code changesSkillshare update docs
SkillRecords one architecture decision with alternativesArchitecture Decision Recorder
PromptAct as a GitHub Repository Analyst to perform in-depthGithub repository analysis and enhancement
PromptAct as a GitHub Repository Analyst
PromptA prompt designed to analyze a codebaseMulti-Audience Application Discovery & Documentation PromptMore from wshobson
SkillMaster C/.NET backend development patterns for building
SkillImplement WCAG 2.2 compliant interfaces with mobileAccessibility compliance
SkillMaster Material Design 3 and Jetpack Compose patternsAndroid Mobile Design
SkillMigrate from AngularJS to Angular using hybrid modeAngular migration
SkillUnderstand anti-reversing, obfuscationAnti reversing techniques
SkillBuild production Apache Airflow DAGs with best practicesApache Airflow DAG Patterns