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:
.gemini/, .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 .gemini/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:
.gemini/
└── 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-context-23description: Use when starting work on any project (technical or non-technical) to understand structure, standards, and best practices before making changes4---56# Analyze Project Context78## Overview910Build 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.1112**Core principle:** Discover what exists, infer patterns, document best practices, establish constitution.1314## When to Use1516Use when:17- Starting work on a new project18- User asks to "analyze the project" or "understand the codebase"19- Before making significant changes20- Need to understand project structure and conventions21- Setting up AI agent workflow for a project2223Works for:24- Software projects (Node.js, Python, Go, etc.)25- Documentation repositories26- Content projects (marketing, writing, guides)27- Mixed projects (docs + code)28- Design projects (templates, assets)29- Any organized file structure3031## Core Principles3233- **Evidence Over Assumption:** Discover what exists, don't assume structure34- **Pattern Recognition:** Infer conventions from existing files35- **Universal Applicability:** Works for any project type36- **Document Findings:** Create AGENTS.md and constitution.md37- **Depth Control:** Use discovery budget (max 2-3 tool calls per category) to avoid analysis paralysis3839## Workflow4041### 1. Project Type Detection4243**Action:** Identify project type from file structure4445**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: `.gemini/`, `.specify/`5051**Classify as:**52- **Technical:** Has package managers, source code, build configs53- **Content:** Primarily markdown, templates, media files54- **Documentation:** Organized docs structure, no executable code55- **Mixed:** Contains both code and significant content/docs5657### 2. Structural Discovery5859**Action:** Map the project organization6061**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)6667**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 tooling7273**Content Projects (if detected):**74- Content organization (`docs/`, `content/`, `posts/`, `guides/`)75- Templates and reusable components76- Media assets (`images/`, `assets/`, `static/`)77- Style guides or brand guidelines7879### 3. Pattern & Convention Discovery8081**Action:** Infer project conventions from existing files8283**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)8889**For Technical Projects:**90- Code style (linters, formatters, config files)91- Testing patterns (framework, file locations, naming)92- Import/module patterns93- Error handling conventions9495**For Content Projects:**96- Content structure (headings, sections, metadata)97- Cross-referencing patterns (links, includes, references)98- Asset organization and naming99- Version control patterns (drafts, published, archived)100101### 4. Standards Documentation Discovery102103**Action:** Find existing standards, guidelines, or best practices104105**Check for:**106- CONTRIBUTING.md (contribution guidelines)107- STYLE.md or style guides108- ARCHITECTURE.md or technical docs109- AGENTS.md (AI agent best practices) - if exists110- constitution.md (project principles) - if exists111- Templates or examples directory112113**Extract existing standards** from these files (don't reinvent what exists)114115### 5. Technology Analysis (If Technical Project)116117**Action:** Identify actual technology stack118119**Sources:**120- Package manager files (dependencies, dev dependencies)121- Config files (tsconfig, babel, webpack, etc.)122- Import/require statements in source files123- Build scripts and deployment configs124125**Optional Validation:**126- For major frameworks, verify version-specific patterns127- Check if code matches current best practices for that version128- Identify deprecated patterns or outdated dependencies129130**Skip this section** for non-technical projects131132### 6. Create AGENTS.md (Best Practices for AI Agents)133134**Action:** Generate or update `.gemini/AGENTS.md` with project-specific best practices135136**Structure:**137```markdown138# AI Agent Best Practices: [Project Name]139140**Generated:** [Date]141**Project Type:** [Technical/Content/Documentation/Mixed]142143## Project Overview144[From README - purpose, goals, audience]145146## Working with This Project147148### File Organization149- [Pattern 1]: [Explanation and examples]150- [Pattern 2]: [Explanation and examples]151152### Naming Conventions153- Files: [Convention with examples]154- [Other identifiers]: [Convention with examples]155156### Common Tasks1571. [Task]: [How to do it correctly]1582. [Task]: [How to do it correctly]159160### Quality Standards161- [Standard 1]: [What to check]162- [Standard 2]: [What to check]163164### What NOT to Do165- ❌ [Anti-pattern]: [Why to avoid]166- ❌ [Anti-pattern]: [Why to avoid]167168### Technology-Specific Notes169[Only if technical project - framework versions, patterns, gotchas]170171## Related Files172- Constitution: `.specify/memory/constitution.md` (if exists)173- [Other relevant docs]174```175176**Base content on discovered patterns** - this is project-specific, not generic advice177178### 7. Create/Update Constitution (Project Principles)179180**Action:** Trigger `speckit-constitution` skill to create or update `.specify/memory/constitution.md`181182**If constitution doesn't exist:**183- Invoke `speckit-constitution` skill184- Suggest principles based on discovered patterns185- Let user refine interactively186187**If constitution exists:**188- Report path and note it was found189- Validate current project follows constitution190- Report any violations or gaps191192**Constitution should capture:**193- Non-negotiable project principles (MUST)194- Strong recommendations (SHOULD)195- Forbidden patterns or approaches196- Quality gates and standards197- Technology constraints (if technical project)198199### 8. Synthesis & Report200201**Action:** Generate structured analysis report202203**Format:**204```markdown205# Project Analysis: [Project Name]206207## Executive Summary208- **Project Type:** [Type]209- **Primary Purpose:** [From README]210- **Key Characteristics:** [3-5 bullet points]211212## Structure213[Directory tree or organization description]214215## Conventions & Patterns216[Key patterns discovered]217218## Standards & Guidelines219- Existing: [List of found docs]220- Created: AGENTS.md with project best practices221- Constitution: [Created/Updated/Found at path]222223## Recommendations2241. [Action]: [Reason]2252. [Action]: [Reason]226227## Next Steps228[Suggested actions - use existing skills, workflows, or custom tasks]229```230231**Present options to user:**2321. Review AGENTS.md and constitution.md2332. Start implementing features (use speckit workflow)2343. Run specific analysis (code quality, documentation coverage, etc.)235236## Anti-Patterns (What NOT to Do)237238### Universal Anti-Patterns239- **NEVER** assume project structure without verification240- **NEVER** create AGENTS.md with generic, non-specific advice241- **NEVER** skip constitution creation/update242- **NEVER** hallucinate file paths that don't exist243- **NEVER** overwrite existing standards without reviewing them first244245### Technical Project Anti-Patterns246- **NEVER** assume framework patterns without checking versions (e.g., Next.js App Router vs Pages)247- **NEVER** skip validation of major dependencies248- **NEVER** guess package manager (could be npm, yarn, pnpm, bun)249250### Content Project Anti-Patterns251- **NEVER** ignore existing content organization patterns252- **NEVER** assume markdown is the only format (could be MDX, AsciiDoc, reStructuredText)253- **NEVER** overlook asset organization and naming conventions254255## Common Mistakes256257| 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 |264265## Quick Reference266267| 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 |273274## Success Indicators275276Analysis is complete when:277- ✅ Project type correctly identified278- ✅ Key directories and organization patterns discovered279- ✅ File naming and structure conventions documented280- ✅ AGENTS.md created with project-specific best practices281- ✅ Constitution created or verified282- ✅ Report generated with actionable next steps283- ✅ No assumptions made without evidence284285## Output286287**Created Files:**288```289.gemini/290└── AGENTS.md # Project-specific AI agent best practices291292.specify/memory/293└── constitution.md # Project principles (created or updated)294```295296**Analysis Report:**297- Project classification298- Structure and conventions299- Standards documentation300- Recommendations and next steps301302## Related Skills303304- **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