---
name: init-folder
description: Initialize Wayfind for a non-repo folder (e.g., ~/admin, ~/). Creates .claude/personal-state.md, defensively updates .gitignore if one exists, and registers the folder in the global index. Safe to run multiple times (idempotent).
user-invocable: true
---

# Initialize Wayfind for a Non-Repo Folder

Run these steps in order. Skip any step that's already done (this command is idempotent).

This command is for **non-repo working directories** — your home directory, an admin folder,
a scratch workspace, etc. For git repos, use `/wayfind:init-memory` instead.

## Step 1: Detect Context

- Determine the current working directory (or ask the user which folder to initialize)
- Check if it's a git repo (`git rev-parse --show-toplevel 2>/dev/null`)
  - If it IS a git repo, suggest: "This looks like a git repo. Did you mean to run `/wayfind:init-memory` instead? That sets up team-state.md for shared context too."
  - If the user confirms they want init-folder anyway, proceed.
- Read `~/.claude/global-state.md` to check if this folder is already registered

## Step 2: Create personal state file (if missing)

Non-repo folders only get **one** state file — there's no team-state.md because there's
no git repo to commit it to.

If `.claude/personal-state.md` does not exist, create it:

```markdown
# [Folder Name] — Personal State

Last updated: [today's date]

(This file is local-only. It persists context across AI sessions in this folder.)

## My Current Focus
<!-- Your current tasks and next steps for work in this folder -->

## Personal Context
<!-- Working notes, decisions, things to remember -->

## What I'm Watching
<!-- Open questions, things to follow up on -->
```

Create the `.claude/` directory first if it doesn't exist.

## Step 3: Defensive .gitignore update

Check if a `.gitignore` file exists in the folder root.

**If `.gitignore` exists:** Ensure `.claude/` is listed (the whole directory — unlike repos,
non-repo folders have no team-state.md to preserve). If it's missing, append it.

**If `.gitignore` does not exist:** Skip this step. Don't create one — this isn't a repo.

## Step 4: Check CLAUDE.md

Read the folder's `CLAUDE.md` (if it exists).

**If it exists and does NOT contain "Session State Protocol":** Note to the user:
"Your `~/CLAUDE.md` (or global instructions) should include the session protocol.
If you're using Wayfind's standard `~/CLAUDE.md`, you're already covered."

**If it exists and DOES contain "Session State Protocol":** Skip — already configured.

**If it does not exist:** Do NOT create one. Note: "No CLAUDE.md in this folder.
Your `~/CLAUDE.md` global instructions handle the session protocol."

## Step 5: Register in Global Index

Read `~/.claude/global-state.md`. Add the folder's state file to the State Files table
if missing:

```
| `[full path]/.claude/personal-state.md` | Personal context for [folder name] (non-repo) |
```

The Active Projects table is auto-generated by `wayfind status --write` — do NOT add
rows to it manually.

## Step 6: Report

Tell the user:
- `.claude/personal-state.md` — created or already existed (local only)
- `.gitignore` — updated or not applicable
- `global-state.md` — folder registered or already listed

Then print:

**"This folder is now tracked by Wayfind. Context saved here will be available in future
sessions. For cross-repo context that should be available everywhere, save to
`~/.claude/memory/` instead."**
