---
title: "PM CLI case study: context management for agents · Stefan Preu"
description: "How Stefan Preu built PM CLI: his role, four design decisions and their trade-offs, a reproducible agent handoff, lessons learned and honest limits."
url: https://preu.at/work/pm-cli
updated: 2026-12-05
---

# PM CLI

context that survives the session: goals, decisions and evidence kept in one shared record, where the next person or agent will look.

- install: `npm install -g @unbrained/pm-cli`
- version: 2026.12.5 · 5 Dec 2026
- license: MIT
- source: [github.com/unbraind/pm-cli](https://github.com/unbraind/pm-cli)
- docs: [pm-cli.unbrained.dev](https://pm-cli.unbrained.dev)

## the problem

agents start each session without memory of the last one. what usually survives is a task list: titles, maybe a status. a title doesn’t carry why the work exists, what was decided, what was ruled out or how anyone will know it’s done, so a fresh session re-derives it, guesses, or asks someone who might not remember.

so i treat project management as a context problem: tasks become useful when they’re connected to goals, decisions, evidence, history and the coordination between the people and agents doing the work.

## my role

i started PM CLI in february 2026, and i’m its designer and only human maintainer. coding agents do much of the implementation, and the commit history credits them as co-authors.

my part is the direction: what it’s for, the decisions below, and what counts as done.

- first commit: 17 feb 2026
- people: me, plus coding agents credited in the commits
- tracked in itself: 3,001 items, 69 of them decisions

[counted on 19 oct 2026 at 54a583c](https://github.com/unbraind/pm-cli/tree/54a583c1caa035fdc8bcc0301f27b8200c8a17ae/.agents/pm)

## decisions and trade-offs

### 1. plain files in any folder

- instead of: a server or a separate database
- because: any agent that can read files can use it, and in a git repo it travels with branches and pull requests, reviewed like code.
- trade-off: many writers need care: changes go through a journal and a workspace writer lock, and an append-only history, replayed with hash checks, catches drift.
- see: [src/sdk/item-transaction.ts @ 828edf4](https://github.com/unbraind/pm-cli/blob/828edf4ae71d27c28a103ca05cec87366d88a5fd/src/sdk/item-transaction.ts), [src/core/history/replay.ts @ 828edf4](https://github.com/unbraind/pm-cli/blob/828edf4ae71d27c28a103ca05cec87366d88a5fd/src/core/history/replay.ts)

### 2. context outside the harness

- instead of: the memory built into one model or agent tool
- because: i switch models and harnesses as they improve, and the goals, decisions and history shouldn’t stay behind. the same record is reachable from the command line, over MCP, in ChatGPT and in the browser.
- trade-off: nothing arrives by itself: an agent has to ask, and the record is only as good as what gets written down.
- see: [pm-mcp.unbrained.dev](https://pm-mcp.unbrained.dev), [pm-gpt.unbrained.dev](https://pm-gpt.unbrained.dev), [pm-web.unbrained.dev](https://pm-web.unbrained.dev)

### 3. a small vocabulary, extended from outside

- instead of: a dedicated feature for every workflow
- because: goals, items with acceptance criteria, decisions and typed links are parts that people and agents combine themselves. new behaviour goes into configuration, the SDK and separately published extensions, so nobody has to adopt a workflow they didn’t ask for.
- trade-off: the core is still more complex than i’d like, and every extension is one more package to keep current.
- see: [35 extension packages, live from npm](https://preu.at/work#group-pm-ecosystem)

### 4. context on request, within a budget

- instead of: loading everything, or a fixed summary
- because: too much context misleads an agent as surely as too little. it asks for the slice it needs within a token budget, and is told what was left out and how to get it.
- trade-off: the budget is PM CLI’s own estimate, not a model’s tokenizer count, and a ranking can leave out something that mattered. the omission receipt at least says so.
- see: [src/sdk/query/context.ts @ 828edf4](https://github.com/unbraind/pm-cli/blob/828edf4ae71d27c28a103ca05cec87366d88a5fd/src/sdk/query/context.ts)

## a reproducible handoff

what changes for the next session, shown on a synthetic project: two sessions that share nothing but the repository. session 1 records a goal, a decision and two tasks with acceptance criteria, one blocked by the other. session 2 starts cold.

1. **session 1 writes it down:** goal “CSV export for monthly reports”, decision “Stream CSV rows instead of building files in memory”, task “Streaming CSV endpoint” (in progress), task “Download button on the reports page” (blocked); plus a progress note and a linked file. then the session ends, and its memory with it.
2. **the repository keeps it as files:** `epics/rpt-l1pf.toon`, `decisions/rpt-gfhy.toon`, `tasks/rpt-5epo.toon`, `tasks/rpt-yzm4.toon`; plain text in .agents/pm, next to the code, each with an append-only history.
3. **session 2 starts cold and asks** with `pm context --for orient` and gets the same four items back; plus session 1’s last three actions, in 988 of 3,000 estimated tokens.

recorded transcript (pm 2026.10.18, 2026-10-18; verbatim output, trimmed only where marked “…”; the orientation pack was estimated at 988 tokens of a 3,000 budget):

```text
# # session 1 recorded a goal, a decision, two tasks (one blocked) and:
$ pm claim rpt-5epo --start
…
$ pm comments rpt-5epo --add "text=Endpoint streams via a cursor (see rpt-gfhy). Remaining: 409 for open months."
…
$ pm files rpt-5epo --add "path=src/reports/csv.ts,scope=project"
…
# # session 2: a fresh agent, nothing carried over
$ pm context --for orient --limit 5
summary:
…
  in_progress: 1
  blocked: 1
…
hierarchy[1]:
  - id: rpt-l1pf
    title: CSV export for monthly reports
…
    children[3]{id,title,type,status,children_total,children_closed}:
      rpt-5epo,Streaming CSV endpoint,Task,in_progress,0,0
      rpt-gfhy,Stream CSV rows instead of building files in memory,Decision,open,0,0
      rpt-yzm4,Download button on the reports page,Task,blocked,0,0
activity[3]{id,op,ts,author}:
  rpt-5epo,release,"2026-10-18T19:03:01.720Z",session-1
  rpt-5epo,files_add,"2026-10-18T19:02:56.447Z",session-1
  rpt-5epo,comment_add,"2026-10-18T19:02:51.788Z",session-1
blockers[1]{id,title,blocked_by,blocked_by_title,blocked_by_status}:
  rpt-yzm4,Download button on the reports page,rpt-5epo,Streaming CSV endpoint,in_progress
…
  token_budget: 3000
…
  estimated_tokens: 988
  within_budget: true
$ pm get rpt-5epo
item:
  id: "rpt-5epo"
  title: "Streaming CSV endpoint"
…
  status: "in_progress"
…
  acceptance_criteria: "GET /reports/:month.csv streams rows with a header line; Open months return 409 with an explanation"
  parent: "rpt-l1pf"
…
linked:
  files[1]{path,scope}:
    src/reports/csv.ts,project
claim_state:
  claimed: false
…
omission_receipt:
  has_omissions: true
…
    comments,"--fields comments"
```

the script creates a throwaway repository, turns telemetry off and prints the transcript. run it yourself with PM CLI installed:

```sh
curl -fsSLO https://preu.at/case-study/pm-handoff.sh && bash pm-handoff.sh
```

read it first: [pm-handoff.sh](https://preu.at/case-study/pm-handoff.sh)

## what i learned

### use it on itself

PM CLI’s own development runs on PM CLI: 3,001 items in its public repository, 69 of them decisions. the agents working on it hit the same friction as anyone else, and that friction becomes the next items.

[its .agents/pm folder](https://github.com/unbraind/pm-cli/tree/54a583c1caa035fdc8bcc0301f27b8200c8a17ae/.agents/pm)

### move instructions into the tool

in may i cut the repository’s agent guide from 487 to 108 lines. exact flags now come from the installed version itself (pm <command> --help --json), so agents read them from the version they actually run.

[the commit, 8546f58](https://github.com/unbraind/pm-cli/commit/8546f586dbb7db42eb07ff3bc4792be82720f4cc)

### simplify by moving, not removing

when the core gets heavy, behaviour moves into configuration and reusable SDK pieces instead of being deleted, so the people who rely on it keep it.

[the SDK guide](https://github.com/unbraind/pm-cli/blob/54a583c1caa035fdc8bcc0301f27b8200c8a17ae/docs/SDK.md)

## what this doesn’t show

**measured scope:** one synthetic project, one machine, one run. it shows that recorded context is returned to a cold session in a bounded, inspectable form.

- it doesn’t measure whether agents finish work faster or better with it, or how many tokens it saves overall.
- it says nothing about large teams, very large trackers or many agents writing concurrently.
- acceptance criteria describe the intended outcome; they are not proof the outcome was reached. that still takes tests, review and evidence.
- the token figure is PM CLI’s own estimate, not a tokenizer count for a specific model.
- the counts above describe one repository at one commit. they show activity, not quality.

## try it

ask your agent to set it up for your project and see how it fits your existing workflow, rather than copying someone else’s setup.

```sh
npm install -g @unbrained/pm-cli
```

[source on GitHub](https://github.com/unbraind/pm-cli) · [package on npm](https://www.npmjs.com/package/@unbrained/pm-cli)

### PM CLI on the web

documentation, the package list and hosted ways to reach the same project record.

- [website and docs](https://pm-cli.unbrained.dev): guides, reference and every published package.
- [pm-web](https://pm-web.unbrained.dev): browse, search and manage pm projects in the browser.
- [pm-mcp](https://pm-mcp.unbrained.dev): connect agents and IDEs over remote MCP and OAuth.
- [pm-gpt](https://pm-gpt.unbrained.dev): work with pm projects in ChatGPT and Codex.
- [pm-search](https://pm-search.unbrained.dev): find decisions, tasks and fixes in public repositories’ pm items, with commit-pinned links.

working on context for your own agents? tell me what you have in mind. [get in touch](https://preu.at/contact)

---

[preu.at](https://preu.at/) · Stefan Preu, agentic systems architect, based in austria · [every page for agents](https://preu.at/llms.txt) · this page in a browser: https://preu.at/work/pm-cli
