| title | Claude Code Project Structure Tutorial | ||
|---|---|---|---|
| tags |
|
||
| last_updated | 2026-04-22 |
You won't need any other project structure for Claude Code. Just this one. This definitive guide covers where skills go, how to organize hooks and MCP servers, and explains the 6 extension types alongside memory file workflows.
Complete Claude Code workspace with skills, Hooks, MCP Servers, Subagents, and Plugins designed for production AI-assisted development.
- L1 -
CLAUDE.md: Persistent context and rules - L2 - Skills: Auto-invoked knowledge packs
- L3 - Hooks: Safety gates and automation
- L4 - Agents: Subagents with their own context
Here is the complete file tree for a production Claude Code workspace:
my_project/
├── CLAUDE.md
├── .claude/
│ ├── settings.json
│ ├── settings.local.json
│ ├── commands/
│ │ ├── review.md
│ │ ├── deploy.md
│ │ ├── test-all.md
│ │ └── bootstrap.md
│ ├── skills/
│ │ ├── code-review/
│ │ │ ├── SKILL.md
│ │ │ ├── scripts/
│ │ │ ├── references/
│ │ │ └── assets/
│ │ ├── text-writer/
│ │ │ └── SKILL.md
│ │ ├── security-audit/
│ │ │ └── SKILL.md
│ │ └── refactor/
│ │ └── SKILL.md
│ ├── agents/
│ │ ├── code-reviewer.yml
│ │ ├── test-writer.yml
│ │ ├── security-auditor.yml
│ │ └── devops-sre.yml
│ └── plugins/
│ ├── manifest.json
│ └── my-plugin/
├── .mcp.json
├── src/
│ ├── components/
│ │ ├── auth/
│ │ ├── dashboard/
│ │ └── shared/
│ ├── services/
│ │ ├── api.ts
│ │ ├── auth.ts
│ │ └── database.ts
│ ├── utils/
│ │ ├── logger.ts
│ │ ├── validators.ts
│ │ └── helpers.ts
│ ├── types/
│ │ └── index.ts
│ └── index.ts
├── tests/
│ ├── unit/
│ ├── integration/
│ └── e2e/
├── docs/
│ ├── architecture.md
│ ├── api-reference.md
│ └── onboarding.md
├── scripts/
│ ├── setup.sh
│ ├── deploy.sh
│ └── seed.db.sh
├── package.json
├── tsconfig.json
├── .env.example
├── .gitignore
├── Dockerfile
└── README.md
CLAUDE.md: Project memory.claude/: Config & extensionscommands/: Slash commandsskills/: Auto-activated skills.mcp.json: MCP server configagents/: Subagent definitions
- Skills: Auto-activate on task match
- Hooks: Lifecycle event scripts
- MCP: External tool connections
- Subagents: Isolated parallel work
- Agent Teams: Multi-agent coordination
- Plugins: Bundled distributable setups
CLAUDE.md serves as Claude's persistent memory, loaded automatically at the start of every session.
- WHAT: Tech stack, Directory map, Architecture
- WHY: Purpose of each module, Design decisions
- HOW: Build/test/lint commands, Workflows, Gotchas
Your project memory should capture:
- Project conventions & style guide
- Tech stack & architecture overview
- Testing requirements & patterns
- Git workflow & branch strategy
- Security & compliance rules
- File naming & folder conventions
- Review checklist before commits
Memory File Hierarchy Rules:
~/.claude/CLAUDE.md: Global - all projects~/CLAUDE.md: Parent - monorepo root./CLAUDE.md: Project - shared on git./frontend/CLAUDE.md: Subfolder - scoped context
Keep each file <200 lines. Subfolder files append context. Never overwrite parent context.
# Project: MyApp
## Tech Stack
- Next.js 14, TypeScript, Tailwind
- Supabase for auth & database
- Prisma ORM, tRPC API layer
## Conventions
- Always write tests before code
- Use conventional commits
- Never commit directly to main
- Run lint + typecheck before PR
## Architecture
- src/components - React components
- src/services - Business logic
- src/utils - Shared helpers
## Security
- No secrets in code or logs
- Validate all user inputs
- Use parameterized queries onlySkills are markdown guides that Claude auto-invokes via natural language.
SKILL.md: Instructions & metadatascripts/: Executable automationreferences/: Docs loaded on demandassets/: Templates & static files
---
name: testing patterns
description: Jest testing patterns
allowed_tools: Read, Grep, Glob
---
# Testing Patterns
Use describe + it + AAA pattern
Use factory mocksTip: The description field is critical for auto-activation.
code-reviewtesting-patternscommit-messagesdocker-deploycodebase-visualizerapi-design
Hooks are deterministic callbacks that govern execution.
PreToolUse: Block before execution (e.g., check safety)PostToolUse: Auto lint after writesSessionStart: Load context on launchSessionEnd: Save session summariesPreCommit: Secret detectionNotification: Slack/webhook alerts
Exit codes dictate behavior: 0 -> allow, 2 -> block.
{
"permissions": {
"allow": ["Read:*", "Bash:git:*", "Write:*.md"],
"deny": ["Read:env:*", "Bash:sudo:*"]
},
"hooks": {
"PreToolUse": [{"matcher": "Book", "hooks": [{"type": "command", "command": "scripts/sec.sh", "timeout": 5}]}],
"PostToolUse": [{"matcher": "Write", "hooks": [{"type": "command", "command": "npm run lint"}]}]
},
"env": {
"MAX_THINKING_TOKENS": "18000",
"CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "50"
}
}Configure via .mcp.json:
- GitHub: PRs, issues, repos
- JIRA/Linear: Ticket workflows
- Slack: Notifications & search
- PostgreSQL: Direct queries
- Playwright: Browser automation
- Filesystem: Scoped file access
.mcp.json Example:
{
"mcpServers": {
"github": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@anthropic/mcp-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"postgres": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@anthropic/mcp-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
}
}
}npm i -g @anthropic-ai/claude-codecd your_project && claude- Generate memory:
/init - Add slash commands in
.claude/commands/ - Configure MCP in
.mcp.json - Add skills as workflows grow
- 0-60% context: Work freely
- 50-70%: Monitor usage
- 70-80%: Run
/compact - 80%+:
/clearmandatory
cd project && claudeShift + Tab + Tab-> Plan Mode- Describe feature intent
Shift + Tab-> Auto Accept/compactperiodicallyEsc Esc-> rewind if needed- Commit frequently
- Start new session per feature
/init: GenerateCLAUDE.md/doctor: Check installation/compact: Compress contextShift + Tab: Change modesTab: Toggle extended thinkingEsc Esc: Rewind menu
- Iterative Development: Start small, test frequently
- Clear Skill Documentation: Describe skill purpose & usage
- Modular Skill Design: Break down complex tasks
- Secure Secret Handling: Use environment variables, not code
- Regular Testing & Auditing: Ensure skills remain reliable
- Claude Agent Skills Playbook — Dive deeper into building reusable workflows.
- Claude AI vs Claude Code vs Claude Cowork — Understand which tool fits your specific use case.
- Claude Code Tool Guide — Explore additional automation commands and configurations.
- Claude Code Cheatsheet Tutorial — Keep the essential commands handy.
- Model Context Protocol (MCP) Guide — Learn how to configure robust external tool connections.
- Claude Code product page: https://claude.com/product/claude-code
- Everything Claude Code (GitHub)