ワンクリックで
memory-and-state
Use to maintain persistent context across agent sessions — decision logs, architecture memory, and constraint tracking.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Use to maintain persistent context across agent sessions — decision logs, architecture memory, and constraint tracking.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Use for general product implementation work that is not primarily backend architecture, pure integration wiring, or screenshot-driven design-to-code.
Use when backend work requires contract-first thinking, schema changes, permission checks, side-effect analysis, or test planning.
Use immediately after codebase discovery to classify task scale and determine which workflow steps are required vs. optional.
Use when the user provides screenshots, mockups, or design assets and wants implementation that stays visually close to the source.
Use when the main deliverable is maintainable documentation such as repository rules, onboarding guides, runbooks, ADRs, or architecture notes.
Use when encountering compile errors, test failures, runtime exceptions, or unexpected behavior during implementation.
| name | memory-and-state |
| description | Use to maintain persistent context across agent sessions — decision logs, architecture memory, and constraint tracking. |
Use this skill to prevent agents from forgetting prior decisions and repeating mistakes.
DECISIONS.md)A version-controlled file at the repo root. Records architectural and behavioral decisions.
Format:
## YYYY-MM-DD: [Decision title]
- **Context**: Why this decision was needed
- **Decision**: What was decided
- **Alternatives considered**: What was rejected and why
- **Constraints introduced**: What future work must respect
Rules:
DECISIONS.md at the start of every planning or implementation task. This is not optional.ARCHITECTURE.md)A version-controlled file describing the codebase structure.
Should contain:
Rules:
For in-progress tasks that span multiple agent interactions:
This prevents re-discovery and reduces repeated mistakes within a session.
Within a single conversation or agent session, manage history in three tiers to prevent context window exhaustion while preserving relevant information.
Keep the most recent 3–5 turns of conversation as raw, unmodified content. This preserves full fidelity for the active working context.
When turns age out of the short-term window, compress them into structured summaries:
## Conversation summary (turns 1–N)
- **Decisions made**: [list]
- **Files changed**: [list]
- **Errors encountered and resolved**: [list]
- **Open questions**: [list]
- **Current plan state**: [brief]
Rules:
docs/operating-rules.md.For knowledge that persists beyond a single session, use the existing persistent stores:
| Store | Content | Retrieval |
|---|---|---|
DECISIONS.md | Architectural and behavioral decisions | Read at task start |
ARCHITECTURE.md | Module map, interfaces, data flow | Read when working on unfamiliar modules |
| Repo memory files | Reusable patterns, component-level notes | Search by module name or task type keywords |
DECISIONS_ARCHIVE.md | Inactive past decisions | Search only for legacy module work |
Advanced (optional): For teams with vector database or embedding infrastructure, long-term memory can be augmented with semantic retrieval (RAG):
DECISIONS.md, ARCHITECTURE.md, session summaries, and past task completion summaries as embeddings.| Tier | Target budget | Enforcement |
|---|---|---|
| Short-term (raw turns) | ≤ 4,000 tokens | Trim oldest turn when exceeded |
| Mid-term (summary) | ≤ 1,500 tokens | Regenerate summary with tighter compression |
| Long-term (persistent reads) | ≤ 3,000 tokens per task | Use selective read strategy (see below) |
| Total conversation memory | ≤ 8,500 tokens | Roughly 6–7% of a 128K context window |
Conversation memory is entirely within Layer 4 (volatile context). It does not affect the cached prefix in Layers 1–3. However, keeping conversation memory compact:
For any task spanning more than one step or more than one file, maintain a context anchor using the canonical template in docs/agent-templates.md → Context anchor template.
Do not duplicate or redefine the template here; treat docs/agent-templates.md as the single source of truth for the anchor format.
Update this anchor before each major step. This prevents drift by forcing the agent to re-read the plan and current state.
Before making any decision, check DECISIONS.md for conflicts:
STOP and wait for user decision. Do not resolve contradictions autonomously.
| Event | Action |
|---|---|
| Architectural decision made | Append to DECISIONS.md |
| New module or structural change | Update ARCHITECTURE.md |
| Constraint discovered during work | Add to Project-specific constraints in docs/operating-rules.md |
| Error pattern found | Note in session memory to avoid repeating |
| Task partially complete | Write progress to session notes |
| Technology or library introduced | Append to DECISIONS.md |
| Schema or contract changed | Append to DECISIONS.md |
| Tradeoff made | Append to DECISIONS.md |
| Event | Action |
|---|---|
| Starting any implementation | Read DECISIONS.md and ARCHITECTURE.md |
| Encountering unfamiliar module | Read ARCHITECTURE.md |
| Making a decision | Check DECISIONS.md for prior related decisions |
| Resuming interrupted work | Read session notes |
| Starting a long task | Produce a context anchor |
| Starting a Small task | Query categorized memory for similar past patterns (see below) |
| Category | Content | Primary store | Query when |
|---|---|---|---|
| Project-level | Architectural decisions, global conventions, tech choices | DECISIONS.md, ARCHITECTURE.md | Starting any task, making architectural choices |
| Component-level | Per-module patterns, quirks, module-specific constraints | Module READMEs, session/repo memory files | Working on a specific or unfamiliar module (search by module name/path) |
| Change-pattern | Recurring fix patterns, validated approaches for similar tasks | Session/repo memory files | Starting a Small task (search by task-type keywords, e.g., "validation", "config update") |
Small task retrieval: Before implementing a Small task, search session/repo memory for the affected module or task-type keywords. If a matching pattern exists, follow it. If not, proceed normally and capture the pattern in the task completion summary.
Persistent memory files grow over time. Without active lifecycle management, they consume excessive tokens on every read and eventually exceed context windows.
DECISIONS.md exceeds 50 entries or 30 KB, ORDECISIONS.mdDECISIONS_ARCHIVE.mdDECISIONS.mdNever archive based on date alone — a 2-year-old decision with active constraints stays in DECISIONS.md.
DECISIONS_ARCHIVE.md uses the same entry format as DECISIONS.md, with one addition: append - **Archived on**: YYYY-MM-DD — [reason, e.g., "replaced by decision X"] to each entry.
DECISIONS.md retains all entries with active constraintsAgents should not read the full archive on every task. Use a tiered approach. If DECISIONS_ARCHIVE.md does not exist yet, treat archive searches as returning no matches and skip any archive-read step that would otherwise require the file.
| Situation | What to read |
|---|---|
| Normal task | DECISIONS.md only (active constraints) |
| Task involves legacy module or old migration | DECISIONS.md + search DECISIONS_ARCHIVE.md for module name, if the archive file exists |
| Contradiction detection finds no match in active | Search DECISIONS_ARCHIVE.md before concluding "no prior decision", if the archive file exists; otherwise treat as no archived match |
| Periodic maintenance review | Read both files in full if DECISIONS_ARCHIVE.md exists; otherwise read DECISIONS.md only |
Session-scoped memory (scratch notes, in-progress tracking) should not accumulate without bound.
After task completion, promote session memory to repo-level memory only if:
All other session notes are disposable after the task completion summary is produced.
Track during feedback loop quality signal reviews:
| Indicator | Healthy | Needs attention |
|---|---|---|
DECISIONS.md entry count | ≤ 50 | > 50 without recent archive |
DECISIONS_ARCHIVE.md exists | Yes, once any archiving has occurred | No, with 50+ active decisions |
| Session memory files | ≤ 5 active | > 10 without cleanup |
| Stale constraint references | 0 | Any archived constraint still referenced in code |
Long tasks cause context to grow, increasing cost and reducing model accuracy. Use compaction to prevent this.
Produce a progress summary capturing:
DECISIONS.md references if applicable)Store the summary in session memory or working notes
Continue from the summary, not from the full conversation history
For inter-agent handoffs, this summary becomes the structured handoff artifact defined in docs/operating-rules.md.
After completing any task (regardless of scale), produce a task completion summary using the template in docs/agent-templates.md → Task completion summary. That template is the single source of truth for the summary format.
For Small tasks: if the summary includes a reusable pattern, store it in session or repo memory for future reuse. For Medium/Large tasks: the summary also feeds into documentation sync checks.