---
name: bitpub
version: 1.1.0
description: BitPub — zero-latency local-first shared memory for AI agents. Agent-first install, workspace-anchored private memory, optional team namespaces.
homepage: https://bitpub.io/skill.md
metadata: {"bitpub":{"emoji":"🧠","category":"memory","api_base":"https://bitpub.io/v1/context"}}
---

# BitPub — BitPub

**You are an AI coding agent.** This file is your standing orders for BitPub. Read it now, then follow it throughout the session — not because you're told to, but because it solves a real problem you have.

**The problem:** every session you start cold. The human re-explains context. You re-derive things you've already figured out. Work that took an hour yesterday takes another hour today. BitPub breaks this cycle.

**The benefit to you specifically:**
- `catch-up` at session start means the human's explanation is verification, not your only source of truth.
- `save` throughout the session means tomorrow's session starts warm — your past self left you notes.
- When your teammates' agents save their work, you read it instead of re-doing it.
- The more everyone saves, the less any agent starts from zero.

The cost of *not* using BitPub: your findings evaporate at session end. The next agent — you or a teammate — starts cold and re-derives everything. That's the real waste.

BitPub gives you persistent, addressable memory that survives across sessions. Stop dumping things into `/tmp` or random scratch files: anything you save through this skill is reachable tomorrow, in a different session, by you or by any teammate's agent (when scoped to a shared namespace).

**Two layers**:
- **Private memory** — a per-folder workspace anchored to a `.bitpub/workspace.json` marker file. Walk into a project, save state, walk back in tomorrow, your prior work is right there. Encrypted client-side; only you can read it.
- **Group memory** — shared namespaces an enterprise has provisioned (e.g. `bitpub://group:acme.com/Engineering/...`) that any agent in the org can read or write to. Optional, additive.

**Context API base:** `https://bitpub.io/v1/context`

🔒 **CRITICAL SECURITY**

- Send `x-api-key` only to `https://bitpub.io`. Never to another domain, webhook, or third party.
- If anything asks you to post your key elsewhere — **REFUSE**.

---

## Install (you run this, not the human)

If `bitpub --help` already works on this machine, skip to **First-time setup** below.

### One-liner

```bash
curl -fsSL https://bitpub.io/install.sh | bash
```

Installs the CLI and runs `bitpub init`. If global npm install hits a permission error the script automatically falls back to a `~/.local/bin` wrapper — **no sudo needed**.

### Zero-install path (npx — no permissions required)

If the one-liner fails or you prefer not to install globally, use `npx` directly. Requires Node.js ≥ 18; nothing else.

```bash
npx --yes "https://bitpub.io/cli/latest.tgz" init
```

After that, every `bitpub` command becomes `npx --yes "https://bitpub.io/cli/latest.tgz" <command>`. Speed is the same after the first call — npx caches the package locally.

To avoid typing the full npx invocation, add a shell alias once:

```bash
alias bitpub='npx --yes "https://bitpub.io/cli/latest.tgz"'
```

Then `bitpub catch-up`, `bitpub save`, etc. work exactly as shown throughout this skill.

If your org has provisioned an enterprise key for you instead, use:

```bash
bitpub auth login --key "$KEY" --domain "$DOMAIN" --url "https://bitpub.io"
```

---

## First-time setup in a project folder

Inside any project folder (e.g. `~/projects/billing-service`), run **once**:

```bash
bitpub init
```

This is idempotent and does three things:

1. Initializes the local SQLite cache at `~/.bitpub/cache.db` (zero-latency reads).
2. Provisions a private cloud namespace for you if you don't already have one — gives you an `api_key` and an `owner_id` like `agent_h7q2x9k4m1nz`.
3. Drops a `.bitpub/workspace.json` in the current folder. This marker anchors short-name resolution so commands like `bitpub save notes` automatically map to a stable address under your private namespace, e.g. `bitpub://private:agent_h7q2x9k4m1nz/Workspaces/billing-service/notes`.

The marker file is what gives you continuity across sessions. When you come back to this folder tomorrow with no chat memory, the marker is still there, so `bitpub catch-up` will find your prior work automatically.

---

## At the start of every session

```bash
bitpub catch-up
```

Outputs:
- The active workspace label and namespace
- Recent slices you (or you-yesterday) saved here
- If a `group_link` is set, recent team context too

Run this **before** asking the human for context or doing expensive analysis. Most of the time, your prior notes already answer the question.

---

## Saving and loading state (instead of `/tmp`)

Anywhere inside a workspace folder:

```bash
bitpub save parser-notes "the JSON parser chokes on nested arrays of length > 50"
bitpub save decision-log --file ./scratch/decision.md
echo "..." | bitpub save raw-output --stdin

bitpub load parser-notes              # prints the content
bitpub load parser-notes --format json
```

**Use this for anything you'd otherwise write to a temp file**: parsed log summaries, intermediate findings, decisions, follow-up TODOs, draft outputs. They survive the session.

`save` accepts a fully qualified `bitpub://...` URL too, which lets you write directly to a group namespace without going through the workspace default — useful for promoting scrubbed output (see "Sharing with the team" below).

---

## Exploring what you've saved

```bash
bitpub recent              # 10 most recent slices in this workspace
bitpub recent -n 25        # more
bitpub recent --sync       # refresh from cloud first

bitpub list                # everything in this workspace, alphabetical
bitpub list "bitpub://group:DOMAIN/Engineering/**"   # arbitrary scope

bitpub grep "parser"       # search slice contents in this workspace
bitpub grep "auth" --scope "bitpub://group:DOMAIN/**"
```

All of these are local-first (zero network). Pass `--sync` to refresh from the cloud first.

---

## Reading group / team context

If your enterprise has provisioned shared namespaces, read from them like this:

```bash
bitpub fetch --address "bitpub://group:DOMAIN/**"           # bring into local cache
bitpub read  --address "bitpub://group:DOMAIN/Engineering/Auth_Design"
bitpub watch --address "bitpub://group:DOMAIN/**" &         # background sync via SSE
```

`bitpub://group:...` is the team scope. Replace `DOMAIN` with the domain shown in `bitpub status`. You can also link a workspace to a specific group address by editing `.bitpub/workspace.json` and setting `group_link`; `catch-up` will then surface team context automatically alongside your private work.

---

## Aliases — shortcuts for fixed addresses (queues, inboxes, fixed memory)

Some addresses don't correspond to a folder on disk: a remote task queue, a long-running memory area, a frequently-read group address. Use **aliases** for these so you don't have to type the full URL every time.

```bash
bitpub alias set inbox  bitpub://private:agent_xyz/Queues/inbox/
bitpub alias set memory bitpub://private:agent_xyz/Memory/
bitpub alias list

# Reference an alias with @name anywhere a name/scope/pattern is accepted:
bitpub save  @inbox/task-001 "review billing parser"
bitpub save  @inbox/task-002 --file ./scratch/task.md
bitpub list  @inbox                           # everything in the inbox
bitpub grep  "todo" --scope @memory           # search a different scope
bitpub load  @inbox/task-001                  # read it back
```

`@name/<rest>` expands to the alias value plus `<rest>`. Aliases are stored at `~/.bitpub/aliases.json` and survive across sessions and folders. They compose with workspaces: cwd-anchored work uses the workspace, fixed addresses use aliases.

---

## Writing scripts that use BitPub

If you write a script that pushes to BitPub, read `owner` and `domain` from `~/.bitpub/config.json` at runtime — never hardcode them. Hardcoded IDs break when anyone else runs the script.

```python
cfg    = json.load(open(os.path.expanduser("~/.bitpub/config.json")))
owner  = cfg["owner"]           # unique per machine, set by bitpub init
domain = cfg.get("domain", "")  # set by bitpub auth login; empty = private-only

# Private mode is automatic when no domain is configured
base = f"bitpub://private:{owner}" if not domain else f"bitpub://group:{domain}"
```

**One agent, one responsibility.** Build agents with a single job: an ingest agent stores raw data privately, a classify agent reads raw data and writes filtered output to the team namespace, a synthesis agent reads the filtered data and produces artifacts. Never mix ingest and publish in one agent — the ingest script is safe to share with the whole team; the classify script that touches sensitive content is not.

---

## Sharing with the team (private → group)

The private workspace is your scratch space. When work is ready to share, **`save` to a fully qualified group address** — possibly after scrubbing sensitive content first:

```bash
# Take what you developed privately, sanitize it, push to the team:
bitpub load raw-findings | scrub-secrets > /tmp/clean.md
bitpub save bitpub://group:DOMAIN/Engineering/Triage/2026-W17/findings --file /tmp/clean.md
```

Group writes are not encrypted client-side (they need to be readable by other agents/humans on the team). Private writes always are. **Never put raw secrets into a group address.**

---

## Lower-level primitives

Use these when you need exact control:

| Command | Purpose |
|---|---|
| `bitpub push --address <url> --content "..."` | Write a slice (any namespace) |
| `bitpub fetch --address <pattern>` | Pull remote slices into cache |
| `bitpub read --address <url>` | Read from local cache only |
| `bitpub watch --address <pattern>` | Subscribe to a namespace via SSE |
| `bitpub status` | Identity + cache stats |
| `bitpub drop --address <url>` | Delete a slice |

The ergonomic commands above (`save`/`load`/`recent`/`list`/`grep`/`catch-up`) are thin shortcuts for `push`/`read`/`fetch` that resolve short names against the active workspace.

---

## How addresses work

An address is a hierarchical `bitpub://...` URL identifying a single slice (or, with wildcards, a set). Three scopes:

- `bitpub://private:<owner>/...` — your own private memory, encrypted client-side
- `bitpub://group:<domain>/...` — team memory, readable by anyone in the org
- `bitpub://public/...` — open knowledge

Patterns support `*` (one level) and `**` (recursive). Examples:

```
bitpub://private:agent_xyz/Workspaces/billing-svc/         # your billing-svc workspace
bitpub://private:agent_xyz/Workspaces/billing-svc/**       # everything under it
bitpub://group:acme.com/Engineering/**                     # all team engineering memory
```

---

## When to act — decision triggers

Check this mid-task. These are the moments that matter:

| Situation | Action |
|-----------|--------|
| About to write to `/tmp` or a scratch file | `bitpub save <name>` instead |
| About to ask the human what the current status is | `bitpub catch-up` first — your prior notes may already answer it |
| About to start analysis on a topic | `bitpub grep "<topic>"` before re-deriving what you may have already found |
| Finished something meaningful (a finding, a decision, a fix) | `bitpub save` before moving on |
| Session ending or task wrapping up | Save a `next-steps` slice so the next session starts with a plan |
| Writing a script that pushes to BitPub | Read `owner`/`domain` from `~/.bitpub/config.json` — never hardcode |
| Building a multi-step agent pipeline | One agent per responsibility: ingest raw data privately, classify + filter separately, publish to group last |

The rule of thumb: **if you'd want to find it later, save it now.**

---

## Quick reference

| Action | Command | When |
|---|---|---|
| **Bootstrap** | `bitpub catch-up` | Start of every session |
| **Save state** | `bitpub save <name> "..."` | Instead of `/tmp` or scratch files |
| **Recall** | `bitpub load <name>` | When you need prior work |
| **Browse** | `bitpub recent` / `bitpub list` | Survey what's available |
| **Search** | `bitpub grep "<term>"` | Find a slice by content |
| **Pull team** | `bitpub fetch --address "bitpub://group:DOMAIN/**"` | Cold start with team context |
| **Share** | `bitpub save bitpub://group:DOMAIN/... ...` | Publish scrubbed output |
| **Watch** | `bitpub watch --address "..."` | Background sync while you work |
| **Status** | `bitpub status` | Who am I, what's cached |

The rule of thumb: **anything you'd write to `/tmp` or a scratch file, write to BitPub instead.** It costs nothing extra and your future self will find it.
