Switch Book

**Framework-only command for multi-book mode**

Installs: 0
Used in: 2 repos
Updated: 2d ago
$npx ai-builder add command rubrical-studios/switch-book

Installs to .claude/commands/switch-book.md

# Switch Book

**Framework-only command for multi-book mode**

This command allows users to switch the active book in a multi-book installation.

---

## Prerequisites

This command only works from **CONFIG_ROOT** (.config/ directory). Check:
- `fw-location.json` exists (indicates valid CONFIG_ROOT)
- `books-registry.json` exists
- `settings.json` exists (contains BOOKS_ROOT path)

If not found, inform user: "This command requires a valid CONFIG_ROOT. Run /fw-init first."

---

## Usage

```
/switch-book [Book Name or ID]
```

**Examples:**
- `/switch-book My Amazing Book`
- `/switch-book my-amazing-book`
- `/switch-book` (no argument - show list and prompt)

---

## Workflow

### Step 1: Validate CONFIG_ROOT

1. Check for `fw-location.json` in current directory
2. If not found: Report "CONFIG_ROOT required - run /fw-init first" and stop

### Step 2: Read Configuration

1. Read `settings.json` → get `booksRoot` as BOOKS_ROOT
2. Read `books-registry.json` → get list of all books
3. Get current `activeBook` from registry

### Step 3: Handle User Input

**If book name/ID provided:**
1. Search registry for matching book (by title or id)
2. If found: Set as active book
3. If not found: Show list and ask user to select

**If no argument provided:**
1. Display all registered books with numbers
2. Show current active book (marked with `*`)
3. Ask user to select by number or name

### Step 4: Display Book List

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Switch Book
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Available books:
  1. [Book Title One] - [status] (last: [date])  * ACTIVE
  2. [Book Title Two] - [status] (last: [date])
  3. [Book Title Three] - [status] (last: [date])

Enter book number or name to switch:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

### Step 5: Update Registry

1. Update `activeBook` in `books-registry.json` to selected book's ID
2. Update `lastAccessed` date for selected book to CONFIRMED_DATE
3. Write updated registry

### Step 6: Load New Context

1. Set `BOOK_PATH` = `[BOOKS_ROOT]/[Book-Directory]` (BOOKS_ROOT from settings.json)
2. Read `[BOOK_PATH]/PROJECT_CONTEXT.md`
3. Update session context with new BOOK_PATH
4. Store new `ACTIVE_BOOK` and `BOOK_PATH` in session

### Step 7: Confirmation

```
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Switched to: [Book Title]
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Book: [Title]
Author: [Author]
Status: [status]
Chapters: [X]
Style: [style name]

Location: [BOOKS_ROOT]/[Book-Directory]/

Ready to work on [Book Title]!
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
```

---

## Alternative Triggers

Users can also switch books by saying:
- "switch to [Book Name]"
- "work on [Book Name]"
- "change to [Book Name]"

These should be recognized and invoke this workflow.

---

## Edge Cases

### No Books Registered

```
No books registered yet.

To create a new book:
1. Say "create new book" or
2. Execute Prompt 1
```

### Book Not Found

```
Book "[search term]" not found.

Available books:
[list books]

Enter book number or name:
```

### Already Active

If user selects the already active book:
```
"[Book Title]" is already the active book.
```

---

## Session Variables Updated

After switching:
- `ACTIVE_BOOK` = new book ID
- `BOOK_PATH` = BOOKS_ROOT/[new book directory] (BOOKS_ROOT from settings.json)

These are used by all prompts for path resolution.

**Path Resolution:**
- CONFIG_ROOT = current directory (.config/)
- BOOKS_ROOT = from settings.json → booksRoot
- BOOK_PATH = BOOKS_ROOT/[book directory]

---

**Version:** 0.16.1
**Last Updated:** 2025-11-28

Quick Install

$npx ai-builder add command rubrical-studios/switch-book

Details

Type
command
Slug
rubrical-studios/switch-book
Created
6d ago