# Context Persistence Across Claude Code Sessions > **Last Updated**: 2025-01-30 > **Status**: โœ… Fully Configured --- ## ๐ŸŽฏ Overview This document explains how project instructions and tooling requirements persist across Claude Code conversation sessions. --- ## โœ… What Happens Automatically ### 1. CLAUDE.md Loading - **Status**: โœ… Automatic (built into Claude Code) - **When**: Start of every conversation - **File**: [CLAUDE.md](../CLAUDE.md) - **How**: Claude Code includes it in the system prompt automatically - **Action Required**: None - works out of the box ### 2. SessionStart Hook - **Status**: โœ… Configured and active - **When**: Start of every conversation - **File**: [.claude/hooks/session-start.sh](.claude/hooks/session-start.sh) - **Configuration**: [.claude/settings.json:116-126](.claude/settings.json#L116-L126) - **What it does**: Displays a prominent reminder about: - Available MCP servers - Available agents - Mandatory tooling usage requirements - Links to documentation ### 3. MCP Servers - **Status**: โœ… Auto-connect on every session - **Configuration**: [.mcp.json](../.mcp.json) + `enableAllProjectMcpServers: true` - **Servers**: serena, sequential-thinking, context7, memory, fetch, windows-mcp, playwright, database-server ### 4. Specialized Agents - **Status**: โœ… Always available - **Location**: [.claude/agents/](.claude/agents/) - **Count**: 8 agents (Explore, Plan, test-engineer, code-reviewer, etc.) - **Access**: Via `Task` tool with `subagent_type` parameter ### 5. Slash Commands - **Status**: โœ… Always available - **Location**: [.claude/commands/](.claude/commands/) - **Count**: 9 commands (/test, /review, /explain, etc.) - **Access**: Via `SlashCommand` tool --- ## ๐Ÿ“‹ Session Initialization Flow ``` New Conversation Started โ†“ 1. Claude Code loads CLAUDE.md automatically โ†“ 2. SessionStart hook executes (.claude/hooks/session-start.sh) โ†“ 3. Hook outputs reminder message to conversation โ†“ 4. MCP servers auto-connect โ†“ 5. Agents become available โ†“ 6. Slash commands become available โ†“ โœ… Session ready with full context! ``` --- ## ๐Ÿงช Testing ### Verify Session Hook Works Run manually to see output: ```bash bash .claude/hooks/session-start.sh ``` Expected output: ``` ๐Ÿš€ **New Session Initialized - Foundry VTT Development Environment** ๐Ÿ“‹ **MANDATORY REMINDERS FOR THIS SESSION**: [... reminder content ...] ``` ### Verify CLAUDE.md Loading Start a new conversation and ask: > "What project am I working on?" Claude should know about: - Foundry VTT v11.315 - PF1e System v10.8 - Macro development focus - All project structure details ### Verify MCP Servers In a new conversation, ask: > "What MCP servers are available?" Should list all 8 servers. ### Verify Agents In a new conversation, ask: > "What specialized agents are available?" Should list all 8 agents with descriptions. --- ## ๐Ÿ“ Key Files | File | Purpose | Auto-Load? | |------|---------|-----------| | [CLAUDE.md](../CLAUDE.md) | Complete project documentation | โœ… Yes | | [.claude/SESSION_INSTRUCTIONS.md](SESSION_INSTRUCTIONS.md) | Quick reference for mandatory policies | Manual read | | [.claude/settings.json](settings.json) | Claude Code configuration | โœ… Yes | | [.claude/hooks/session-start.sh](hooks/session-start.sh) | Session initialization hook | โœ… Yes | | [.mcp.json](../.mcp.json) | MCP server configuration | โœ… Yes | --- ## ๐Ÿ”ง Customization ### To Modify Session Start Message Edit: [.claude/hooks/session-start.sh](hooks/session-start.sh) The heredoc section (lines 15-48) contains the message displayed at session start. ### To Add More Instructions **Option A**: Add to CLAUDE.md (automatically loaded) **Option B**: Modify session-start.sh hook (shown at session start) **Option C**: Create new files in .claude/ (manual read required) ### To Add More Hooks Edit: [.claude/settings.json](settings.json) Available hooks: - `SessionStart`: Start of session - `SessionEnd`: End of session - `PreToolUse`: Before any tool use - `PostToolUse`: After any tool use - `UserPromptSubmit`: When user sends a message - `Stop`: When generation is stopped --- ## โœจ Benefits of This Setup 1. **Zero Manual Effort**: Everything loads automatically 2. **Consistent Reminders**: Every session starts with clear instructions 3. **Full Context**: Claude always knows about agents, MCP servers, and project details 4. **Trackable**: Session logs in `.claude/logs/session.log` 5. **Customizable**: Easy to modify hooks and instructions --- ## ๐ŸŽฏ What Claude Will See in Every New Session At the start of every conversation, Claude receives: 1. โœ… **System Prompt**: Contains full CLAUDE.md automatically 2. โœ… **Hook Output**: Displays session initialization banner 3. โœ… **MCP Tools**: All 8 MCP servers' tools are registered 4. โœ… **Agents**: All 8 agents are available via Task tool 5. โœ… **Slash Commands**: All 9 commands are available 6. โœ… **Permissions**: All allowed/denied operations from settings.json --- ## ๐Ÿ“ Maintenance ### When to Update Update these files when: - Adding new MCP servers โ†’ Update session-start.sh - Adding new agents โ†’ Update session-start.sh - Changing project focus โ†’ Update CLAUDE.md + session-start.sh - Adding new mandatory policies โ†’ Update CLAUDE.md + SESSION_INSTRUCTIONS.md ### Backup Key files to backup: - CLAUDE.md - .claude/settings.json - .claude/hooks/*.sh - .claude/SESSION_INSTRUCTIONS.md - .mcp.json --- ## ๐Ÿ› Troubleshooting ### Hook Not Running? Check [.claude/settings.json](settings.json) lines 116-126: ```json "hooks": { "SessionStart": [ { "matcher": "*", "hooks": [ { "type": "command", "command": "bash .claude/hooks/session-start.sh" } ] } ] } ``` ### CLAUDE.md Not Loading? - Ensure file exists at project root: `c:\DEV\Foundry\CLAUDE.md` - File is automatically loaded by Claude Code (no configuration needed) ### MCP Servers Not Connecting? - Check `.mcp.json` exists - Verify `enableAllProjectMcpServers: true` in settings.json - Check MCP server installations --- **Reference**: See [CLAUDE.md](../CLAUDE.md) for complete project documentation **Questions?**: The session-start hook ensures you see reminders at every session start!