Initialize project context for optimal Claude Code sessions. Use when setting up a new project or documenting an existing (brownfield) project's architecture, tech stack, conventions, and key patterns.
This skill initializes project context by capturing essential information about the codebase, enabling Claude to work optimally in future sessions.
Creates structured documentation in .agent/context/ that helps Claude understand:
Create a todo list for all tasks in this workflow and work through them one by one.
Determine if this is a new project (minimal/no code) or brownfield (existing codebase).
For New Projects:
For Brownfield Projects:
Create the directory structure for storing project context:
mkdir -p .agent/context
mkdir -p .agent/sessions
mkdir -p .agent/archive
Create a .gitignore entry for session files (but keep context files versioned):
.agent/sessions/
.agent/archive/
Ask targeted questions to gather information not discoverable from the codebase. Use the AskUserQuestion tool to ask about:
Architecture & Design:
Tech Stack (if not fully discoverable):
Conventions:
Testing:
Key Context:
Based on exploration (brownfield) and user answers, create comprehensive context files:
.agent/context/architecture.md:
# System Architecture
## Overview
[High-level description of the system architecture]
## Architectural Patterns
[Key patterns: MVC, layered, event-driven, etc.]
## System Boundaries
[Main modules/services and their responsibilities]
## Design Decisions
[Critical architectural decisions and rationale]
## Constraints
[Important constraints or limitations to be aware of]
## Data Flow
[How data moves through the system]
.agent/context/tech-stack.md:
# Technology Stack
## Languages
- [Language]: [Version] - [Purpose/Usage]
## Frameworks
- [Framework]: [Version] - [Purpose/Usage]
## Libraries
### Core Dependencies
- [Library]: [Version] - [Purpose]
### Development Dependencies
- [Tool]: [Version] - [Purpose]
## Databases & Storage
- [Database]: [Version] - [Usage]
## Build & Deploy
- Build Tool: [Tool and version]
- Package Manager: [Manager and version]
- Deployment: [Process/platform]
## Development Environment
- Required tools: [List]
- Setup steps: [Key steps]
.agent/context/conventions.md:
# Coding Conventions
## File Organization
[How files and directories are organized]
## Naming Conventions
### Files
[File naming patterns]
### Variables/Functions
[Naming patterns and styles]
### Classes/Types
[Class and type naming]
## Code Patterns
### Error Handling
[How errors should be handled]
### Logging
[Logging approach and standards]
### Comments & Documentation
[When and how to comment/document]
## Code Style
[Formatting, style guide references]
## Common Patterns
[Frequently used patterns in the codebase]
## Anti-Patterns
[Things to avoid]
.agent/context/testing.md:
# Testing Approach
## Testing Philosophy
[Coverage expectations, testing pyramid]
## Test Frameworks
- Unit Tests: [Framework]
- Integration Tests: [Framework]
- E2E Tests: [Framework]
## Test Organization
[Directory structure and file naming]
## Test Patterns
### Unit Tests
[Patterns and conventions]
### Integration Tests
[Patterns and conventions]
### Mocking/Stubbing
[Approach to test doubles]
## Running Tests
```bash
# Unit tests
[command]
# Integration tests
[command]
# E2E tests
[command]
[Testing in CI/CD pipeline]
**`.agent/context/key-files.md`:**
```markdown
# Key Files & Directories
## Entry Points
- [File path]: [Description and purpose]
## Core Business Logic
- [Directory/File]: [What it contains]
## Configuration
- [Config file]: [What it configures]
## Infrastructure
- [File]: [Purpose]
## Common Pitfalls
[Known gotchas or common mistakes]
## Performance Considerations
[Performance-sensitive areas]
## Security
[Security-critical components or requirements]
Review generated files to ensure:
Create a git commit with the new context files:
git add .agent/context/ .gitignore
git commit -m "Initialize project context for Claude Code sessions
Add comprehensive project documentation including:
- System architecture and design patterns
- Technology stack and dependencies
- Coding conventions and standards
- Testing approach and frameworks
- Key files and common patterns"
Provide a summary of what was created:
✅ Project initialization complete!
Created context files in .agent/context/:
- architecture.md - System architecture and design patterns
- tech-stack.md - Technologies, frameworks, and tools
- conventions.md - Coding standards and patterns
- testing.md - Testing approach and frameworks
- key-files.md - Key files and important information
These files will help Claude work optimally in future sessions.
Next steps:
- Use /start-session to begin work on a feature, bug, or chore
- Update context files as the project evolves