---
title: "Knowledge Library"
description: "A platform-level catalog of shared wiki folders. Owners ingest repos, files, and URLs into Karpathy-style LLM wikis; agents are assigned the folders they need."
---

The **Knowledge Library** is a workspace-wide catalog of wiki folders that any agent can be assigned. A folder is owned by the person who created it; that owner ingests sources (repos, files, URLs), builds the wiki, and decides which agents get it. The same folder can power one agent or twenty — no duplication, no per-agent rebuilds.

<img src="/images/knowledge-library.png" alt="Knowledge Library showing three shared wiki folders with their owners" style={{borderRadius: "12px", marginBottom: "24px"}} />

## Why Karpathy-style?

[Andrej Karpathy's observation](https://x.com/karpathy/status/1979644538185752935): LLMs read best when content is pre-organized as a wiki — overview, concepts, flows, modules — rather than dumped as raw files. A human codebase has hidden structure; a wiki makes it explicit.

SlackHive's ingest pipeline does exactly that. Instead of stuffing 200 source files into the agent's context, each folder builds:

- An `overview.md` — what this is, in one page
- An `index.md` — table of contents with every page
- `concepts/` — domain ideas (accounts, bookings, payouts)
- `entities/` — the concrete objects (User, Invoice, Session)
- `flows/` — how things connect (checkout flow, refund flow)
- `modules/` — one page per code module (for repo sources)

The agent reads `index.md` first, then pulls only the pages it needs. Context stays small, answers stay grounded.

## Roles

| Role | What they can do with wiki folders |
|---|---|
| **Anyone authenticated** | Read every folder and built wiki page |
| **Editor** | Create new folders. Edit / build / delete folders **they created**. Assign their own folders to agents they own |
| **Admin / Superadmin** | Edit, build, delete, or assign any folder regardless of owner |

A folder's `createdBy` is the source of truth for ownership — folder names are not unique across the workspace. Agents are assigned folders by the agent's editor; that editor must own the folder (or be an admin) for the assignment to land.

## Create a folder and add sources

1. Open the **Knowledge Library** from the sidebar
2. Click **+ New Folder**, give it a name, save
3. Inside the folder, click **+ Add Source** and pick a type:

| Source | Use when | Example |
|---|---|---|
| **Git repo** | You want the agent to understand a codebase | `github.com/pelago-labs/slackhive` |
| **URL** | The content lives on a public or internal webpage | `docs.internal.co/runbooks/checkout` |
| **File upload** | You have plain-text content to quote verbatim | Markdown spec, runbook, schedule |

Plain-text uploads only — `.md`, `.txt`, `.csv`, `.json`, `.yaml`, code files. PDFs and binaries are rejected at upload time. Max 2 MB per file.

<Note>
  Private repos use a personal access token. Add the token via **Settings → Env Vars** (e.g. `GITHUB_TOKEN`), then reference it from the source's "PAT Env Ref" dropdown. You can only reference env vars **you** created — if you need a teammate's PAT, ask them to create the source.
</Note>

## Build the wiki

Click **Build Wiki** on the folder header. The build:

- Compiles all sources in the folder to `~/.slackhive/knowledge/<folderId>/wiki/`
- Marks each source `compiled` once finished; failed sources show `error` with the message
- Uses an atomic file lock so two simultaneous builds for the same folder don't collide

For routine updates on a single source — say a repo that just got new commits — use **Sync** on that source row instead of rebuilding the whole folder. Sync runs the same pipeline scoped to one source.

A source is automatically marked `stale` when its `repoUrl`, `branch`, `patEnvRef`, content, or URL changes. Stale sources are picked up by the next folder build.

### Incremental re-sync (repo sources)

Repo-type sources track the last successfully ingested commit SHA. On the **next** sync after a successful first build, the runner compares HEAD to that SHA and takes one of three paths:

| HEAD vs `last_synced_sha` | What runs | Token cost |
|---|---|---|
| HEAD unchanged | **Skip Claude entirely.** Just bump `last_synced` timestamp. | Near zero |
| HEAD moved, diff computable | **Diff-focused content.** Only the bodies of changed/added/renamed files plus a small README context block. Deleted files become a path list so Claude can clean up the corresponding wiki articles. | ~5–10% of a full snapshot on small diffs |
| HEAD moved, diff unreachable (force-push, branch swap, deepen failed) | **Full snapshot fallback.** Same as today's first-time ingest. | Same as a normal build |

You can see which path ran in the runner log:

```
Repo unchanged since last sync — skipping
Repo diff read … added: 2, modified: 5, deleted: 1, renamed: 0
Repo content read … chars: 466382      ← snapshot fallback
```

The `Wiki source compiled` line includes `mode: incremental` or `mode: snapshot` so you can verify after the fact. **File-type and URL-type sources don't track a SHA** — re-syncs always re-process the full content for those. **Build from scratch** ignores incremental tracking entirely and zeros every source's `last_synced_sha`, `word_count`, and `last_synced` so the wiki rebuilds from a clean slate.

<img src="/images/engineering-knowledge-wiki-diversity.png" alt="A built wiki folder with the article tree on the left and concepts/diversity.md open on the right" style={{borderRadius: "12px", marginBottom: "24px"}} />

## Assign folders to an agent

Open the agent and switch to the **Wiki** tab. You'll see every folder in the library with an **Assign** button.

<img src="/images/argus-wiki-folders.png" alt="Agent's Wiki tab showing assignable wiki folders from the Knowledge Library" style={{borderRadius: "12px", marginBottom: "24px"}} />

When you assign a folder:

- The folder's compiled wiki is copied into the agent's workspace at `knowledge/wiki/{folder-slug}/`
- The agent's `CLAUDE.md` gets a `# Knowledge Base` section listing every assigned folder and its articles
- The `/wiki` slash skill is auto-enabled when at least one assigned folder has built content

Reload the agent (or wait for the auto-reload) and it can immediately consult the wiki. To unassign, click **Unassign** in the same place — the folder stays in the library, only this agent loses access.

## How the agent uses it

When a user asks a question:

1. Agent runs `/wiki` (built-in skill)
2. The skill reads the `# Knowledge Base` index in `CLAUDE.md`
3. Agent picks the relevant folder and article(s), Reads them
4. Agent answers, grounded in the wiki

No configuration needed. It just works.

## Coach access

Coach can **read** wiki sources for context — `list_file_sources` tells it what file content is available across the agent's assigned folders, and `read_file_source` returns one source's verbatim text. This is useful when Coach is auditing claude.md or skills against actual reference material.

Coach **cannot** add, edit, or delete wiki sources. Wiki content belongs to the folder owner and is shared across many agents — edits go through the Knowledge Library UI so the owner stays in the loop.

## Backup and restore

Each folder's compiled wiki lives at `~/.slackhive/knowledge/<folderId>/wiki/` on the host. Snapshot that directory alongside your `data.db` for disaster recovery; folder ownership and assignments are restored from the database.

## Next steps

<CardGroup cols={2}>
  <Card title="Concepts" icon="diagram-project" href="/agents/concepts">
    How the Knowledge Library fits with system prompt, skills, and memory.
  </Card>
  <Card title="Coach" icon="comments" href="/agents/coach">
    The interactive panel that tunes claude.md, skills, and memory.
  </Card>
</CardGroup>
