# Library

> Keep the scripts, design components, HTML pages, documents, and prompts your agents make in one searchable library, so agents reuse them instead of writing them again.

The **Library** keeps work your agents make that is worth having again: scripts
and tools, design components, HTML pages, documents, diagrams, and snippets such
as prompts. Agents search it before they write a script and save to it when they
make something reusable, and pages they leave in temporary folders arrive on
their own.

- App: **Library**
- CLI: `hansard library`
- In your agent: `search_library`

## Buckets

Every item sits in one bucket:

- **Scripts & tools**: shell, Python, JavaScript, and other scripts.
- **Components**: interface pieces such as a React component with its CSS, and
  design tokens.
- **Artifacts**: HTML pages, documents, diagrams, images, and data files.
- **Snippets**: prompts, commands, and short text you paste again.

**Found** holds scripts and documents Hansard collected from scratch folders.
Keep the ones worth reusing. The rest leave the library after 90 days without
being kept or opened.

## What arrives on its own

The watcher collects, every 30 minutes:

- HTML pages, SVG diagrams, scripts, and Markdown that an agent wrote to a
  temporary folder or an `artifacts/` folder, found through the files your
  archived conversations edited. Pages and diagrams are kept; scripts and
  documents wait under **Found**.
- Pages published from Claude Code.
- Artifacts from your claude.ai conversations, one item per artifact with a
  version for each edit.
- ChatGPT canvas documents, rebuilt version by version from your archived
  conversations.
- Files that a chat's sandbox or a cloud agent made: claude.ai's created and
  edited files and its conversation outputs, the files a ChatGPT reply links
  for download, Claude Cowork's writes, and Claude Science's saved artifacts,
  each with a version for every edit. Plans that Cursor writes in Plan Mode
  are kept as Markdown documents.
- Images that ChatGPT, Codex, or Gemini generated, titled by the prompt that
  asked for them.

Chat files and images come from what Hansard archived. A ChatGPT export names
its images without their bytes, so the browser extension's capture of the
conversation is what brings them in. PDFs, Office documents, and archives stay
in the conversation, since the secret scanner cannot read them.

Hansard copies each file into the library and never changes, moves, or deletes
the original. It skips `node_modules`, build and release folders, hidden
folders, files over 16 MiB, files whose names look like credentials, and any
file whose text the secret scanner flags. Run `hansard library collect` to
collect now.

## Browse and preview in the app

1. Select **Library** in the dock, below **Skills & plugins**. Choose a bucket,
   or search the library from the field above the buckets.
2. Select an item. A page shows in a sandboxed preview that cannot reach the
   app, a document shows formatted, and code shows with highlighting. **Preview**
   and **Source** switch between the two for a page, a diagram, or a document.
3. **Source** names the agent that made the item, the conversation, the
   project, and the original file or published address. **Versions** lists
   each change; select one to preview it.
4. Use **Copy** to copy the text, **Open** to open a page in its own tab, or
   **Download**. Select the pencil to edit the title, the description agents
   read, the kind and its bucket, and the tags.
5. For an item under **Found**, select **Keep** and choose its bucket.

An item of several files lists them under **Files**, with its entry file
first. Select a file to preview it. A page previews with the stylesheets,
scripts, and pictures it names from the same item.

## Let agents use it

Hansard installs a `library` skill with the recall skills for each agent (named
`hansard-library` where an agent already has a skill called `library`). It
tells agents to search the library before writing a utility script, to save
scripts and components they will reuse, and to save HTML pages and documents
they make for you to the library instead of a temporary folder. The recall MCP
server gives agents three tools:

- `search_library` finds items by words in their title, description, tags,
  and text.
- `get_library_item` reads an item and where it came from.
- `save_to_library` saves a file, or a new version of an item, with a
  description that says when to use it. It refuses text that looks like a
  credential.

## Use the command line

```sh
hansard library list --bucket scripts
hansard library search "resize images"
hansard library show <id> --raw > resize.sh
hansard library add ./resize.sh --title "Resize images"
hansard library import ~/design/components
hansard library list --found --sort task
hansard library keep <id> <id> --bucket components
hansard library edit <id> --title "Resize images" --tags images,cli
hansard library remove <id> --yes
```

`list --found --sort task` groups found items under the folder or conversation
that made them, as Found does in the Library view. `keep` and `remove` take
several ids at once, and `keep --bucket` files a found item in another bucket.

`add` with a folder keeps one item of its files, such as a component with its
CSS and a demo page; `--entry` names the file to preview, which is otherwise
`index.html` or `README.md`. `import` adds each file of a folder as its own
item. Removing an item never
touches the original file, and Hansard does not collect it again.

## Where it lives

The library is stored in your Hansard archive. With
[Personal Sync](https://www.hansard.dev/sync/personal-sync/), items you keep reach your other
computers and show under **Other devices**, read-only there; edit or remove an
item on the computer that kept it. Items under **Found** stay on the computer
that collected them. Library items travel only after every computer in your
Personal Sync profile runs a Hansard version that reads them. Hosted assistants
connected to Hansard cannot read or save library items.
