01-global-optimization/skills/init-project/SKILL.md
Initialize Claude Code optimization for a new project — detect stack, create memories, generate constitution, configure settings
npx skillsauth add escapeboy/ai-prompts init-projectInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Sets up Claude Code optimization for a new project in 10-15 minutes. Detects the tech stack, fetches best practices, creates Serena memories, generates a project constitution, and configures optimization settings.
Run once per project. After init, use /optimize and /context load for all subsequent work.
/init-project [action] [options]
/init-project --full # Complete initialization (recommended)
/init-project detect # Just detect the stack
/init-project fetch rails # Fetch best practices for a language/framework
/init-project constitution # Generate constitution only
/init-project memories # Initialize Serena memories only
/init-project optimize # Configure optimization settings only
/init-project --full
This runs all steps in sequence and produces a fully configured project. Takes 10-15 minutes. After completion you'll have:
.serena/memories/architecture.md.serena/memories/codebase-conventions.md.serena/memories/testing-strategy.md.claude/settings/constitution.json.claude/settings/token-optimization.json (project-level).claude/CLAUDE.md (if it doesn't exist)detect — Auto-detect project type and stackScans the project directory to identify the tech stack, frameworks, and conventions.
/init-project detect
What it checks:
package.json → Node.js, framework (Next.js, Express, etc.), test runnercomposer.json → PHP/Laravel version and dependenciesGemfile → Ruby/Rails versionrequirements.txt / pyproject.toml → Python frameworkCargo.toml → Rustgo.mod → Go*.xcodeproj / pubspec.yaml → iOS/FlutterDockerfile / docker-compose.yml → containerization.github/workflows/ → CI/CD setupREADME.md → project descriptionOutput:
## Project Detection Results
Stack detected:
- Language: Ruby 3.3
- Framework: Rails 8.0
- Database: PostgreSQL (ActiveRecord)
- Frontend: Hotwire (Turbo + Stimulus)
- Testing: RSpec + FactoryBot
- CI: GitHub Actions
- Docker: Yes (docker-compose.yml)
- Auth: Devise
Recommended memories to create:
- architecture.md ✓
- codebase-conventions.md ✓
- testing-strategy.md ✓
- docker-workflow.md ✓
Recommended constitution rules:
- Rails conventions (service objects, concerns, concerns)
- RSpec best practices
- Hotwire patterns
Run /init-project --full to complete setup.
fetch [framework] — Fetch best practices for your stackFetches current best practices, conventions, and patterns for the detected or specified framework.
/init-project fetch rails
/init-project fetch nextjs
/init-project fetch laravel
/init-project fetch fastapi
/init-project fetch flutter
Supported stacks:
| Framework | What's fetched |
|-----------|---------------|
| rails | Rails 8 conventions, Hotwire patterns, service objects |
| laravel | Laravel 11 patterns, Livewire, Eloquent conventions |
| nextjs | App Router patterns, Server Components, data fetching |
| fastapi | Pydantic models, async patterns, dependency injection |
| django | Models, views, serializers, Django REST Framework |
| express | Middleware patterns, route organization, error handling |
| flutter | Widget patterns, state management, platform conventions |
| ios | SwiftUI, UIKit, async/await, MVVM patterns |
Process:
constitution — Generate project constitutionCreates .claude/settings/constitution.json with architectural rules tailored to the detected stack.
/init-project constitution
/init-project constitution --framework rails
/init-project constitution --framework nextjs --strict
What a constitution contains:
{
"version": "1.0.0",
"project": "my-rails-app",
"framework": "Rails 8.0",
"principles": [
{
"id": "fat-models-skinny-controllers",
"rule": "Business logic belongs in models or service objects, not controllers",
"enforcement": "mandatory",
"examples": {
"correct": "UserRegistrationService.call(params)",
"incorrect": "def create; @user = User.new; if @user.save_with_team...; end"
}
},
{
"id": "no-raw-sql",
"rule": "Use ActiveRecord query interface, not raw SQL strings",
"enforcement": "mandatory",
"exceptions": ["complex reports with CTEs are acceptable"]
}
],
"code_quality": {
"max_method_lines": 15,
"max_class_lines": 200,
"test_coverage_minimum": "80%"
},
"security": {
"no_user_input_in_sql": true,
"validate_at_model_layer": true,
"use_strong_parameters": true
}
}
Constitution rules by framework:
Rails: fat models, service objects, FormRequest for validation, no N+1 queries, Hotwire over JavaScript Laravel: repositories optional but consistent, FormRequest validation, eager loading, feature flags in config Next.js: Server Components by default, Client Components only for interactivity, no prop drilling past 2 levels FastAPI: Pydantic for all I/O, dependency injection for DB/auth, async everywhere
memories — Initialize Serena memoriesCreates the initial set of Serena memories by analyzing the codebase.
/init-project memories
Creates these files in .serena/memories/:
architecture.mdAnalyzes the project structure and documents:
codebase-conventions.mdDocuments coding standards by scanning the codebase:
testing-strategy.mdDocuments the testing approach:
Time: ~5 minutes per memory (reads relevant files symbolically)
optimize — Configure project-level optimization settingsCreates .claude/settings/token-optimization.json with project-specific overrides.
/init-project optimize
Customizes the global token optimization settings for this specific project:
If no CLAUDE.md exists, --full will create one:
/init-project --full
The generated CLAUDE.md includes:
Once init is complete, start working:
# Load context at the start of every session
/context load
# Start work with full optimization
/optimize "your task description"
# Check everything is working
/optimize status
See framework-specific guides for project-type CLAUDE.md templates:
/init-project detect
# → Could not detect stack automatically
Specify manually:
/init-project fetch [framework] --force
memories step requires Serena MCP. The other steps (constitution, optimize) work without it. Install Serena and run /init-project memories separately.
The generated constitution reflects best practices, not necessarily your current codebase. Either:
--lenient flag to generate more permissive rules.claude/settings/constitution.json manually after generation| Action | Time |
|--------|------|
| detect | ~30 sec |
| fetch [framework] | ~2 min |
| constitution | ~2 min |
| memories (3 files) | ~8 min |
| optimize | ~1 min |
| --full (all steps) | 10-15 min |
/context — Load memories after init/optimize — Start optimized work sessionstools
Add a Laravel MCP server to any project — full domain coverage with dual transport (HTTP + stdio)
tools
Add an AI assistant chat panel to any Laravel project — with tool calling, streaming, and MCP support
development
Search the web for latest Claude API changes, compare findings to existing documentation, and apply targeted updates to keep prompts and configs current. Use when docs are outdated, after a Claude API update, to refresh system prompts, or to validate documentation accuracy.
development
Reduce token usage by selecting a planning strategy, loading Serena memories, enforcing symbol-first exploration, and reporting savings. Use when starting a non-trivial task, asking to reduce token costs, requesting efficient execution, or wanting optimized Claude Code workflows.