# How to Install BOSS AI: Team-Wide Usage and OKR Tracking for Codex and Claude Code

> AI Release · @ai_releaseorg · https://ai-release.org/guides/poshagovoe-rukovodstvo-kak-ustanovit-boss-ai-i-vesti-uc_en.html

## TL;DR

- **Time to complete:** ~30 minutes (one machine), plus ~10 minutes per additional teammate.
- **Difficulty:** Intermediate — you need Docker, a shell and basic Python.
- **You will need:** macOS, Linux or WSL2; Docker Engine with the Compose plugin; Python 3.9+; `jq`; a Claude Code install (`~/.claude/`) and a Codex CLI install (`~/.codex/`) that have each run at least one real session; access to the BOSS AI release page.

## What you will get

- A running BOSS AI service you can see in `docker compose ps` as `Up`, with read-only mounts of `~/.claude` and `~/.codex`.
- `usage_report.py` — a working collector that walks both agent data directories and writes `team-usage.csv` with per-user, per-session input, output and cached token totals.
- A `team-usage.md` weekly report plus a cron/launchd job that regenerates it, so the whole team's Codex and Claude Code spend sits in one table.

## Quick start

```bash
cd ~/boss-ai && cp .env.example .env
docker compose up -d && docker compose ps
python3 usage_report.py --days 7 --out team-usage.csv
head -n 5 team-usage.csv
```

Details and verification are in the steps below.

## Requirements and setup
![Illustration: Requirements and setup](https://ai-release.org/guides/img/poshagovoe-rukovodstvo-kak-ustanovit-boss-ai-i-vesti-uc-en-1.jpg?v=1796222146)


- **OS:** macOS 13+, Ubuntu 22.04+ or WSL2 on Windows 11. Native Windows without WSL2 cannot mount `~/.claude` into a Linux container cleanly.
- **Docker Engine 24+ with the Compose v2 plugin.** Check with `docker compose version` — the output must contain `v2`.
- **Python 3.9+** — check with `python3 --version`.
- **`jq`** — check with `jq --version`.
- **Agent data present.** Claude Code stores each session as a `.jsonl` transcript under `~/.claude/projects/<encoded-project-path>/`; every assistant message there carries a `usage` object with token counters. Codex CLI stores rollout `.jsonl` files under `~/.codex/sessions/<YYYY>/<MM>/<DD>/`. BOSS AI reads this data; it does not create it.
- **BOSS AI release access.** The image name, default port and environment variable names are defined by the release you download — check the documentation before editing the compose file.

| Component | Why it is needed | How to check |
|---|---|---|
| Docker + Compose v2 | Runs BOSS AI as a container | `docker compose version` |
| Python 3.9+ | Runs the usage collector | `python3 --version` |
| `~/.claude/projects/*.jsonl` | Claude Code token source | `find ~/.claude/projects -name '*.jsonl' \| wc -l` |
| `~/.codex/sessions/**/*.jsonl` | Codex token source | `find ~/.codex/sessions -name '*.jsonl' \| wc -l` |

## Step 1. Confirm both agents are writing session data
![Illustration: Step 1. Confirm both agents are writing session data](https://ai-release.org/guides/img/poshagovoe-rukovodstvo-kak-ustanovit-boss-ai-i-vesti-uc-en-2.jpg?v=1796222152)


**What to do:** verify that Claude Code and Codex CLI exist on the machine and that both have already produced session files.

```bash
command -v claude codex
claude --version
codex --version
find ~/.claude/projects -name '*.jsonl' | wc -l
find ~/.codex/sessions -name '*.jsonl' | head -n 3
```

Inspect one line so you know what the collector will parse:

```bash
head -n 1 ~/.claude/projects/*/*.jsonl | python3 -m json.tool | head -n 30
```

**Example:** the Claude Code output contains a block like `"usage": {"input_tokens": 1204, "output_tokens": 318, "cache_read_input_tokens": 8192}`, while a Codex rollout file contains a token-accounting event with its own counter names. The names differ between tools — that is why the collector in Step 3 matches counter keys by name instead of by fixed position.

**Why:** token accounting is only as complete as the transcripts on disk. If an agent has never run a session on this machine, there is nothing to count and BOSS AI will show an empty team.

If you are rolling this out beyond one laptop, pair the collector with the team-level setup described in [Claude Code for Teams: Setting Up Subagents and a Shared AI Superagent](https://ai-release.org/guides/claude-code-dlya-komandy-kak-nastroit-subagentov-i-obsc.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide) so every teammate produces session data in the same place.

**How to check:** both `command -v` lines print a path (e.g. `/usr/local/bin/claude`), and both `find` commands print a number greater than `0`.

Checklist before moving on:

- [ ] `claude --version` and `codex --version` both print a version
- [ ] `~/.claude/projects` contains at least one `.jsonl`
- [ ] `~/.codex/sessions` contains at least one `.jsonl`
- [ ] you have run one assistant turn in each tool today, so the data is fresh

## Step 2. Install BOSS AI and mount the two agent directories

**What to do:** create the deployment directory, write the compose file, and start the service.

```bash
mkdir -p ~/boss-ai && cd ~/boss-ai
cat > docker-compose.yaml <<'YAML'
services:
  boss-ai:
    image: <boss-image>
    ports:
      - "<boss-port>:<boss-port>"
    environment:
      - CLAUDE_DATA_DIR=/data/claude
      - CODEX_DATA_DIR=/data/codex
    volumes:
      - ~/.claude:/data/claude:ro
      - ~/.codex:/data/codex:ro
      - boss-data:/var/lib/boss
volumes:
  boss-data:
YAML
docker compose up -d
```

Replace `<boss-image>` with the image tag and `<boss-port>` with the port from the release page. Keep the `:ro` suffix — BOSS AI only reads transcripts, and a read-only mount makes it impossible for the container to corrupt an agent's session files.

**Why:** the two volume mounts are the only part of this file that connects BOSS AI to your token data. Everything else (image, port, environment variable names) comes from the release you downloaded — if your release documentation uses different variable names, change them there rather than guessing.

**Example:** after `docker compose up -d`, `docker compose logs --tail 20 boss-ai` shows the service starting, and `curl -s http://localhost:<boss-port>/ | head` returns HTML. The exact health path is release-specific — check the documentation.

**How to check:** `docker compose ps` lists the `boss-ai` service with status `Up` (and `(healthy)` if the release defines a health check). If the container exits immediately, read the reason with `docker compose logs boss-ai`.

## Step 3. Aggregate tokens per developer and cross-check the numbers
![Illustration: Step 3. Aggregate tokens per developer and cross-check the numbers](https://ai-release.org/guides/img/poshagovoe-rukovodstvo-kak-ustanovit-boss-ai-i-vesti-uc-en-3.jpg?v=1796222160)


**What to do:** save this collector as `usage_report.py` in `~/boss-ai` and run it.

```python
#!/usr/bin/env python3
"""Aggregate Codex + Claude Code token usage per user into one CSV."""
import argparse, csv, getpass, json, pathlib, time

COUNTERS = ("input_tokens", "output_tokens", "cache_creation_input_tokens",
            "cache_read_input_tokens", "cached_input_tokens", "total_tokens")

def collect(obj, totals):
    if isinstance(obj, dict):
        for key, value in obj.items():
            if key in COUNTERS and isinstance(value, int):
                totals[key] = totals.get(key, 0) + value
            else:
                collect(value, totals)
    elif isinstance(obj, list):
        for item in obj:
            collect(item, totals)

def scan(root, tool, cutoff, rows):
    root = pathlib.Path(root).expanduser()
    if not root.exists():
        return
    for path in root.rglob("*.jsonl"):
        if path.stat().st_mtime < cutoff:
            continue
        totals = {}
        with path.open(encoding="utf-8", errors="replace") as handle:
            for line in handle:
                line = line.strip()
                if not line:
                    continue
                try:
                    collect(json.loads(line), totals)
                except json.JSONDecodeError:
                    continue
        if totals:
            rows.append({"user": getpass.getuser(), "tool": tool,
                         "session": path.name,
                         **{k: totals.get(k, 0) for k in COUNTERS}})

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--days", type=int, default=7)
    parser.add_argument("--out", default="team-usage.csv")
    parser.add_argument("--claude-dir", default="~/.claude/projects")
    parser.add_argument("--codex-dir", default="~/.codex/sessions")
    args = parser.parse_args()

    cutoff = time.time() - args.days * 86400
    rows = []
    scan(args.claude_dir, "claude-code", cutoff, rows)
    scan(args.codex_dir, "codex", cutoff, rows)

    with open(args.out, "w", newline="", encoding="utf-8") as handle:
        writer = csv.DictWriter(handle, fieldnames=["user", "tool", "session", *COUNTERS])
        writer.writeheader()
        writer.writerows(rows)
    print(f"{len(rows)} sessions -> {args.out}")

if __name__ == "__main__":
    main()
```

Run it:

```bash
cd ~/boss-ai && python3 usage_report.py --days 7 --out team-usage.csv
head -n 3 team-usage.csv
```

**Example:** the shape of the file (your numbers will differ):

```
user,tool,session,input_tokens,output_tokens,cache_creation_input_tokens,cache_read_input_tokens,cached_input_tokens,total_tokens
alice,claude-code,9f3c1a2e-4b77-4d1e-9a55-0c1d2e3f4a5b.jsonl,1204,318,0,8192,0,0
alice,codex,rollout-2025-01-14T09-12-03.jsonl,2310,442,0,0,6144,0
```

The script reads counter keys by name, so it works even though Codex and Claude Code name their counters differently. That is why Step 1 asked you to inspect one raw line.

To produce the human-readable weekly summary:

```bash
python3 usage_report.py --days 7 --out team-usage.csv
python3 - <<'PY'
import csv, collections
totals = collections.defaultdict(lambda: collections.Counter())
with open("team-usage.csv", encoding="utf-8") as fh:
    for row in csv.DictReader(fh):
        for key in ("input_tokens", "output_tokens", "cache_read_input_tokens"):
            totals[(row["user"], row["tool"])][key] += int(row[key] or 0)
with open("team-usage.md", "w", encoding="utf-8") as out:
    out.write("| User | Tool | Input | Output | Cache read |\n|---|---|---|---|---|\n")
    for (user, tool), t in sorted(totals.items()):
        out.write(f"| {user} | {tool} | {t['input_tokens']} | {t['output_tokens']} | {t['cache_read_input_tokens']} |\n")
print(open("team-usage.md", encoding="utf-8").read())
PY
```

Wrap the two commands in a skill if you want teammates to run exactly the same thing instead of a copy-pasted shell history — see [How to Create a Claude Skill: Step-by-Step Guide](https://ai-release.org/guides/kak-sozdat-claude-skill-poshagovoe-rukovodstvo-po-svoim.html?utm_source=tg&utm_medium=channel&utm_campaign=guide_inline&utm_content=guide_to_guide).

**How to check:** open any Claude Code session in the same project and run `/cost` inside it. Compare the token numbers it reports against the newest `claude-code` row for today's date in `team-usage.csv`. They should be in the same range; a row of zeros means the transcript for that session is older than `--days` or lives under a different `HOME`.

## Troubleshooting

**Problem. The container refuses to start because the port is taken**

- Error: `Error response from daemon: driver failed programming external connectivity on endpoint boss-ai: Bind for 0.0.0.0:<boss-port> failed: port is already allocated`
- Cause: another process already listens on the port you mapped.
- Solution: find the owner with `lsof -i :<boss-port>` (or `ss -ltnp | grep <boss-port>`), then either stop that process or change the left side of the mapping in `docker-compose.yaml` to a free port, e.g. `"<boss-port>:<free-port>"`, and run `docker compose up -d` again.

**Problem. The collector finds nothing for a teammate**

- Error: `FileNotFoundError: [Errno 2] No such file or directory: '/root/.claude/projects'`
- Cause: the job runs as a different account (a root cron entry, or `sudo`) and therefore resolves `~` to the wrong home directory.
- Solution: run the collector as the developer's own user, or pass the paths explicitly: `python3 usage_report.py --claude-dir /home/alice/.claude/projects --codex-dir /home/alice/.codex/sessions --out alice-usage.csv`. If another account's home is unreadable, you will see `Permission denied: '/home/alice/.claude/projects'` — in that case each machine must export its CSV to the shared drive instead of one host reading every home directory.

**Problem. Rows appear but every counter is zero**

- Error: `docker compose logs boss-ai` shows `no usage events in <file>.jsonl`, or the CSV columns are `0`.
- Cause: the file was matched by extension but is not a session transcript (for example a cached prompt or index file written into the same tree), or the session records only user messages so far.
- Solution: open one file and confirm it contains a usage block: `grep -m1 -o '"usage"' ~/.claude/projects/*/*.jsonl`. If `grep` prints nothing, that file has no token data and the zero row is correct; re-run after the developer completes one assistant turn.

## Summary and next steps

BOSS AI now runs from Compose with read-only access to `~/.claude` and `~/.codex`, and `usage_report.py` produces `team-usage.csv` and `team-usage.md` covering every session from the last seven days. Next, schedule the collector weekly on each machine and push the CSV to a shared drive so one report covers the whole team.

## FAQ

**Does BOSS AI replace the `/cost` view inside Claude Code?**
No. `/cost` shows the current session only; BOSS AI and the collector aggregate transcripts across sessions and across both Codex and Claude Code, which is what a team report needs.

**Do cached input tokens count toward our spend?**
They are recorded in separate counters (`cache_read_input_tokens`, `cached_input_tokens`) precisely because they are billed differently from fresh input. Keep them as their own column and check the documentation for your plan's rates.

**Can one machine track the whole team?**
Only the sessions stored on that machine. Each teammate's transcripts live under their own home directory, so either run the collector on every machine and merge the CSVs, or export each developer's directory to a shared location first.

**What if a teammate uses a browser or IDE client with no local JSONL files?**
There is nothing on disk to parse. Check that client's documentation for a usage export and treat it as a separate data source; do not assume BOSS AI will see those sessions.
