> built 2026-11-23 05:01 UTC from e398516 (main) · aikb 0.0.9. Details: build_info.json

# index.html.md

<!-- generated by epythet -->

# aikb

Programmatic CRUD for AI project knowledge bases (Claude Projects, and a local provider; Gemini Gems are planned, not implemented).

Dict-like access to knowledge files — `store['notes.md'] = content` — backed by
local files, Claude Projects (via ClaudeSync), or any custom provider.

To install:	`pip install aikb`

## Quick start

```python
from aikb import LocalKb

store = LocalKb()  # ~/.local/share/aikb/localkb_files/default/
store["ideas.md"] = "# Ideas\nFirst idea"
print(store["ideas.md"])
list(store)  # ['ideas.md']
del store["ideas.md"]
```

Every store is a standard Python `MutableMapping` (dict-like), so `len()`,
`in`, `.keys()`, `.values()`, `.items()`, and `.update()` all work.

Override the default directory with a path or the `AIKB_LOCAL_DIR` env var:

```python
store = LocalKb("/path/to/my/knowledge")
store = LocalKb(project_id="research")  # subfolder under default dir
```

## Claude Projects

Manage knowledge files in Claude.ai Projects programmatically:

```bash
pip install aikb[claude]
```

### Browse all your projects

```python
from aikb import ClaudeProjects

projects = ClaudeProjects()
list(projects)  # ['My Project', 'Another Project', ...]
files = projects["My Project"]  # returns a dict-like store
list(files)  # ['context.md', 'notes.md']
print(files["context.md"])
```

### Direct access by project UUID

```python
from aikb import ClaudeProject

store = ClaudeProject("your-project-uuid")
store["context.md"] = "# Project context\n..."
print(store["context.md"])
del store["context.md"]
```

### Getting your session key

aikb automatically looks for a Claude session key in this order:

1. Explicit `session_key` parameter
2. `CLAUDE_SESSION_KEY` environment variable
3. ClaudeSync stored credentials (`~/.claudesync/`)
4. Browser cookies (requires `pip install aikb[cookies]`)

If none are found, you’ll get a helpful error with instructions.

**To get your session key manually:**

1. Open https://claude.ai and log in
2. Open Developer Tools (F12) → Application → Cookies
3. Copy the value of the `sessionKey` cookie (starts with `sk-ant-`)
4. Set it:

```bash
export CLAUDE_SESSION_KEY='sk-ant-sid01-...'
```

Or use [ClaudeSync](https://github.com/jahwag/ClaudeSync) to store credentials:

```bash
pip install claudesync
claudesync auth login
```

## Syncing stores

aikb includes a sync engine that works with any two `MutableMapping` stores — plain dicts, `LocalKb`, `ClaudeProject`, or any custom store.

### Push / Pull (one-directional)

```python
from aikb import LocalKb, ClaudeProject, push, pull

local = LocalKb("/path/to/docs")
remote = ClaudeProject("project-uuid")

push(local, remote)  # local → remote (source wins)
push(local, remote, delete=True)  # also remove remote files not in local
pull(local, remote)  # remote → local
```

### Bidirectional sync (three-way reconciliation)

```python
from aikb import sync, clone

# First time: clone to establish a manifest (baseline)
clone(local, remote, manifest_path=".aikb/manifest.json")

# Later: bidirectional sync detects who changed what
sync(local, remote, manifest_path=".aikb/manifest.json")
```

### Status (dry run)

```python
from aikb import status

for action in status(local, remote):
    print(f"{action.action.value:8s} {action.direction:10s} {action.filename}")
```

### Conflict resolution

```python
from aikb import sync, ConflictPolicy

sync(a, b, manifest=m, on_conflict=ConflictPolicy.A_WINS)  # local wins
sync(a, b, manifest=m, on_conflict=ConflictPolicy.SKIP)  # skip conflicts
sync(a, b, manifest=m, on_conflict=my_resolver_function)  # custom callable
```

Works with plain dicts too — no aikb stores required:

```python
from aikb import push

src = {"readme.md": "# Hello", "notes.md": "..."}
tgt = {}
push(src, tgt)  # tgt is now a copy of src
```

## Custom providers

Implement the `KnowledgeBaseProvider` protocol to add new backends:

```python
from aikb import KnowledgeFiles, KnowledgeBaseProvider


class MyProvider:  # no inheritance needed — just implement the methods
    def list_files(self, project_id: str): ...
    def read_file(self, project_id: str, filename: str) -> str: ...
    def upsert_file(self, project_id: str, filename: str, content: str): ...
    def delete_file(self, project_id: str, filename: str): ...


store = KnowledgeFiles(MyProvider(), project_id="my-project")
```

## MCP server

Expose knowledge base CRUD as MCP tools for Claude Desktop, Claude Code, or
any MCP-compatible client:

```bash
pip install aikb[mcp]
python -m aikb.mcp_server
```

Tools exposed: `list_files`, `read_file`, `write_file`, `delete_file` — each
taking `platform` (`"local"` or `"claude"`), `project`, and file parameters.

## dol compatibility

`aikb` stores implement `collections.abc.MutableMapping`, making them natively
compatible with [dol](https://github.com/i2mint/dol):

```bash
pip install aikb[dol]
```

```python
from dol import wrap_kvs
from aikb import LocalKb

store = wrap_kvs(
    LocalKb("/tmp/kb"),
    obj_of_data=lambda s: s.upper(),  # transforms on read
)
```

## Optional dependencies

| Extra     | Install                     | Provides                               |
|-----------|-----------------------------|----------------------------------------|
| `claude`  | `pip install aikb[claude]`  | Claude Projects via ClaudeSync         |
| `cookies` | `pip install aikb[cookies]` | Auto-extract session keys from browser |
| `mcp`     | `pip install aikb[mcp]`     | FastMCP server                         |
| `dol`     | `pip install aikb[dol]`     | dol store transforms                   |
| `all`     | `pip install aikb[all]`     | Everything                             |

## Skills

This package ships agent skills you can install into any agent host with
[`gh skill`](https://cli.github.com/manual/gh_skill) (don’t have it?
[install gh](https://cli.github.com/)):

```bash
gh skill install thorwhalen/aikb aikb-setup --agent claude-code
gh skill install thorwhalen/aikb aikb-sync
gh skill install thorwhalen/aikb aikb-maintain
```

| Skill           | Use it when…                                             |
|-----------------|----------------------------------------------------------|
| `aikb-setup`    | installing, configuring, or starting to use aikb         |
| `aikb-sync`     | syncing knowledge files between platforms or directories |
| `aikb-maintain` | maintaining, extending, or debugging aikb                |
<p class="epythet-aggregates">This documentation as a single file: <a href="aikb.md">aikb.md</a> (Markdown, for agents).</p>


# _autosummary/aikb.base.html.md

# aikb.base

Core module: protocols, stores, providers, and factory functions for aikb.

### Functions

| [`ClaudeProject`](_autosummary/aikb.base.html.md#aikb.base.ClaudeProject)(project_id, \*[, session_key, ...])   | Create a Claude Project knowledge store.   |
|------------------------------------------------------------------------------------------------------|--------------------------------------------|
| [`LocalKb`](_autosummary/aikb.base.html.md#aikb.base.LocalKb)([rootdir, project_id])                      | Create a local filesystem knowledge store. |

### Classes

| [`ClaudeProjects`](_autosummary/aikb.base.html.md#aikb.base.ClaudeProjects)(\*[, session_key, ...])         | Read-only mapping of Claude project names to KnowledgeFiles stores.   |
|-------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------|
| [`ClaudeProjectsProvider`](_autosummary/aikb.base.html.md#aikb.base.ClaudeProjectsProvider)([session_key, ...])     | Claude Projects provider wrapping ClaudeSync.                         |
| [`KnowledgeBaseProvider`](_autosummary/aikb.base.html.md#aikb.base.KnowledgeBaseProvider)(\*args, \*\*kwargs)      | Structural interface for knowledge base backends.                     |
| [`KnowledgeFiles`](_autosummary/aikb.base.html.md#aikb.base.KnowledgeFiles)(provider, \*, project_id)       | Dict-like access to knowledge files in an AI project.                 |
| [`LocalFilesProvider`](_autosummary/aikb.base.html.md#aikb.base.LocalFilesProvider)(rootdir, \*[, create_dirs]) | Local filesystem provider for knowledge files.                        |

### aikb.base.ClaudeProject(project_id, , session_key=None, organization_id=None)

Create a Claude Project knowledge store.

Requires `pip install aikb[claude]`.

Session key is resolved automatically (env var, ClaudeSync config,
browser cookies). Pass *session_key* explicitly to override.

* **Return type:**
  [`KnowledgeFiles`](_autosummary/aikb.base.html.md#aikb.base.KnowledgeFiles)

### *class* aikb.base.ClaudeProjects(, session_key=None, organization_id=None, include_archived=False)

Bases: [`Mapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.Mapping)

Read-only mapping of Claude project names to KnowledgeFiles stores.

```pycon
>>> p = ClaudeProjects(session_key='sk-ant-...')
>>> list(p)
['My Project', 'Another Project']
>>> files = p['My Project']
>>> list(files)
['context.md', 'notes.md']
```

### *class* aikb.base.ClaudeProjectsProvider(session_key=None, , organization_id=None)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Claude Projects provider wrapping ClaudeSync.

Requires `pip install aikb[claude]`.

Session key resolution priority:

1. Explicit *session_key* parameter
2. `CLAUDE_SESSION_KEY` environment variable
3. ClaudeSync stored config (`~/.claudesync/`)
4. Browser cookies (requires `pip install aikb[cookies]`)

### *class* aikb.base.KnowledgeBaseProvider(\*args, \*\*kwargs)

Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol)

Structural interface for knowledge base backends.

Any object implementing these four methods can be used as a provider.

### *class* aikb.base.KnowledgeFiles(provider, , project_id)

Bases: [`MutableMapping`](https://docs.python.org/3/library/collections.abc.html#collections.abc.MutableMapping)

Dict-like access to knowledge files in an AI project.

Keys are filenames (str), values are file contents (str).

```pycon
>>> import tempfile, os
>>> store = LocalKb(tempfile.mkdtemp())
>>> store['notes.md'] = '# Notes'
>>> store['notes.md']
'# Notes'
>>> list(store)
['notes.md']
>>> len(store)
1
>>> del store['notes.md']
>>> list(store)
[]
```

### *class* aikb.base.LocalFilesProvider(rootdir, , create_dirs=True)

Bases: [`object`](https://docs.python.org/3/builtins/functions.html#object)

Local filesystem provider for knowledge files.

Each `project_id` maps to a subdirectory under *rootdir*.
Files are stored as UTF-8 text.

### aikb.base.LocalKb(rootdir=None, , project_id='default')

Create a local filesystem knowledge store.

Files are stored in `rootdir / project_id /`.
Defaults to `~/.local/share/aikb/localkb_files/` or the
`AIKB_LOCAL_DIR` environment variable.

```pycon
>>> import tempfile
>>> store = LocalKb(tempfile.mkdtemp())
>>> store['ideas.md'] = '# Ideas\nFirst idea'
>>> store['ideas.md']
'# Ideas\nFirst idea'
```

* **Return type:**
  [`KnowledgeFiles`](_autosummary/aikb.base.html.md#aikb.base.KnowledgeFiles)


# _autosummary/aikb.html.md

# aikb

Programmatic CRUD for AI project knowledge bases (Claude Projects, and a local provider; Gemini Gems are planned, not implemented).

### Modules

| [`base`](_autosummary/aikb.base.html.md#module-aikb.base)                                    | Core module: protocols, stores, providers, and factory functions for aikb.   |
|-----------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [`mcp_server`](_autosummary/aikb.mcp_server.html.md#module-aikb.mcp_server)                        | MCP server exposing knowledge base CRUD as tools.                            |
| [`sync`](_autosummary/aikb.sync.html.md#aikb.sync)(a, b, \*[, manifest, manifest_path, ...]) | Bidirectional sync with three-way reconciliation.                            |


# _autosummary/aikb.mcp_server.html.md

# aikb.mcp_server

MCP server exposing knowledge base CRUD as tools.

Requires `pip install aikb[mcp]`.

Run with:

```default
python -m aikb.mcp_server
```

### Functions

| [`create_server`](_autosummary/aikb.mcp_server.html.md#aikb.mcp_server.create_server)()   | Create and return the FastMCP server instance.   |
|--------------------------------------------------------------------|--------------------------------------------------|

### aikb.mcp_server.create_server()

Create and return the FastMCP server instance.


# _autosummary/aikb.sync.html.md

# aikb.sync

### aikb.sync(a, b, \*, manifest=None, manifest_path=None, on_conflict=ConflictPolicy.RAISE, dry_run=False, hash_fn=<function content_hash>)

Bidirectional sync with three-way reconciliation.

Requires a *manifest* (or *manifest_path*) for correct conflict detection.
If neither is provided, uses an empty manifest (first sync — everything
looks “created”).

After successful propagation, updates the manifest to reflect the new
synchronized state.

* **Return type:**
  [`list`](https://docs.python.org/3/builtins/stdtypes.html#list)[`SyncAction`]


# about-this-build.html.md

<!-- generated by epythet -->

# About this build

This documentation was built on **2026-11-23 05:01 UTC** from commit <a href="https://github.com/addaix/aikb/commit/e39851604358f4141ecea1fcba52b3b475cebc6e"><code>e398516</code></a> on branch <code>main</code>, for **aikb 0.0.9** (from <code>pyproject.toml</code>).

#### NOTE
Nothing suggests a mismatch: the tree was clean at the commit above, and the documented version is the one on PyPI.

## Source

|                     |                                                                                                                                                    |
|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| Commit              | <a href="https://github.com/addaix/aikb/commit/e39851604358f4141ecea1fcba52b3b475cebc6e"><code>e39851604358f4141ecea1fcba52b3b475cebc6e</code></a> |
| Branch              | <code>main</code>                                                                                                                                  |
| Tags at this commit | <code>0.0.9</code>                                                                                                                                 |
| Working tree        | clean                                                                                                                                              |
| Remote              | <code>https://github.com/addaix/aikb</code>                                                                                                        |

## Continuous integration

|              |                                                                                            |
|--------------|--------------------------------------------------------------------------------------------|
| Repository   | <code>addaix/aikb</code>                                                                   |
| Run          | <a href="https://github.com/addaix/aikb/actions/runs/45115036844">45115036844</a>          |
| Ref          | <code>refs/heads/main</code>                                                               |
| Event commit | <code>ac11c0b62e3169bf67da2fee7055bc699e4fdd6a</code> (in the history of the built commit) |

## Tools

|          |         |
|----------|---------|
| epythet  | 0.2.23  |
| Sphinx   | 9.1.1   |
| docutils | 0.22.4  |
| Python   | 3.12.16 |

## Configuration as resolved

|               |                                                                  |
|---------------|------------------------------------------------------------------|
| theme         | <code>auto</code> (Sphinx theme <code>furo</code>)               |
| accent        | <code>#23691d</code>                                             |
| api_generator | <code>autosummary</code>                                         |
| ignore        | <code>tests/</code>, <code>scrap/</code>, <code>examples/</code> |
| agent_outputs | <code>true</code>                                                |
| aggregates    | <code>md</code>                                                  |
| ai_artifacts  | <code>true</code>                                                |

## Package on PyPI

Latest release: <a href="https://pypi.org/project/aikb/0.0.9/">0.0.9</a>, the same as the documented version.

## Reproduce

```bash
git clone https://github.com/addaix/aikb && cd aikb
git checkout e39851604358f4141ecea1fcba52b3b475cebc6e
pip install "epythet==0.2.23"
epythet quickstart . --ignore tests/ scrap/ examples/
```

The same data, for machines: <a href="build_info.json"><code>build_info.json</code></a> (schema version 1).


# ai-agents.html.md

<!-- generated by epythet -->

# For AI agents

`aikb` ships artifacts for coding agents alongside its code. This page lists
them, says where each lives in the repository, and points at the
machine-readable copies of this documentation.

## Skills

Skills are folders holding a `SKILL.md` (the [Agent Skills](https://agentskills.io) format): a description that tells an agent when to use it and a body with the procedure. Install one into your agent with `gh skill` (any host: `--agent claude-code`, `copilot`, `cursor`, `codex`, `gemini`), or use the copy bundled in the wheel.

### `aikb-maintain`

Use when maintaining, extending, or debugging the aikb codebase. Covers adding new providers, modifying the store facade, updating tests, and architectural decisions.

```bash
gh skill install addaix/aikb aikb-maintain --agent claude-code
```

Source: [`skills/aikb-maintain`](https://github.com/addaix/aikb/tree/HEAD/skills/aikb-maintain).

### `aikb-setup`

Use when helping a user install, configure, or start using aikb. Covers installation, authentication setup, first-use walkthroughs, and troubleshooting.

```bash
gh skill install addaix/aikb aikb-setup --agent claude-code
```

Source: [`skills/aikb-setup`](https://github.com/addaix/aikb/tree/HEAD/skills/aikb-setup).

### `aikb-sync`

Use when syncing knowledge files between platforms or directories — e.g., pushing local files to Claude Projects, mirroring between projects, or batch-updating a knowledge base from a folder of markdown files.

```bash
gh skill install addaix/aikb aikb-sync --agent claude-code
```

Source: [`skills/aikb-sync`](https://github.com/addaix/aikb/tree/HEAD/skills/aikb-sync).

## Instruction files

Files agents read before working in this repository.

- [`.claude/CLAUDE.md`](https://github.com/addaix/aikb/tree/HEAD/.claude/CLAUDE.md): read by Claude Code

## Machine-readable documentation

This site publishes the same documentation in forms that fit an agent’s context window:

- [`llms.txt`](https://addaix.github.io/aikb/llms.txt): an index of every page with a one-line description ([llms.txt](https://llmstxt.org) format)
- [`aikb.md`](https://addaix.github.io/aikb/aikb.md): the whole documentation as one Markdown file
- `<page>.html.md`: a rendered Markdown twin of every page, advertised from each page’s `<head>` with `<link rel="alternate" type="text/markdown">`
- [`objects.inv`](https://addaix.github.io/aikb/objects.inv): the Sphinx inventory: a symbol-to-URL index (`sphobjinv convert plain objects.inv -`)


# api.html.md

# API reference

| [`aikb`](_autosummary/aikb.html.md#module-aikb)   | Programmatic CRUD for AI project knowledge bases (Claude Projects, and a local provider; Gemini Gems are planned, not implemented).   |
|---------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|


