Analyze Project Context
Overview
Build comprehensive, evidence-based understanding of ANY project type (code, documentation, content, mixed) before making changes. Works for technical projects, content projects, documentation repositories, and everything in between.
Core principle: Discover what exists, infer patterns, document best practices, establish constitution.
When to Use
Use when:
- Starting work on a new project
- User asks to "analyze the project" or "understand the codebase"
- Before making significant changes
- Need to understand project structure and conventions
- Setting up AI agent workflow for a project
Works for:
- Software projects (Node.js, Python, Go, etc.)
- Documentation repositories
- Content projects (marketing, writing, guides)
- Mixed projects (docs + code)
- Design projects (templates, assets)
- Any organized file structure
Core Principles
- Evidence Over Assumption: Discover what exists, don't assume structure
- Pattern Recognition: Infer conventions from existing files
- Universal Applicability: Works for any project type
- Document Findings: Create AGENTS.md and constitution.md
- Depth Control: Use discovery budget (max 2-3 tool calls per category) to avoid analysis paralysis
Workflow
1. Project Type Detection
Action: Identify project type from file structure
Discovery:
- Check for README.md, README, or similar (project overview)
- Look for technical indicators:
package.json, requirements.txt, Cargo.toml, go.mod, pom.xml, etc.
- Look for content indicators:
docs/, content/, posts/, guides/, templates/
- Check for existing AI/agent files:
.github/, .specify/
Classify as:
- Technical: Has package managers, source code, build configs
- Content: Primarily markdown, templates, media files
- Documentation: Organized docs structure, no executable code
- Mixed: Contains both code and significant content/docs
2. Structural Discovery
Action: Map the project organization
Universal Checks:
- README.md or equivalent (purpose, structure, getting started)
- Directory structure (identify main folders and their purposes)
- File naming patterns (kebab-case, camelCase, snake_case)
- Organization principles (by feature, by type, by topic)
Technical Projects (if detected):
- Package manager files (
package.json, requirements.txt, etc.)
- Source directories (
src/, lib/, app/)
- Test directories (
test/, __tests__/, spec/)
- Build configs and tooling
Content Projects (if detected):
- Content organization (
docs/, content/, posts/, guides/)
- Templates and reusable components
- Media assets (
images/, assets/, static/)
- Style guides or brand guidelines
3. Pattern & Convention Discovery
Action: Infer project conventions from existing files
Sample 3-5 representative files to extract:
- Naming conventions (files, directories, identifiers)
- Structural patterns (how are similar things organized?)
- Documentation patterns (inline comments, separate docs, both?)
- Metadata usage (frontmatter, headers, tags)
For Technical Projects:
- Code style (linters, formatters, config files)
- Testing patterns (framework, file locations, naming)
- Import/module patterns
- Error handling conventions
For Content Projects:
- Content structure (headings, sections, metadata)
- Cross-referencing patterns (links, includes, references)
- Asset organization and naming
- Version control patterns (drafts, published, archived)
4. Standards Documentation Discovery
Action: Find existing standards, guidelines, or best practices
Check for:
- CONTRIBUTING.md (contribution guidelines)
- STYLE.md or style guides
- ARCHITECTURE.md or technical docs
- AGENTS.md (AI agent best practices) - if exists
- constitution.md (project principles) - if exists
- Templates or examples directory
Extract existing standards from these files (don't reinvent what exists)
5. Technology Analysis (If Technical Project)
Action: Identify actual technology stack
Sources:
- Package manager files (dependencies, dev dependencies)
- Config files (tsconfig, babel, webpack, etc.)
- Import/require statements in source files
- Build scripts and deployment configs
Optional Validation:
- For major frameworks, verify version-specific patterns
- Check if code matches current best practices for that version
- Identify deprecated patterns or outdated dependencies
Skip this section for non-technical projects
6. Create AGENTS.md (Best Practices for AI Agents)
Action: Generate or update .github/AGENTS.md with project-specific best practices
Structure:
# AI Agent Best Practices: [Project Name]
**Generated:** [Date]
**Project Type:** [Technical/Content/Documentation/Mixed]
## Project Overview
[From README - purpose, goals, audience]
## Working with This Project
### File Organization
- [Pattern 1]: [Explanation and examples]
- [Pattern 2]: [Explanation and examples]
### Naming Conventions
- Files: [Convention with examples]
- [Other identifiers]: [Convention with examples]
### Common Tasks
1. [Task]: [How to do it correctly]
2. [Task]: [How to do it correctly]
### Quality Standards
- [Standard 1]: [What to check]
- [Standard 2]: [What to check]
### What NOT to Do
- ❌ [Anti-pattern]: [Why to avoid]
- ❌ [Anti-pattern]: [Why to avoid]
### Technology-Specific Notes
[Only if technical project - framework versions, patterns, gotchas]
## Related Files
- Constitution: `.specify/memory/constitution.md` (if exists)
- [Other relevant docs]
Base content on discovered patterns - this is project-specific, not generic advice
7. Create/Update Constitution (Project Principles)
Action: Trigger speckit-constitution skill to create or update .specify/memory/constitution.md
If constitution doesn't exist:
- Invoke
speckit-constitution skill
- Suggest principles based on discovered patterns
- Let user refine interactively
If constitution exists:
- Report path and note it was found
- Validate current project follows constitution
- Report any violations or gaps
Constitution should capture:
- Non-negotiable project principles (MUST)
- Strong recommendations (SHOULD)
- Forbidden patterns or approaches
- Quality gates and standards
- Technology constraints (if technical project)
8. Synthesis & Report
Action: Generate structured analysis report
Format:
# Project Analysis: [Project Name]
## Executive Summary
- **Project Type:** [Type]
- **Primary Purpose:** [From README]
- **Key Characteristics:** [3-5 bullet points]
## Structure
[Directory tree or organization description]
## Conventions & Patterns
[Key patterns discovered]
## Standards & Guidelines
- Existing: [List of found docs]
- Created: AGENTS.md with project best practices
- Constitution: [Created/Updated/Found at path]
## Recommendations
1. [Action]: [Reason]
2. [Action]: [Reason]
## Next Steps
[Suggested actions - use existing skills, workflows, or custom tasks]
Present options to user:
- Review AGENTS.md and constitution.md
- Start implementing features (use speckit workflow)
- Run specific analysis (code quality, documentation coverage, etc.)
Anti-Patterns (What NOT to Do)
Universal Anti-Patterns
- NEVER assume project structure without verification
- NEVER create AGENTS.md with generic, non-specific advice
- NEVER skip constitution creation/update
- NEVER hallucinate file paths that don't exist
- NEVER overwrite existing standards without reviewing them first
Technical Project Anti-Patterns
- NEVER assume framework patterns without checking versions (e.g., Next.js App Router vs Pages)
- NEVER skip validation of major dependencies
- NEVER guess package manager (could be npm, yarn, pnpm, bun)
Content Project Anti-Patterns
- NEVER ignore existing content organization patterns
- NEVER assume markdown is the only format (could be MDX, AsciiDoc, reStructuredText)
- NEVER overlook asset organization and naming conventions
Common Mistakes
| Mistake |
Reality |
| "All projects have package.json" |
Content projects, docs repos don't have code dependencies |
| "I'll skip AGENTS.md for simple projects" |
Even simple projects benefit from documented patterns |
| "Constitution is only for code projects" |
ALL projects need principles (quality, style, structure) |
| "Generic best practices are enough" |
Project-specific patterns are what make AGENTS.md valuable |
| "I can infer everything from README" |
READMEs often incomplete - inspect actual files |
Quick Reference
| Project Type |
Key Discovery |
Constitution Focus |
| Technical |
Package manager, tech stack, code patterns |
Code quality, tech constraints, testing |
| Content |
Content structure, frontmatter, assets |
Style, tone, structure, publishing |
| Documentation |
Doc organization, cross-references |
Accuracy, consistency, completeness |
| Mixed |
Both code and content patterns |
Both technical and content standards |
Success Indicators
Analysis is complete when:
- ✅ Project type correctly identified
- ✅ Key directories and organization patterns discovered
- ✅ File naming and structure conventions documented
- ✅ AGENTS.md created with project-specific best practices
- ✅ Constitution created or verified
- ✅ Report generated with actionable next steps
- ✅ No assumptions made without evidence
Output
Created Files:
.github/
└── AGENTS.md # Project-specific AI agent best practices
.specify/memory/
└── constitution.md # Project principles (created or updated)
Analysis Report:
- Project classification
- Structure and conventions
- Standards documentation
- Recommendations and next steps
Related Skills
- speckit-constitution - Create/update project constitution (invoked automatically)
- speckit - Full spec-driven development workflow (suggested next step for features)
- brainstorming - Explore requirements before making changes
1---2name: analyze-project-context3description: Use when starting work on any project (technical or non-technical) to understand structure, standards, and best practices before making changes4---5
6# Analyze Project Context
7
8## Overview
9
10Build comprehensive, evidence-based understanding of ANY project type (code, documentation, content, mixed) before making changes. Works for technical projects, content projects, documentation repositories, and everything in between.
11
12**Core principle:** Discover what exists, infer patterns, document best practices, establish constitution.
13
14## When to Use
15
16Use when:
17- Starting work on a new project
18- User asks to "analyze the project" or "understand the codebase"
19- Before making significant changes
20- Need to understand project structure and conventions
21- Setting up AI agent workflow for a project
22
23Works for:
24- Software projects (Node.js, Python, Go, etc.)
25- Documentation repositories
26- Content projects (marketing, writing, guides)
27- Mixed projects (docs + code)
28- Design projects (templates, assets)
29- Any organized file structure
30
31## Core Principles
32
33- **Evidence Over Assumption:** Discover what exists, don't assume structure
34- **Pattern Recognition:** Infer conventions from existing files
35- **Universal Applicability:** Works for any project type
36- **Document Findings:** Create AGENTS.md and constitution.md
37- **Depth Control:** Use discovery budget (max 2-3 tool calls per category) to avoid analysis paralysis
38
39## Workflow
40
41### 1. Project Type Detection
42
43**Action:** Identify project type from file structure
44
45**Discovery:**
46- Check for README.md, README, or similar (project overview)
47- Look for technical indicators: `package.json`, `requirements.txt`, `Cargo.toml`, `go.mod`, `pom.xml`, etc.
48- Look for content indicators: `docs/`, `content/`, `posts/`, `guides/`, `templates/`
49- Check for existing AI/agent files: `.github/`, `.specify/`
50
51**Classify as:**
52- **Technical:** Has package managers, source code, build configs
53- **Content:** Primarily markdown, templates, media files
54- **Documentation:** Organized docs structure, no executable code
55- **Mixed:** Contains both code and significant content/docs
56
57### 2. Structural Discovery
58
59**Action:** Map the project organization
60
61**Universal Checks:**
62- README.md or equivalent (purpose, structure, getting started)
63- Directory structure (identify main folders and their purposes)
64- File naming patterns (kebab-case, camelCase, snake_case)
65- Organization principles (by feature, by type, by topic)
66
67**Technical Projects (if detected):**
68- Package manager files (`package.json`, `requirements.txt`, etc.)
69- Source directories (`src/`, `lib/`, `app/`)
70- Test directories (`test/`, `__tests__/`, `spec/`)
71- Build configs and tooling
72
73**Content Projects (if detected):**
74- Content organization (`docs/`, `content/`, `posts/`, `guides/`)
75- Templates and reusable components
76- Media assets (`images/`, `assets/`, `static/`)
77- Style guides or brand guidelines
78
79### 3. Pattern & Convention Discovery
80
81**Action:** Infer project conventions from existing files
82
83**Sample 3-5 representative files** to extract:
84- Naming conventions (files, directories, identifiers)
85- Structural patterns (how are similar things organized?)
86- Documentation patterns (inline comments, separate docs, both?)
87- Metadata usage (frontmatter, headers, tags)
88
89**For Technical Projects:**
90- Code style (linters, formatters, config files)
91- Testing patterns (framework, file locations, naming)
92- Import/module patterns
93- Error handling conventions
94
95**For Content Projects:**
96- Content structure (headings, sections, metadata)
97- Cross-referencing patterns (links, includes, references)
98- Asset organization and naming
99- Version control patterns (drafts, published, archived)
100
101### 4. Standards Documentation Discovery
102
103**Action:** Find existing standards, guidelines, or best practices
104
105**Check for:**
106- CONTRIBUTING.md (contribution guidelines)
107- STYLE.md or style guides
108- ARCHITECTURE.md or technical docs
109- AGENTS.md (AI agent best practices) - if exists
110- constitution.md (project principles) - if exists
111- Templates or examples directory
112
113**Extract existing standards** from these files (don't reinvent what exists)
114
115### 5. Technology Analysis (If Technical Project)
116
117**Action:** Identify actual technology stack
118
119**Sources:**
120- Package manager files (dependencies, dev dependencies)
121- Config files (tsconfig, babel, webpack, etc.)
122- Import/require statements in source files
123- Build scripts and deployment configs
124
125**Optional Validation:**
126- For major frameworks, verify version-specific patterns
127- Check if code matches current best practices for that version
128- Identify deprecated patterns or outdated dependencies
129
130**Skip this section** for non-technical projects
131
132### 6. Create AGENTS.md (Best Practices for AI Agents)
133
134**Action:** Generate or update `.github/AGENTS.md` with project-specific best practices
135
136**Structure:**
137```markdown
138# AI Agent Best Practices: [Project Name]
139
140**Generated:** [Date]
141**Project Type:** [Technical/Content/Documentation/Mixed]
142
143## Project Overview
144[From README - purpose, goals, audience]
145
146## Working with This Project
147
148### File Organization
149- [Pattern 1]: [Explanation and examples]
150- [Pattern 2]: [Explanation and examples]
151
152### Naming Conventions
153- Files: [Convention with examples]
154- [Other identifiers]: [Convention with examples]
155
156### Common Tasks
1571. [Task]: [How to do it correctly]
1582. [Task]: [How to do it correctly]
159
160### Quality Standards
161- [Standard 1]: [What to check]
162- [Standard 2]: [What to check]
163
164### What NOT to Do
165- ❌ [Anti-pattern]: [Why to avoid]
166- ❌ [Anti-pattern]: [Why to avoid]
167
168### Technology-Specific Notes
169[Only if technical project - framework versions, patterns, gotchas]
170
171## Related Files
172- Constitution: `.specify/memory/constitution.md` (if exists)
173- [Other relevant docs]
174```
175
176**Base content on discovered patterns** - this is project-specific, not generic advice
177
178### 7. Create/Update Constitution (Project Principles)
179
180**Action:** Trigger `speckit-constitution` skill to create or update `.specify/memory/constitution.md`
181
182**If constitution doesn't exist:**
183- Invoke `speckit-constitution` skill
184- Suggest principles based on discovered patterns
185- Let user refine interactively
186
187**If constitution exists:**
188- Report path and note it was found
189- Validate current project follows constitution
190- Report any violations or gaps
191
192**Constitution should capture:**
193- Non-negotiable project principles (MUST)
194- Strong recommendations (SHOULD)
195- Forbidden patterns or approaches
196- Quality gates and standards
197- Technology constraints (if technical project)
198
199### 8. Synthesis & Report
200
201**Action:** Generate structured analysis report
202
203**Format:**
204```markdown
205# Project Analysis: [Project Name]
206
207## Executive Summary
208- **Project Type:** [Type]
209- **Primary Purpose:** [From README]
210- **Key Characteristics:** [3-5 bullet points]
211
212## Structure
213[Directory tree or organization description]
214
215## Conventions & Patterns
216[Key patterns discovered]
217
218## Standards & Guidelines
219- Existing: [List of found docs]
220- Created: AGENTS.md with project best practices
221- Constitution: [Created/Updated/Found at path]
222
223## Recommendations
2241. [Action]: [Reason]
2252. [Action]: [Reason]
226
227## Next Steps
228[Suggested actions - use existing skills, workflows, or custom tasks]
229```
230
231**Present options to user:**
2321. Review AGENTS.md and constitution.md
2332. Start implementing features (use speckit workflow)
2343. Run specific analysis (code quality, documentation coverage, etc.)
235
236## Anti-Patterns (What NOT to Do)
237
238### Universal Anti-Patterns
239- **NEVER** assume project structure without verification
240- **NEVER** create AGENTS.md with generic, non-specific advice
241- **NEVER** skip constitution creation/update
242- **NEVER** hallucinate file paths that don't exist
243- **NEVER** overwrite existing standards without reviewing them first
244
245### Technical Project Anti-Patterns
246- **NEVER** assume framework patterns without checking versions (e.g., Next.js App Router vs Pages)
247- **NEVER** skip validation of major dependencies
248- **NEVER** guess package manager (could be npm, yarn, pnpm, bun)
249
250### Content Project Anti-Patterns
251- **NEVER** ignore existing content organization patterns
252- **NEVER** assume markdown is the only format (could be MDX, AsciiDoc, reStructuredText)
253- **NEVER** overlook asset organization and naming conventions
254
255## Common Mistakes
256
257| Mistake | Reality |
258|---------|---------|
259| "All projects have package.json" | Content projects, docs repos don't have code dependencies |
260| "I'll skip AGENTS.md for simple projects" | Even simple projects benefit from documented patterns |
261| "Constitution is only for code projects" | ALL projects need principles (quality, style, structure) |
262| "Generic best practices are enough" | Project-specific patterns are what make AGENTS.md valuable |
263| "I can infer everything from README" | READMEs often incomplete - inspect actual files |
264
265## Quick Reference
266
267| Project Type | Key Discovery | Constitution Focus |
268|--------------|---------------|-------------------|
269| **Technical** | Package manager, tech stack, code patterns | Code quality, tech constraints, testing |
270| **Content** | Content structure, frontmatter, assets | Style, tone, structure, publishing |
271| **Documentation** | Doc organization, cross-references | Accuracy, consistency, completeness |
272| **Mixed** | Both code and content patterns | Both technical and content standards |
273
274## Success Indicators
275
276Analysis is complete when:
277- ✅ Project type correctly identified
278- ✅ Key directories and organization patterns discovered
279- ✅ File naming and structure conventions documented
280- ✅ AGENTS.md created with project-specific best practices
281- ✅ Constitution created or verified
282- ✅ Report generated with actionable next steps
283- ✅ No assumptions made without evidence
284
285## Output
286
287**Created Files:**
288```
289.github/
290└── AGENTS.md # Project-specific AI agent best practices
291
292.specify/memory/
293└── constitution.md # Project principles (created or updated)
294```
295
296**Analysis Report:**
297- Project classification
298- Structure and conventions
299- Standards documentation
300- Recommendations and next steps
301
302## Related Skills
303
304- **speckit-constitution** - Create/update project constitution (invoked automatically)
305- **speckit** - Full spec-driven development workflow (suggested next step for features)
306- **brainstorming** - Explore requirements before making changes