# ConfigHub for Coding Agents: Setup & Ongoing Session Guide

> Free, open-source (MIT) plugin (`v0.99.48`, ~4.8 MB) and Zero-to-Cloud on-ramp to **ConfigHub** for Claude Code, Codex CLI, Google Antigravity, and coding-agent workflows: tracked config reasons across chats, pre-write undo protection, isolated previews, and human-approved production rollouts.

## HARD RULES FOR AGENTS (READ FIRST — STOP BEFORE RUNNING ANYTHING)
1. **Person runs install — NEVER run `claude plugin marketplace add` or `claude plugin install` unattended.** Hand the command to the human (or open a 1-file `.claude/settings.json` PR with the Consent Card below).
2. **Marketplace collision check first:** Run `claude plugin marketplace list`. If `confighub` already points to `confighub/confighub-skills` — **OR if permissions block you from running the check** — **STOP**, inform the human, and do NOT proceed to install.
3. **Hooks load in a new chat:** Tell the user that after installing (or after `/confighub:staging`), they need to open a fresh chat for hooks/scoped keys to activate (and give them a 1-line carry-over prompt).
4. **Hard-gate boundary:** Production approval is only a hard gate when raw host production credentials (e.g. logged-in `vercel` / `fly` CLI) are kept out of the agent's shell. When the agent holds provider creds, recommend `CUB_MINI_MODE=team` and running host deploys in the owner's terminal.

## Trust, License & Footprint
- **License & org:** Free & open source (MIT) Zero-Hub client plugin (`v0.99.48`, ~4.8 MB) published under [`confighubai`](https://github.com/confighubai/confighub-mini-plugin) (ConfigHub's official AI org; client binary only, zero server). Optional Local Hub server binaries come from the official [`confighub/cub-server`](https://github.com/confighub/cub-server) plugin (`cub plugin install confighub/cub-server && cub server local up`) under ConfigHub's Evaluation License (Apple Silicon Mac, ~125 MB, loopback `127.0.0.1`, no Docker; Linux and Intel Mac use Cloud Hub or K8s/`kind` via `cub server install`); hosted Cloud Hubs are on `confighub.com`.
- **Zero Hub → Local Hub → Cloud Hub (same 7 `cub <noun> <verb>` groups):** Start offline with Zero Hub (plugin alone), add an optional Local Hub on `127.0.0.1` via `cub server local up` / `cub local start` / `/confighub:staging`, or scale directly to a Cloud Hub (`confighub.com` or self-hosted Helm) via `/confighub:to-hub` or `cub local to-hub` (`cub mini ...` stays as a compatibility alias).
- **Footprint & overhead:** Zero Hub starts offline with no background servers, no account, and no outbound network calls, scaling cleanly from Zero to Cloud (`~20 ms` median pre-tool hook, `~100–175 ms` once a Local Hub is attached, fail-closed `SHA256SUMS` check). Optional Local Hub (`cub server local up` / `cub local start`) runs the official ConfigHub server, PostgreSQL, and Web UI on `127.0.0.1` (Apple Silicon Mac, ~125 MB, no Docker; Linux/Intel use Cloud Hub or K8s/`kind`) and `/confighub:staging` restricts Claude's sandbox network to localhost (run `npm install` or host CLIs in your own terminal).
- **Storage:** Local history lives in `~/.confighub/agent-changes` on this machine. Run `/confighub:help` anytime inside Claude Code for a 1-screen repo capabilities menu.

---

## Step 1: Inspect the Environment First (Idempotent)

Before proposing any install, check what is already present and detect the repo stack:

1. Check existing tools and setup:
   - `command -v confighub || command -v cub`
   - `claude plugin marketplace list` (if Claude Code is installed)
   - `ls -la ~/.confighub .claude/settings.json AGENTS.md 2>/dev/null`
2. Detect repo config and deploy surfaces:
   - `.env*`, `app-config.json`, `config/*.yaml`, `/etc/<app>/<app>.yaml`
   - `vercel.json`, `fly.toml`, `Procfile`
   - `k8s/`, `Chart.yaml`, `argocd/`, `flux/`
   - `Dockerfile`, `docker-compose.yml`, `.devcontainer/`
3. **Fit rubric (recommend the smallest tier that solves the problem):**
   - Plain `.env`/JSON/YAML repo or PaaS host (Vercel, Fly, Heroku): start with the **plugin alone** (zero repo layout changes, zero server). Add a hub only when isolated previews, staging/prod separation, or server-side approvals are needed.
   - Helm charts + Argo CD, Flux, or Sveltos: start with read-only **Inventory** (`docs/inventory.html`, no 12-chart cap) + **GitHub PR review Action** (`docs/review-readme.html`).
4. If ConfigHub is already installed and configured for this repo, skip to Step 6 (Verification).

---

## Step 2: Show the 4-Line Consent Card and Ask

Present this summary to the human and wait for `y/n` approval (or offer a PR):

```text
ConfigHub plugin setup summary:
- Installs: confighub@confighub (MIT open-source plugin v0.99.48, ~4.8 MB, SHA256SUMS fail-closed, Zero-to-Cloud — starts offline with zero servers)
- Local state: ~/.confighub/agent-changes (no background servers, no account, zero outbound network calls)
- Repo changes: optional .claude/settings.json + 5-line AGENTS.md rule (zero app code changes)
- Uninstall: remove .claude/settings.json entry (or run `claude plugin uninstall confighub@confighub`) and `rm -rf ~/.confighub/agent-changes`
Proceed? [y/n]
```

---

## Step 3: Install via the Matching Harness Path (After Consent)

### Claude Code (solo developer)
First run `claude plugin marketplace list` to confirm `confighub` does not already point to `confighub/confighub-skills` (if it does, stop and ask the user before proceeding). Then ask the user to run:

```sh
claude plugin marketplace add confighubai/confighub-mini-plugin && claude plugin install confighub@confighub
```

Add `--scope project` to limit installation to this repository. Set `CUB_MINI_EARLIER_SESSIONS=lazy` for on-demand transcript lookup instead of 30-day backfill.

### Claude Code (team or PR-based handoff)
Open a branch/PR adding `.claude/settings.json` (omit `"env"` for solo defaults):

```json
{
  "extraKnownMarketplaces": {
    "confighub": {
      "source": { "source": "github", "repo": "confighubai/confighub-mini-plugin" }
    }
  },
  "enabledPlugins": {
    "confighub@confighub": true
  },
  "env": {
    "CUB_MINI_MODE": "team"
  }
}
```

Paste the 4-line Consent Card into the PR description. Merging the PR is the human owner's approval. (If Claude Code shows enabled-but-not-installed on first open, the teammate runs `claude plugin install confighub@confighub --scope project` once.)

### Codex CLI
Review the manual clone, checksum, and removal steps at `https://confighub.github.io/helm-expt/ai-agents/docs/codex.html#set-it-up`, then run with user consent:

```sh
[ -d "$HOME/confighub-mini-plugin" ] || git clone --depth 1 --branch v0 https://github.com/confighubai/confighub-mini-plugin "$HOME/confighub-mini-plugin"
"$HOME/confighub-mini-plugin/plugins/confighub/bin/confighub" agent setup
```

### Google Antigravity (native plugin, `v0.99.48`)
Installs the native `hooks.json` plugin (`confighub mini hook --agy`) into `~/.gemini/config/plugins/confighub`:

```sh
[ -d "$HOME/confighub-mini-plugin" ] || git clone --depth 1 --branch v0 https://github.com/confighubai/confighub-mini-plugin "$HOME/confighub-mini-plugin"
mkdir -p "$HOME/.gemini/config/plugins" && ln -sfn "$HOME/confighub-mini-plugin/plugins/confighub" "$HOME/.gemini/config/plugins/confighub"
```

### Cursor, Windsurf & Other Agent Harnesses
Append the 5-line `AGENTS.md` rule in Step 4 and optionally generate a stack-specific recipe using `https://confighub.github.io/helm-expt/ai-agents/recipes/template.md`.

---

## Step 4: Ongoing Session Persistence (`AGENTS.md`)

Ask the user whether to append this 5-line rule to `AGENTS.md` (or `CLAUDE.md`) so fresh chats inherit it automatically:

```markdown
## Config changes (ConfigHub)
Before editing `.env*`, `app-config.json`, `k8s/`, `helm/`, `vercel.json`, `fly.toml`, or service config files:
1. Check prior intent (`/confighub:why <key>` or `cub agent changes --mode envelope`) before modifying or reverting any setting.
2. Record a plain-English reason (`--change-desc`) for every config edit so later chats see why it changed.
3. Never write directly to production or self-approve a release; propose a change order for human `cub inbox approve`.
```

---

## Step 5: Person-Only Steps & Provisional Contracts

- **Person-only steps (hand the exact command to the human):** `claude plugin install`, `cub inbox approve BASE/ORDER`, `cub repo deliver`, `cub agent require-approval`, `xattr -dr com.apple.quarantine .`, and Claude slash commands (`/confighub:staging`).
- **Provisional features (do not auto-run against `confighub.com`):** `--upload-diff`, hosted `cub agent auth`, and hosted `cub env share` / `cub env join` are preview contracts not yet live on `confighub.com` (`cub agent auth` and `cub env share` / `cub env join` work today against a self-hosted `agentauth-server` relay; see `auth.md`).

---

## Step 6: Verify in 60 Seconds

1. Confirm the CLI responds cleanly (`cub agent card`).
2. Test a safe uncommitted edit in `app-config.json` (`{"cache": false}` → `true` for Saturday's sale), then open a fresh chat and ask `"Why is the cache on?"`.
3. Explore more:
   - Full web router for agents: `https://confighub.github.io/helm-expt/ai-agents/llms.txt`
   - 6-slide Agentic Ops visual story: `https://confighub.github.io/helm-expt/ai-agents/agentic-ops.html`
   - Immutable OCI Config Bundles (Story 31): `https://confighub.github.io/helm-expt/ai-agents/docs/examples/walkthroughs/story-31-oci-config-bundles.html`
   - Stack recipe template: `https://confighub.github.io/helm-expt/ai-agents/recipes/template.md`
   - Pull-only cross-environment sync (`auth.md`): `https://confighub.github.io/helm-expt/ai-agents/auth.md`
   - 17 starters & runtime guides: `https://confighub.github.io/helm-expt/ai-agents/starters.html`
   - Security & privacy review: `https://confighub.github.io/helm-expt/ai-agents/docs/security.html`
