> ## Documentation Index
> Fetch the complete documentation index at: https://eispatch.framewire.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Prompt library

> Save, organize, and reuse EISPATCH prompts locally with projects, categories, tags, capability validation, and JSON import and export.

The Prompt Library (`core/library.mjs`, library version `1.1`) stores composed prompts on your machine so you can reuse them across sessions and hosts. Entries do not include approval tokens; loading an entry always returns the composer to **Draft**.

## Storage

The library is a single JSON file at `~/.eispatch/library.json` with the shape `{ version, updatedAt, entries }`.

* **Atomic writes**: data is written to a temporary file (mode `0600`) and renamed over the library file.
* **Directory**: `~/.eispatch` is created with mode `0700`.
* **Locking**: writers create `library.json.lock`. A writer waits up to 3 seconds, then fails with `Timed out waiting for library lock`. A lock older than 10 seconds is treated as stale and removed.
* **Sanitization**: capability `description` and `instruction` fields pass through pattern-based redaction of URLs and common credential formats before they are saved. Prompt text is stored as written.

## Hierarchy

```text theme={null}
Project → Category → Prompt
```

* **Project**: from the workspace path. `projectKey` is `proj:<canonical path>` (lowercased on Windows) and `projectName` is the folder name. Without a workspace path, the project is `general` / **General**. The General project is listed last.
* **Category**: defaults are UI & Frontend, Testing & QA, Architecture & Refactoring, Documentation, Research & Analysis, Automation & Tooling, and General. Categories are sorted alphabetically; prompts within a category are sorted by most recently updated.

## Suggested metadata

When you save, EISPATCH suggests (and you can change):

* **Title**: the first clause of the prompt (trigger prefix removed), up to 6 words; longer than 48 characters is truncated with `…`. Empty prompts get `Untitled Prompt`.
* **Category**: the category whose keywords (English and some Nepali) appear most often in the prompt, otherwise General.
* **Tags**: up to 4 distinct words of 3 or more characters that are not stop words, plus `breakdown` when the prompt has tasks.

## Library actions

| Action | Behavior |
| - | - |
| Save Prompt | Creates an entry. `originalPrompt` is required. |
| Save Changes | Saves over an existing entry with the same `id`, keeping `createdAt`. |
| Save as New / Duplicate | Copies the entry with a new `id`; the default title gets ` (Copy)`. |
| Load | Restores the entry into the composer in **Draft** state and validates its capabilities. |
| Rename / Move | Updates `title`, `category`, or the project. |
| Delete | Removes the entry permanently. |
| JSON Export | Exports all entries, or only one `projectKey`, as `{ version, exportedAt, entries }`. |
| JSON Import | Accepts `{ entries: [...] }` or an array. See below. |

### Import rules

* Entries without `originalPrompt` are skipped. If none remain, import fails with `No prompt entries found in imported JSON.`
* An incoming `id` is kept if it is not already used; otherwise a new `pr_` ID is generated. Existing entries are never overwritten.
* Missing `projectKey`, `projectName`, and `category` default to `general`, `General`, and `General`.
* Tasks and capabilities are normalized and sanitized the same way as on save.

## Capability validation

When an entry is loaded, its capabilities (prompt-level and per task) are compared by `capabilityId` with capabilities discovered in the current host. The result is `{ valid, missingCapabilities, entry }`:

* `missingCapabilities` lists each unavailable capability once, as `{ capabilityId, kind, label, scope }`. `scope` is `prompt` or the task title.
* Each capability in the returned entry gets `available`, and `enforceable` is taken from the live host (or `false` if the capability is missing).

Validation only reports; it does not change or run anything.

## Entry schema

| Field | Type | Notes |
| - | - | - |
| `id` | string | `pr_` followed by 8 hex characters |
| `title` | string | Suggested if not provided |
| `projectKey` | string | `general` or `proj:<path>` |
| `projectName` | string | Folder name or `General` |
| `canonicalPath` | string or null | Resolved real path |
| `category` | string | Suggested if not provided |
| `tags` | string\[] | Suggested if not provided |
| `originalPrompt` | string | Required |
| `mode` | string | `breakdown` when `tasks` is non-empty, otherwise `simple` |
| `tasks` | object\[] | Each: `id`, `title`, `prompt`, `order`, `recommendedIds`, `capabilities` |
| `selectedCapabilities` | object\[] | Each: `capabilityId`, optional `instanceId`, `kind`, `label`, `description`, `tools`, `enforceable`, `instruction`, `order` |
| `finalEditedPrompt` | string | Final prompt text at save time |
| `manuallyEdited` | boolean | Whether the final prompt was edited by hand |
| `createdAt` | string | ISO timestamp |
| `updatedAt` | string | ISO timestamp of the last change |

> [!NOTE]
>
> The library is shared across hosts on the same machine. A prompt saved in Antigravity can be loaded in Codex, Claude Code, or OpenCode, and validation will report any capabilities that host does not have.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.