---
description: Load project context efficiently (docs + structure, not all source code)
argument-hint: <path>
context: fork
---

# Boot - Load Project Context

Load essential project context for a new session without reading all source code.

**Argument**: Directory path (e.g., `/boot .` or `/boot ~/myproject`)

---

## Phase 1: Documentation Review

Read key documentation files from the specified directory if they exist:

1. **@$ARGUMENTS/README.md** - Project overview and getting started guide
2. **@$ARGUMENTS/DESIGN.md** - Architecture decisions and design rationale

**If file doesn't exist**: Skip silently and continue to next phase.

**Do not read HANDOFF.md** — session continuity is handled separately via the startup hook.

---

## Phase 2: Repository Structure Overview

Generate a lightweight understanding of project organization **without reading all source code**.

### Check if Git Repository

Run `git rev-parse --is-inside-work-tree` in the specified directory.

### If Git Repository (Recommended Path)

> **MANDATORY — SEPARATE TOOL CALLS**: You MUST issue each command below as its own **individual Bash tool call**. NEVER combine multiple commands in one Bash call using `;`, `&&`, `||`, or any other separator. NEVER add `echo` separators. NEVER append `git ls-files --others` or `--exclude-standard` to any call. NEVER use `git -C <path>` — use `cd` instead. Violating these rules causes permission prompts that block the user.

First, `cd` into the target directory so all subsequent git commands run without `-C`:
```bash
cd $ARGUMENTS
```

Then run these four steps as four separate Bash tool calls:

1. **List tracked files**: `git ls-files` (nothing else — no flags, no additional commands)
2. **Recent activity**: `git log --oneline -10`
3. **Current state**: `git status` (this already shows untracked files)
4. **Present directory structure** from the tracked file list as a tree view of directories (not individual files), grouped by purpose

### If Not Git Repository (Fallback Path)

**Step 1: Generate directory tree**

List directories and key files, excluding common patterns:
- `node_modules/`, `__pycache__/`, `.venv/`, `venv/`, `.git/`
- `*.pyc`, `*.class`, `*.o`, `*.so`, `*.dll`
- `.DS_Store`, `Thumbs.db`

**Step 2: Identify key files**

List files matching important patterns:
- `*.md` (documentation)
- `package.json`, `pyproject.toml`, `Cargo.toml`, `pom.xml` (project manifests)
- `**/test_*.py`, `*.test.js`, `*_test.go` (test files)

---

## Phase 3: Symbol Map (For Large Projects)

**Condition**: If project has more than 50 code files, generate a symbol map.

**Purpose**: Show "what exists where" without reading full implementations.

### Symbol Map Contents

For each major source file, list:
- **Classes** defined (with brief docstring if present)
- **Functions/Methods** exported (signature only, not implementation)
- **Key constants** or configuration

**Example format**:
```
src/models/user.py:
  class User:
    """Represents a user account."""
    - __init__(self, email: str, name: str)
    - authenticate(password: str) -> bool
    - update_profile(data: dict) -> None

src/services/auth.py:
  - login(email: str, password: str) -> Token
  - logout(token: Token) -> None
  - verify_token(token: Token) -> User
```

**How to generate**:
- For Python: Look for `class` and `def` at module level
- For JavaScript: Look for `export class`, `export function`, `export const`
- For Java: Look for `public class`, `public interface`
- For other languages: Best effort based on common patterns

**Skip if**: Project is small (<50 files) - not worth the overhead

---

## Phase 4: Summary and Ready State

Present a concise summary:

```
✓ Context loaded for: [project name from README or directory name]
✓ Documentation: [list which files were found]
✓ Repository: [git repo | directory listing] with [N] tracked files
✓ Structure: [key directories identified]
✓ Symbol map: [generated | skipped - small project]
✓ Recent activity: [last commit message if git repo]

Ready for your prompt.
```

**Token budget total**: ~3-4k tokens (vs 50k+ reading all source)

---

## On-Demand Source Loading

Full source code is loaded contextually when needed (file edits, specific implementation questions, code review). Total boot budget: ~3-4k tokens vs 50k+ for reading all source.
