一键导入
decision-trace
Record why the agent changed something, what evidence was used, and what assumptions were made — so code reviews become much faster.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Record why the agent changed something, what evidence was used, and what assumptions were made — so code reviews become much faster.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | decision-trace |
| description | Record why the agent changed something, what evidence was used, and what assumptions were made — so code reviews become much faster. |
| origin | FlowDeck |
Every non-trivial edit should be recorded in .codebase/DECISIONS.jsonl. This creates an append-only audit trail that makes code review and debugging faster.
Record when:
Use the decision-trace tool:
{
"action": "record",
"entry": {
"id": "auth-refactor-2024-05-01",
"file_path": "src/services/auth.ts",
"change_type": "edit",
"rationale": "Refactored token validation to use constant-time comparison to prevent timing attacks",
"evidence": [
"OWASP: timing attacks on string comparison",
"Prior failure: auth-timing-2024-03 in FAILURES.json"
],
"assumptions": [
"Token format remains base64-encoded JWT",
"Redis cache is available for token blacklist"
],
"alternatives_considered": [
"Keep string comparison (rejected: timing attack risk)",
"Move validation to edge (rejected: adds latency)"
],
"risk_level": "medium",
"agent": "backend-coder"
}
}
The decision-trace-hook auto-records a minimal entry for every write/edit. The full entry (with rationale, evidence, assumptions) should be added by the agent explicitly using the tool above.
// Get all decisions for a file
{ "action": "get_for_file", "file_path": "src/services/auth.ts" }
// Get all high-risk decisions
{ "action": "query", "query": { "risk_level": "high", "limit": 10 } }
Decisions are not static. They change as requirements shift, new evidence appears, or better alternatives emerge. Track the full lifecycle:
alternatives_consideredList every option evaluated and why it was rejected or accepted. This prevents re-litigating old choices.
"alternatives_considered": [
"Use PostgreSQL full-text search (rejected: poor ranking for our use case)",
"Add Elasticsearch (rejected: operational overhead exceeds benefit)",
"Hybrid: Postgres for exact match, in-memory trie for prefix (accepted: best latency/cost tradeoff)"
]
superseded_byWhen a later decision replaces this one, link forward. This keeps the ledger from becoming stale.
{
"id": "cache-strategy-v1",
"superseded_by": "cache-strategy-v2",
"rationale": "Initial Redis caching for user sessions"
}
When querying, always check if an entry has superseded_by set. If it does, read the newer decision instead.
evidenceLink to anything that supports the decision:
.codebase/FAILURES.json that motivated the fixEvidence must be checkable. "I think this is faster" is not evidence. A benchmark output is.
confidence_levelRate how certain you are that this decision will hold:
| Level | Criteria | Action |
|---|---|---|
| high | Clear requirement, strong evidence, reversible if wrong | Record and move on |
| medium | Some ambiguity, partial evidence, or moderate blast radius | Schedule review in 2 weeks |
| low | Guesswork, no evidence, high blast radius, or irreversible | Require second opinion before proceeding |
Set confidence_level honestly. A low-confidence decision is not bad — pretending it is high confidence is.
Before recording, verify the decision meets these standards:
assumptions or alternatives_consideredIf any box is unchecked, either gather the missing information or flag the decision as confidence_level: low.
.codebase/DECISIONS.jsonl is append-only newline-delimited JSON. Query it with the decision-trace tool or standard tools:
Use the tool's query action to filter:
// All decisions touching auth files
{ "action": "query", "query": { "file_path": "src/services/auth.ts" } }
// All deletions (high-risk)
{ "action": "query", "query": { "change_type": "delete" } }
// All high-risk decisions from the last sprint
{ "action": "query", "query": { "risk_level": "high", "limit": 20 } }
Read the ledger periodically to spot trends:
alternatives_considered appears 3+ times, extract a convention or skillassumptions entry is contradicted by later decisions, update the original or mark it superseded_byhigh risk decisions in one module signals instability — consider a refactor or deeper reviewFlag entries for re-examination when:
confidence_level: medium or lowrisk_level: high with no linked evidenceevidence array and confidence_level is not highsuperseded_by which itself has superseded_by — merge into a single current decisionThe decision-trace tool accepts these actions:
| Action | Parameters | Description |
|---|---|---|
record | entry object (required) | Append a new decision to the ledger |
query | query object with optional file_path, change_type, risk_level, limit | Search existing decisions |
get_for_file | file_path (required) | Get all decisions for a specific file |
interface DecisionEntry {
id: string; // unique identifier
file_path: string; // file affected
change_type: 'create' | 'edit' | 'delete' | 'refactor';
rationale: string; // why this change was made
evidence: string[]; // supporting commits, tests, docs, failure IDs
assumptions: string[]; // things assumed true
alternatives_considered: string[]; // options evaluated
risk_level: 'low' | 'medium' | 'high';
confidence_level: 'low' | 'medium' | 'high';
agent: string; // which agent made the decision
superseded_by?: string; // ID of a later decision that replaces this
}
Use decision trace alongside these skills:
assumptions.risk_level: high with confidence_level: low and link to the constraint rule.When reviewing a PR, query DECISIONS.jsonl for all files in the diff. For each entry, reviewers can quickly see the "why" without asking the author.
Optimize token usage and context window discipline. Reduce costs and improve response quality through smart context management.
Unified context lifecycle for FlowDeck sessions — ingest, filter, prune, protect, summarize, and persist with telemetry.
Predict affected files, modules, APIs, tests, and DB paths before changes. Returns an impact map for human review.
Map architecture, conventions, and file structure into `.codebase/`. Use when onboarding or before deep feature work.
Plan differently when the agent has low certainty — ask for clarification or narrow scope instead of pretending full understanding.
Protect critical context from pruning during compaction. Preserve active plans, safety files, pending operations, and user intent anchors.