State-first MCP engine for Claude Code and Codex. Keep project truth in files, generate tiny startup briefs, and stop replaying long chat history.
Minimal file-based state engine for agent workflows. Instead of replaying long chat history, it stores the current project state in structured JSON and generates a compact session brief.
Benchmarked on the bundled sample workspace:
5626tokens for a full state replay vs146tokens for session startup with the compact brief. That is a measured97.4%reduction in startup context size.
Release status: the repository is prepared for
v1.0.0. Public npm publish and the first GitHub Release still need maintainer credentials and package-name availability.
Current install path:
npm install -g github:dumancode/project-state-engineThat gives you two commands anywhere on your machine:
project-stateproject-state-mcp
When the npm package is published, this becomes:
npm install -g project-state-engineThe repository ships with a committed demo-workspace/ so you can try the real CLI and MCP workflow immediately.
Generate the sample startup brief:
npm run demo:briefRun the real MCP SDK client example against the bundled workspace:
npm run demo:mcp-workflowThis is the fastest way to answer the important question: "How would another agent or app actually use this?"
The MCP workflow example runs against a temporary working copy, so the committed demo-workspace/ stays clean.
If you want to use the engine as an MCP server, the global install above makes setup copy-paste simple.
Claude Code:
claude mcp add project-state -- project-state-mcpCodex:
codex mcp add project-state -- project-state-mcpInitialize state in the project you actually work on:
project-state init --root /absolute/path/to/your-project --project your-projectIf you want to post this to Hacker News, Reddit, Product Hunt, or X, ready-to-edit launch copy lives here:
Without Project State Engine, a new session often starts like this:
We are building a Next.js app with a FastAPI backend.
JWT auth is active.
Refresh token work is still open.
Before merging we always run tests.
The current blocker is rate limiting.
Yesterday we changed the login flow...
That kind of handoff grows fast, and teams usually keep rewriting it.
With Project State Engine:
project-state session-brief --root /absolute/path/to/your-projectOr from your MCP client, use:
- prompt:
start-session-from-state - tool:
session_brief
On the bundled sample workspace, that startup handoff drops from 5626 tokens to 146.
Most memory tools are trying to remember everything the model touched.
This project is trying to keep only the current project truth small and sharp:
- what is active
- what changed
- what is risky
- what should happen next
That is why the README, dashboard, and MCP prompts all orbit the same thing: a tiny, deterministic startup handoff for Claude Code or Codex.
- solo developers using Claude Code or Codex on the same repo for days or weeks
- vibe coders who keep re-explaining the same project state every morning
- freelancers and small teams who want project truth in Git instead of hidden chat history
- agent workflows that need a compact, deterministic startup brief
- one-off scripts you finish in a single short session
- users who want a full autonomous memory graph of everything ever said
- teams that prefer opaque hosted memory over explicit file-based state
- workflows where replaying the whole chat is acceptable and token cost is irrelevant
Most agent memory projects store too much conversation and then spend tokens searching through it. This project takes a different approach: treat the project as a small, structured state machine.
The goal is not "remember everything." The goal is "start the next session with the smallest useful brief."
- Source of truth is the filesystem
- State is explicit and typed
- Session startup reads
current-state.json, not long chat history - Retrieval is narrow and intentional
This is a better fit when you care about:
- lower token usage
- clearer project continuity
- team-readable state in Git
- fewer hidden side effects than automatic memory systems
The repo now ships a repeatable token benchmark. On the bundled sample workspace, replaying the full stored state and history costs 5626 tokens. The compact prompt surfaces are much smaller:
| Scenario | Tokens | Reduction |
|---|---|---|
| Full state replay baseline | 5626 | 0% |
start-session-from-state prompt |
146 | 97.4% |
implementation-plan-from-state prompt |
447 | 92.1% |
release-checklist-from-state prompt |
686 | 87.8% |
This means the current sample benchmark shows roughly 97% lower startup context cost when using the brief instead of replaying the whole state dump.
Quick read:
- session startup drops from
5626to146tokens - implementation planning drops from
5626to447tokens - release checklist generation drops from
5626to686tokens
Run the benchmark yourself:
npm run benchmark:tokensLatest generated artifacts:
Method note: this is a bundled sample benchmark, not a universal guarantee. Real savings will vary by how much state you store and how aggressively you retrieve it.
- Stores project state as JSON under
.project-state/ - Tracks
decision,rule,goal,task,risk, andsession_summary - Rebuilds
current-state.jsonafter every write - Produces a compact session brief for token-efficient restarts
- Exposes the same engine as an MCP stdio server
- Validates structured writes before they hit disk
- Flags stale records and weak handoffs with
state_doctor - Adds lightweight search across stored state
- Adds append-only history tracking with changed-field diffs
- Exposes current state and records as MCP resources
- Ships reusable MCP prompts for session kickoff, planning, review, triage, refactors, and releases
- Adds markdown exports and an HTML state dashboard
Classic "memory" systems often optimize for recall:
- what was said
- what was tried
- what the agent saw
This project optimizes for execution:
- what is currently true
- what matters right now
- what the next step should be
That makes the startup context smaller, more stable, and easier to version in Git.
.project-state/
decisions/
rules/
goals/
tasks/
risks/
sessions/
current-state.json
index.json
If you prefer running from source instead of the one-command global install:
cd project-state-engine
npm install
npm run buildRun commands directly from the built output:
node dist/cli.js init --root ./demo-workspace --project demo-workspaceOr link the package locally once and use the short commands everywhere:
npm linkInitialize a project state directory in any target workspace:
project-state init --root ./demo-workspace --project demo-workspaceCapture a decision:
project-state state-capture \
--root ./demo-workspace \
--type decision \
--title "Use JWT auth with rotating refresh tokens" \
--summary "JWT was chosen over server-side sessions for portability and cleaner release rollbacks." \
--tags auth,backend \
--content '{"problem":"Choose an auth approach for the public API","decision":"JWT with rotating refresh tokens","reasoning":["Stateless API requests","Cleaner multi-client support"]}'List open tasks:
project-state state-list --root ./demo-workspace --type task --status openSearch state:
project-state state-search --root ./demo-workspace --query "jwt auth"Inspect recent history:
project-state history-list --root ./demo-workspace --limit 10Generate a resource URI:
project-state resource-uri --root ./demo-workspace --kind current-stateRender a markdown brief:
project-state markdown-brief --root ./demo-workspaceRender a markdown history timeline:
project-state history-markdown --root ./demo-workspaceExport every markdown view in one shot:
project-state export-markdown-views --root ./demo-workspaceRun a state health check:
project-state state-doctor --root ./demo-workspaceGenerate a dashboard:
project-state dashboard-html --root ./demo-workspaceGenerate a brief:
project-state session-brief --root ./demo-workspaceClose a session:
project-state session-close \
--root ./demo-workspace \
--what-changed '["Captured the release handoff and open auth risk"]' \
--open-loops '["Refresh token revoke behavior still needs staging verification"]' \
--next-step "Generate the release checklist and capture rollback steps"initstate-capturestate-liststate-searchhistory-liststate-updatesession-briefsession-closestate-doctordoctor-markdownmarkdown-briefhistory-markdownexport-markdown-viewsdashboard-htmlresource-urimcp
- MCP setup and daily workflow:
docs/MCP_GUIDE.md - Example MCP config:
docs/mcp-config.example.json - Launch and marketing copy:
docs/LAUNCH_COPY.md - Release hygiene:
docs/RELEASE.md - Changelog:
CHANGELOG.md - Demo workspace:
demo-workspace/
Run the stdio MCP server:
project-state-mcpOr through the CLI:
project-state mcpSuggested MCP config:
{
"mcpServers": {
"project-state": {
"command": "project-state-mcp"
}
}
}Available MCP tools:
state_doctorstate_initstate_capturestate_liststate_searchstate_historystate_updatesession_briefsession_close
Available MCP resources:
project-state://workspace/{workspace}/historyproject-state://workspace/{workspace}/history.mdproject-state://workspace/{workspace}/doctorproject-state://workspace/{workspace}/doctor.mdproject-state://workspace/{workspace}/dashboard.htmlproject-state://workspace/{workspace}/indexproject-state://workspace/{workspace}/current-stateproject-state://workspace/{workspace}/open-tasksproject-state://workspace/{workspace}/session-briefproject-state://workspace/{workspace}/session-brief.mdproject-state://workspace/{workspace}/records/{id}
Use URL-encoded absolute workspace paths in the {workspace} slot. The CLI can generate these URIs for you.
Available MCP prompts:
start-session-from-statetask-context-from-stateimplementation-plan-from-staterefactor-plan-from-statesprint-planning-from-statecode-review-from-statebugfix-from-statebug-triage-from-staterelease-checklist-from-state
A real SDK client example is included at src/examples/mcp-client-workflow.ts.
Run it against any workspace:
npm run example:mcp-workflow -- ./demo-workspaceThe example does four things through the MCP protocol:
- connects to the local stdio server with the official MCP SDK client
- initializes project state and captures a couple of records
- calls the
session_brieftool - fetches the
release-checklist-from-stateprompt and thesession-brief.mdresource
This gives you a concrete end-to-end example of how another app or agent could use the server. The example copies the requested workspace into a temporary directory first, so it can safely create example records without mutating your checked-in files.
state_doctor inspects your project state for issues that make future sessions worse:
- stale active records
- open tasks without
content.next_action - in-progress goals without linked tasks
- duplicate active titles
- active risks without mitigation
- weak
current-state.jsonhandoff signals
Use it before releases, after long idle periods, or when the brief starts feeling unreliable.
dashboard-html generates a lightweight HTML dashboard that combines:
- current focus and next step
- record counts
- open tasks
- recent history
- state doctor findings
The same dashboard is also exposed as an MCP resource:
project-state://workspace/{workspace}/dashboard.html
Local maintenance scripts:
npm run lint
npm run checkCI runs on GitHub Actions and executes lint, typecheck, tests, and the bundled token benchmark on pushes and pull requests.
A token benchmark example is included at src/examples/token-benchmark.ts. It seeds a sample workspace, measures tokens with gpt-tokenizer, and writes the latest report into benchmark-results/.
{
"brief": {
"project": "demo-workspace",
"active_decisions": ["Use JWT access tokens with rotating refresh tokens"],
"current_focus": "Draft release notes",
"next_step": "Generate the release checklist and capture rollback steps"
},
"brief_text": "Project: demo-workspace\nCurrent focus: Draft release notes\nNext step: Generate the release checklist and capture rollback steps\nActive decisions: Use JWT access tokens with rotating refresh tokens"
}- Source of truth is the filesystem, not a database.
current-state.jsonis the main artifact for session startup.contentandpatcharguments are JSON strings.events.jsonlstores append-only history withchanged_fieldsand before/after values for updates.
- public npm release and the first tagged GitHub Release
- multi-workspace rollup views for people juggling several active repos
- richer dashboard UX beyond the static HTML export
- editor integrations such as a VS Code sidebar or companion extension
- optional hosted sync or team-sharing adapters that keep file-based state as the source of truth


