Skip to Content
Getting started

Your first repository

Create a context repository, commit a fact, and read a historical snapshot.

Start the local CMP server with CMP_DEV_TOKEN exported.

Create a repository

curl -X POST http://127.0.0.1:8787/v1/repos \
  -H "Authorization: Bearer $CMP_DEV_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"id":"demo-project"}'

The response includes a head commit ID. Record it for your first write.

Commit knowledge

Every write includes the expected branch head so concurrent agents do not silently overwrite one another.

HEAD=$(curl -s http://127.0.0.1:8787/v1/repos/demo-project/head \
  -H "Authorization: Bearer $CMP_DEV_TOKEN" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).head")

curl -X POST http://127.0.0.1:8787/v1/repos/demo-project/commits \
  -H "Authorization: Bearer $CMP_DEV_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"branch\":\"main\",\"expectedHead\":\"$HEAD\",\"authorId\":\"developer\",\"message\":\"Add initial architecture decision\",\"changes\":[{\"op\":\"put\",\"record\":{\"id\":\"primary-storage\",\"kind\":\"decision\",\"status\":\"proposed\",\"content\":\"Use PostgreSQL for managed context storage\",\"sourceRefs\":[],\"authorId\":\"developer\",\"updatedAt\":\"2026-11-12T00:00:00Z\"}}]}"

Read a snapshot

curl "http://127.0.0.1:8787/v1/repos/demo-project/records?ref=main" \
  -H "Authorization: Bearer $CMP_DEV_TOKEN"

To read historical context, substitute main with a commit ID.

The current server stores statuses but does not independently verify the truth of an approved decision.

On this page