Project-owned, team-shareable experience governance for coding agents.
expcap turns useful agent work into evidence-backed engineering assets that
belong to the project, not to one person, one machine, or one model account.
Ready-to-use Codex skill: skills/expcap/SKILL.md.
One-command local setup:
git clone <repo-url>
cd agent-experience-capitalization
scripts/codex-skill-quickstartThis installs the skill into ~/.codex/skills/expcap, installs the runtime with
Milvus Lite support, enables the current project, and runs doctor so you can
verify the setup immediately.
By default the installed project is marked active, which means agent
workflows treat it as an active project in reporting. For dormant or archived
projects, install with EXPCAP_PROJECT_STATUS=inactive so the project keeps the
skill and storage contract but is counted separately in reporting and coverage
analysis.
Personal memory helps one agent remember one user. Teams need something different: engineering experience that can move with the codebase, stay tied to recoverable evidence, and remain governable over time.
expcap is a fault-tolerant experience governance layer for coding agents.
It is designed for:
- project-level rules, patterns, context, and checklists;
- team-shareable assets that can be reviewed and delivered;
- agent workflows that get context before work and create governed candidates after work;
- local-first development with a path to shared cloud backends.
It is not a memory-consolidation pile. Raw traces remain first-class evidence; LLM consolidation creates candidates rather than truth; promoted assets stay scoped, reviewable, and feedback-governed.
- Activates relevant project experience at the start of a task.
- Returns sourced candidates so the LLM can decide whether each asset applies.
- Converts completed work into
trace -> episode -> candidate -> asset. - Tracks whether activated experience actually helped.
- Maintains candidate review queues and asset health signals.
- Uses Milvus as the core semantic retrieval layer; SQLite remains a lightweight state index and fallback.
- Exposes a backend contract for shared object stores, cloud state indexes, and hosted vector search.
expcap is designed to avoid the naive pattern of repeatedly compressing old
memories into new abstract memories until drift accumulates.
Core rules:
- Raw trace is never replaced by abstraction.
- Consolidation creates candidates, not truth.
- Promotion requires evidence, review, and scope.
- Retrieval returns sourced candidates, not commands.
- Activated assets must receive feedback, decay, or quarantine.
- Cross-task contamination should be prevented by default.
- Abstractions must remain grounded in recoverable evidence.
One-line positioning:
expcapis not a memory-consolidation pile. It is a fault-tolerant experience governance layer for coding agents.
expcap works best as the dynamic layer beneath project-level prompt files,
not as a replacement for them.
PROJECT_PROMPT.md: host-neutral stable project rules that should apply every session across hosts.AGENTS.md: primary project entrypoint for agent instructions.AGENTS.expcap.md: dynamicget/saveintegration layer installed byexpcap install-project.
The intended flow is: discover experience in expcap, prove it through real
task activations, then promote the small stable subset into project-level prompt
files.
Maintenance then stays host-neutral:
- edit stable rules in
PROJECT_PROMPT.md - use
expcap project-prompt suggestto find assets worth promoting - use
expcap project-prompt apply --sync-afterto write promoted rules into the managed block and refresh host bridge files - use
expcap project-prompt archive --sync-afterto retire stale promoted rules with a traceable archive reason and refresh host bridge files - use
expcap project-prompt syncto refresh host bridge files such asAGENTS.mdandCLAUDE.md
Use the one-command setup above for Codex. Manual setup:
git clone <repo-url>
cd agent-experience-capitalization
python3 -m venv .venv
. .venv/bin/activate
.venv/bin/pip install -e ".[milvus]"
scripts/install-codex-skill
scripts/expcap --helpMilvus Lite is installed by default above because Milvus is the core semantic retrieval layer:
scripts/expcap sync-milvus --workspace "$PWD" --include-shared
scripts/expcap benchmark-milvus --workspace "$PWD" --sample-size 5 --limit 3The recommended entrypoint is the Codex skill in
skills/expcap/SKILL.md. Install it once, then let the agent run the workflow
through the skill instead of making every user memorize CLI commands.
Use centralized local storage for short-cycle testing:
export EXPCAP_STORAGE_PROFILE=user-cache
export EXPCAP_HOME="$HOME/.expcap"The default embedding provider is zero-config hash. To test real OpenAI
embeddings while keeping the current Milvus Lite collection compatible, start
with 128 dimensions:
export EXPCAP_EMBEDDING_PROVIDER=openai
export OPENAI_API_KEY="..."
export EXPCAP_OPENAI_EMBEDDING_MODEL=text-embedding-3-small
export EXPCAP_OPENAI_EMBEDDING_DIM=128If no API key is present, expcap falls back to hash and reports that fallback
in status / doctor.
Milvus Lite indexes are namespaced by embedding profile, for example
hash-token-sha256-signhash-128 or openai-text-embedding-3-small-128, so
different providers and dimensions do not share the same local DB file.
Start a task by activating relevant experience:
expcap auto-start --task "fix pytest import error" --workspace "$PWD"Finish a task by saving the reusable lesson:
expcap auto-finish \
--task "fix pytest import error" \
--workspace "$PWD" \
--command "python3 -m unittest discover -s tests -v" \
--verification-status passed \
--verification-summary "tests passed" \
--result-status success \
--result-summary "fixed import path"Check the loop:
expcap status --workspace "$PWD"
expcap doctor --workspace "$PWD"
expcap dashboard --workspace "$PWD"Open the local dashboard in a browser on macOS:
DASHBOARD_PATH="$(
EXPCAP_STORAGE_PROFILE=user-cache EXPCAP_HOME="$HOME/.expcap" \
expcap dashboard --workspace "$PWD" |
python3 -c 'import json, sys; print(json.load(sys.stdin)["saved_to"])'
)"
open "$DASHBOARD_PATH"On Linux, use xdg-open "$DASHBOARD_PATH" instead of open. The dashboard is
a static local HTML file; no background web server is required.
Runtime data is written to $EXPCAP_HOME with the recommended user-cache
profile. Keep .agent-memory/ out of source control for explicit project-local
testing.
Install expcap into another project:
scripts/expcap install-project --workspace /path/to/projectAlso update CLAUDE.md:
scripts/expcap install-project --workspace /path/to/project --include-claudeInstall Claude hooks (Phase 1 runnable integration):
scripts/expcap install-project --workspace /path/to/project --integration-mode claude-hooksInstall Codex hooks as the preferred host adapter:
scripts/expcap install-project --workspace /path/to/project --integration-mode codex-hooksThe installer appends non-destructive instructions and creates
AGENTS.expcap.md. It also ensures PROJECT_PROMPT.md exists as the
host-neutral stable rule source and that .agent-memory/ is present in
.gitignore. In codex-hooks mode it writes .codex/hooks.json plus
.codex/hooks/expcap_user_prompt_submit.sh and .codex/hooks/expcap_stop.sh.
These wrappers route Codex UserPromptSubmit / Stop events to
scripts/expcap-hook with the default user-cache storage profile. If your
Codex build only reads the user-level ~/.codex/hooks.json, merge the generated
project .codex/hooks.json entries into the user-level file. In claude-hooks
mode it additionally writes
.claude/settings.json plus hook scripts under .claude/hooks/, all routed
through scripts/expcap-hook to call auto-start / auto-finish. Agents can
then use the skill-backed default workflow:
expcap auto-start --task "your task" --workspace "$PWD"
expcap progressive-recall \
--task "your task" \
--workspace "$PWD" \
--message "new error, file scope, or phase change"
expcap feedback \
--workspace "$PWD" \
--activation-id "<activation id>" \
--help-signal supported_strong
expcap auto-finish --task "your task" --workspace "$PWD" --verification-status passed --result-status successUse progressive-recall only when the conversation meaningfully changes:
new errors, new files/modules, topic drift, or phase changes such as
discussion -> implementation -> test -> fix. It applies a cooldown and returns
only delta assets that were not already activated recently.
Use feedback after validating whether an activation actually helped. It
records the help signal on the activation and refreshes linked assets'
temperature and review status.
For manual debugging, the lower-level pipeline is still available:
ingest -> review -> extract -> promote -> activate.
To import project docs as faithful codemap/context assets for LLM recall:
expcap ingest-docs --workspace "$PWD"By default this scans README*, AGENTS.md, CLAUDE.md, and docs/*.md,
then stores chunks as knowledge_kind=codemap assets. It preserves source text
instead of rewriting docs into polished "truth".
To intentionally save a sparse top-level prior:
expcap save-prior \
--workspace "$PWD" \
--knowledge-kind dont_repeat \
--title "Do not re-explain the project memory thesis" \
--content "expcap is a local-prior layer for saving repeated user/team/project context, not a truth-only knowledge base."Use this for explicit, durable preferences, constraints, historical decisions,
or "do not make me repeat this" instructions. High-priority priors are saved as
active project assets so the injection policy can route small stable items into
system_prompt. During activation, explicit high-priority priors also join a
small always-considered prior pool, so they are not lost just because Milvus
top-K retrieval favored older semantic matches.
Active-project control:
scripts/expcap install-project --workspace /path/to/project --project-status active
scripts/expcap install-project --workspace /path/to/project --project-status inactiveNew chat still runs auto-start in both cases. active and inactive are
reporting labels so coverage and daily review can focus on genuinely active
projects instead of every installed repository.
trace: raw task evidence.episode: reviewed task narrative.candidate: reusable lesson proposed from an episode.asset: promoted project/team experience asset.activation: selected assets injected into a future task.feedback: whether activation helped.
Promotion ladder:
trace -> episode -> candidate -> project asset -> team asset -> organization asset
Each step upward should require stronger evidence, clearer scope, and stricter review.
Activation views include source_provenance, match_evidence, risk_flags,
and llm_use_guidance. Retrieval provides sourced candidates; the coding agent
is still responsible for deciding whether an asset fits the current task.
Activation views also include an injection_plan that separates retrieval from
injection. The injection architecture has three layers:
task_start_runtime_injection: task input augmentation atSessionStart,UserPromptSubmit, andauto-start.system_prompt_injection: durable project-level prompt material intended forAGENTS.md/AGENTS.expcap.md.continuous_runtime_recall_injection: event-driven recall during a conversation, primarily throughprogressive-recall.
For compatibility, runtime payloads still expose the legacy system_prompt,
runtime_context, and reference_summary channel fields; those channels map
onto the three injection layers above.
Each auto-start / activate call also materializes the plan as host-friendly
artifacts under the project memory root:
injections/<activation_id>.mdinjections/<activation_id>.jsoninjections/latest.mdinjections/latest.json
These files are runtime artifacts in $EXPCAP_HOME (or .agent-memory/ only
when using the local profile). Claude hooks use the rendered Markdown as
additionalContext; other hosts can read latest.md or latest.json directly.
Assets carry scope and lifecycle metadata:
knowledge_scope: currentlyprojectorcross-project; futureteamandorganizationscopes should require stricter promotion gates.knowledge_kind:pattern,anti_pattern,rule,context,checklist,past_win,preference,constraint,decision_memory,dont_repeat, orcodemap.temperature:hot,warm,neutral, orcool.review_status:healthy,watch,needs_review, orunproven.
Recommended memory/governance levels:
personal / local prior: local preferences, working style, and dont-repeat context that should not silently pollute shared knowledge.project asset: the default level for repository-specific rules, decisions, patterns, and pitfalls.team asset: cross-project experience with explicit owner, evidence, and review.organization asset: stable company-wide knowledge with version, validity window, and deprecation rules.
Assets are project-owned even when the data source is shared. The project keeps identity and ownership metadata; storage can be local, user-level, or remote.
Storage profiles:
local: runtime data lives in the project.agent-memory/directory.user-cache: runtime data lives underEXPCAP_HOMEand stays out of the project directory.shared: source of truth, state, and retrieval are expected to be shared backends.hybrid: shared source/retrieval with a local cache and SQLite state index.
Recommended default for agent workflows:
export EXPCAP_STORAGE_PROFILE=user-cache
export EXPCAP_HOME="$HOME/.expcap"This keeps runtime data out of the project directory while preserving project-owned asset identity.
Storage responsibilities are intentionally split:
Evidence Store: the recoverable source of truth for raw traces, task input, tool calls, diffs, test results, error logs, activation views, and user feedback. In local mode this is JSON / JSONL / logs under the runtime root; in team mode it should evolve toward object storage.Curated Markdown Memory: stable human-readable rules and prompts such asPROJECT_PROMPT.md,AGENTS.md,AGENTS.expcap.md, curated memory docs, and reviewed codemap/docs material.Governance DB: lifecycle, state, and relationship management for traces, episodes, candidates, assets, activations, review queues, temperature, and promotion/deprecation history. Today this is SQLite locally; team mode should evolve toward Postgres / Cloud SQL.Semantic Retrieval Layer: embeddings plus metadata filters for finding relevant candidates and assets. Today this is Milvus Lite or hosted Milvus.
One-line boundary:
- Milvus is for retrieval, not truth.
- SQLite is for governance, not semantic understanding.
- Markdown is for reviewability, not large-scale recall.
- Evidence files/logs are the recoverable source of truth.
Explicit local profile:
- JSON files are the source of truth.
- Milvus Lite is the local core semantic retrieval layer.
- SQLite stores lightweight state, review decisions, activation logs, and fallback metadata indexes.
To force project-local storage:
export EXPCAP_STORAGE_PROFILE=localShared mode uses the same asset contract:
export EXPCAP_STORAGE_PROFILE=shared
export EXPCAP_SOURCE_OF_TRUTH_BACKEND=object-storage
export EXPCAP_STATE_INDEX_BACKEND=cloud-sql
export EXPCAP_RETRIEVAL_BACKEND=milvus
export EXPCAP_SHARING_BACKEND=cloud-shared
export EXPCAP_PROJECT_ID=github:org/repo
export EXPCAP_OWNING_TEAM=agent-platform
export EXPCAP_ASSET_STORE_URI=s3://bucket/expcap/assets
export EXPCAP_STATE_INDEX_URI=postgres://expcap
export EXPCAP_RETRIEVAL_INDEX_URI=https://milvus.example.com
export EXPCAP_SHARED_ASSET_STORE_URI=s3://bucket/expcap/sharedHosted Milvus is connectable today. When EXPCAP_RETRIEVAL_BACKEND=milvus and
EXPCAP_RETRIEVAL_INDEX_URI are set, expcap uses that remote Milvus endpoint
instead of a local Milvus Lite DB:
export EXPCAP_RETRIEVAL_BACKEND=milvus
export EXPCAP_RETRIEVAL_INDEX_URI=https://milvus.example.com
export EXPCAP_RETRIEVAL_INDEX_TOKEN="..."
export EXPCAP_MILVUS_DB_NAME=expcap
export EXPCAP_MILVUS_COLLECTION=experience_assetsEXPCAP_RETRIEVAL_INDEX_TOKEN, EXPCAP_MILVUS_DB_NAME, and
EXPCAP_MILVUS_COLLECTION are optional. Object storage and cloud SQL remain
backend-contract fields until their adapters are implemented; the product model
does not change when those adapters are added.
Semantic retrieval items should always stay traceable back to recoverable source bodies. Milvus can point at trace summaries, episodes, assets, or codemap chunks, but it should never become the only surviving copy of the memory.
Use status for short-cycle evaluation:
expcap status --workspace "$PWD"Use doctor when you need actionable diagnostics:
expcap doctor --workspace "$PWD"
expcap benchmark-milvus --workspace "$PWD" --sample-size 5 --limit 3 --include-sharedUse dashboard when you want a local read-only view of assets, activation
quality, retrieval contribution, candidate review queues, and write frequency:
expcap dashboard --workspace "$PWD"The command writes dashboard.html plus a JSON sidecar under the workspace
review directory for the active storage profile. With the recommended
user-cache profile this lives under $EXPCAP_HOME, not inside the project.
Copy the printed saved_to path into a browser, or use the macOS one-liner in
Quickstart to generate and open it directly.
benchmark-milvus pre-syncs the active embedding-profile Milvus index before
querying, so profile switches do not look like retrieval failures. If the
Milvus runtime is unavailable, the benchmark reports that state clearly and can
use a marked state-index fallback for expectation diagnostics.
For codemap/doc recall checks, add expectations:
expcap benchmark-milvus \
--workspace "$PWD" \
--query "README ingest-docs codemap" \
--expect-kind codemapWatch these fields:
activation_feedback_summary: helped, pending, or stale missing feedback.feedback_cleanup: stale unresolved activations that were auto-closed asunclearso metrics stay usable.candidate_review_queue: candidates that need human review.asset_effectiveness_summary: asset temperature and review health.retrieval_backends: Milvus core retrieval readiness and SQLite lightweight index health.milvus_benchmark: sampled Milvus retrieval quality, including provider metadata, top scores, and historical selected-asset hit rate.injection_policy_summary: whether recent activation plans are routing items intosystem_prompt,runtime_context, orreference_summary.project_activity: whether the workspace isactiveorinactivefor reporting and coverage analysis.backend_configuration: active local/shareable backend profile.
Milvus is the core retrieval capability. If Milvus Lite is locked or
unavailable, the runtime should degrade to JSON/SQLite so work can continue, but
doctor should surface the degradation clearly because retrieval quality is
reduced. doctor also reports Milvus lock metadata and safe recovery
recommendations.
The current implementation already supports several anti-faulty-memory mechanisms:
- Raw trace retention: traces, episodes, activation views, and feedback remain first-class persisted objects.
- Candidate quarantine by default: task summaries land in
candidatefirst and promoted assets still carryunproven/watch/needs_reviewlifecycle states. - Activation provenance: selected assets include
source_provenance,match_evidence,risk_flags, andllm_use_guidance. - Feedback-driven health: activation feedback updates
temperatureandreview_status. - Progressive recall gating:
progressive-recallis explicitly reserved for new errors, files/modules, phase changes, or topic drift.
The current implementation is easy to extend but not complete yet in these areas:
- richer scope tagging such as module, language, framework, task type, applicable conditions, and known counterexamples;
- explicit quarantine / deprecation / validity-window fields in the governance DB;
- replay-based validation for important assets;
- conflict detection and conflict-aware injection suppression;
- stricter promotion rails for future
teamandorganizationassets.
This project is pre-1.0. The current goal is to validate the experience asset model, local runtime, activation feedback loop, and storage contract before expanding the cloud backend surface.
Run tests:
python3 -m unittest discover -s tests -vApache-2.0. See LICENSE.