一键导入
corgispec-memory-init
Initialize the 3-layer memory structure (memory/ + wiki/) for cross-session AI continuity in a Corgi project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Initialize the 3-layer memory structure (memory/ + wiki/) for cross-session AI continuity in a Corgi project.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create or complete a CorgiSpec planning package and synchronize one GitHub parent issue plus Task Group child issues. Use when proposing a change whose normalized tracking provider is GitHub.
Create or complete a CorgiSpec planning package and optionally synchronize GitLab issues. Use when proposing a new change or finishing an existing change whose normalized tracking provider is GitLab or none.
Execute or resume a CorgiSpec Run Contract v2 one Task Group at a time through the canonical corgispec loop CLI. Use when starting, continuing, fixing, committing, recovering, or finalizing an implementation run; never write loop state or evidence artifacts directly.
Implement exactly one pending Task Group from a CorgiSpec change and optionally synchronize GitLab progress. Use when applying a change whose normalized tracking provider is GitLab or none.
Validate and archive a completed CorgiSpec change, extract durable knowledge, and optionally close GitLab tracking. Use when archiving a change whose normalized tracking provider is GitLab or none.
Compare fresh CorgiSpec planning, implementation, Git, and run evidence and close only implementation gaps through the canonical converge CLI. Use after implementation or review when deciding whether a change is converged, planning needs update, or a new append-only Task Group is required.
| name | corgispec-memory-init |
| description | Initialize the 3-layer memory structure (memory/ + wiki/) for cross-session AI continuity in a Corgi project. |
| license | MIT |
| compatibility | Requires corgispec CLI. Target project must have openspec/config.yaml. |
| metadata | {"author":"corgispec","version":"1.0","generatedBy":"1.0.0"} |
Initialize the 3-layer memory structure for cross-session AI continuity.
Creates memory/ (permanent, agent-focused) and wiki/ (long-term, human+AI) directories with template files, then injects the Session Memory Protocol into the project's agent configuration file.
The result is a structured memory system that:
corgispec-install completes (called automatically unless --no-memory)/corgi-memory-init to add memory to an existing Corgi projectmemory/ or wiki/ yetDo not use this skill to modify memory contents, run lint checks, or extract knowledge from changes.
openspec/config.yamlRead the target project's root for context:
README.md exists → extract project name and purpose (first heading + first paragraph)CLAUDE.md exists → extract:
AGENTS.md exists → extract same categories as CLAUDE.md (merge, deduplicate)GEMINI.md exists → extract same categories (merge, deduplicate)package.json exists → extract project name from name field, framework info from dependenciesdocs/ exists → scan top-level .md filenames for architecture clues (don't deep-read, just note presence)Store extracted values for template population:
PROJECT_NAME: from README heading or package.json namePROJECT_PURPOSE: from README first paragraphTECH_STACK: from agent configs + package.json depsHARD_CONSTRAINTS: bullet list from agent configs (max 15)PREFERENCES: bullet list from agent configs (max 10)STABLE_COMPONENTS: well-established tech from stack infoEVOLVING_COMPONENTS: anything described as new/experimental, or "TBD"LEGACY_COMPONENTS: anything described as deprecated/debt, or "None identified"If a file doesn't exist or a value can't be extracted, use placeholder text.
Note: This is a lightweight extraction for initial setup. For deep knowledge migration from existing projects, run /corgi-migrate after init completes.
Create the following files. Skip any file that already exists — never overwrite.
memory/
├── MEMORY.md
├── session-bridge.md
└── pitfalls.md
---
type: memory
created: <today's date YYYY-MM-DD>
---
# MEMORY — Hard Constraints
> AI agent must obey these every session. Never expires.
## Project Identity
- **Name**: <extracted from README or package.json, or "Unknown">
- **Purpose**: <extracted from README first paragraph, or "Not specified">
- **Stack**: <extracted from CLAUDE.md/AGENTS.md, or "Not specified">
## Hard Constraints
- <extracted from CLAUDE.md Must-Follow Rules, or "None specified yet">
## Preferences
- <extracted from CLAUDE.md style/convention sections, or "None specified yet">
---
type: memory
updated: <today's date YYYY-MM-DD>
---
# Session Bridge
> AI agent reads this first at startup. Last session's handoff state.
## Active corgi Change
- **Change**: none
- **Phase**: none
- **Branch**: main
## Done (last session completed)
- (initial setup — memory structure created)
## Waiting (next steps / blockers)
- First change not yet created — run `/corgi-propose`
## New Pitfalls
- (none yet)
## New Discoveries
- (none yet)
## Next Session Start
1. Read this file ← you are here
2. Read [[wiki/hot]]
3. Read [[wiki/index]]
4. Then docs/ or specs/ as needed
---
type: memory
updated: <today's date YYYY-MM-DD>
---
# Pitfalls
> Cross-change pitfall log. Each entry links to its source change. Max 20 active entries.
## Active
(No pitfalls yet — these accumulate during corgi apply sessions)
## Archive
(No archived pitfalls yet — oldest entries rotate here when Active exceeds 20)
Create the following structure. Skip any file that already exists.
wiki/
├── hot.md
├── schema.md
├── log.md
├── index.md
├── architecture/
│ ├── _index.md
│ └── implicit-contracts.md
├── patterns/
│ └── _index.md
├── research/
│ └── _index.md
├── sessions/
│ └── _index.md
├── decisions/
│ └── _index.md
├── questions/
│ └── _index.md
└── meta/
└── _index.md
---
type: wiki
updated: <today's date YYYY-MM-DD>
tags: [hot, entry]
pinned: true
---
# Hot — <Project Name> Latest
> ~500 words | Hard cap 600 words | Updated every session | First entry point for humans and AI
## Active Changes
- (No active change yet — run `/corgi-propose`)
## Recent Decisions
- Initialized memory structure
## Architecture Pulse
- **Stable**: <from CLAUDE.md/README or "TBD">
- **Evolving**: <current work focus or "TBD">
- **Legacy**: <known tech debt or "None identified">
## Recent Pitfalls
- (none yet — see [[memory/pitfalls]])
## Recently Shipped
- (none yet)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# <Project Name> Wiki Index
> AI-maintained long-term knowledge navigation. Hard cap 80 lines. Click wikilinks to jump to source.
## Architecture Insights
- [[wiki/architecture/_index|Architecture Index]]
- [[wiki/architecture/implicit-contracts|Implicit Contracts]]
## Patterns
- [[wiki/patterns/_index|Patterns Index]]
## Research
- [[wiki/research/_index|Research Index]]
## Decisions
- [[wiki/decisions/_index|Decisions Index]]
## Session History
- [[wiki/sessions/_index|Session Index]]
## Questions
- [[wiki/questions/_index|Questions Index]]
---
type: wiki
updated: <today's date YYYY-MM-DD>
status: accepted
source: "[[decisions/wiki-maintenance-contract|Wiki Maintenance Contract]]"
---
# Wiki Schema — Page Types, Frontmatter & Update Contract
## A. Page Types & Frontmatter
| type | 必需欄位 | 可選欄位 |
|------|---------|----------|
| pattern | `type: wiki`, `created`, `source_change` | `tags` |
| decision | `type: wiki`, `updated`, `status` (proposed/accepted/superseded) | `source`, `tags` |
| session | `type: wiki`, `created`, `source_change`, `status` | `tags` |
| research | `type: wiki`, `updated`, `source` | `tags` |
| meta | `type: wiki`, `generated` | `tags` |
> `wiki/architecture/` is planned but not yet active — no `_index.md` needed until content exists.
## B. Update Contract
| 觸發操作 | 必須同步的動作 |
|----------|---------------|
| 在 wiki 子目錄下新增或刪除任一 .md | 更新對應的 `_index.md` |
| 完成 `corgispec-archive` | 追加 `wiki/log.md` 一條記錄 |
| 完成 `corgispec-archive` | 檢查是否有可抽取的 decision → 若有則創建 decision page |
| 完成 `corgispec-memory-extract` | 更新對應 `_index.md` |
| 完成一次 session | 同時更新 `memory/session-bridge.md` 和 `wiki/hot.md` |
| 跑 `/corgi-lint` | 檢查 orphan page、frontmatter 合規、_index 同步、log 覆蓋率 |
## C. Exemptions
- **Root-level files** (`hot.md`, `index.md`, `schema.md`, `log.md`) 不受 `_index.md` 覆蓋要求約束
- 頁面可透過 `unlisted: true` frontmatter 欄位從 `_index.md` 中排除
## D. Log Format
`wiki/log.md` 採 append-only,每行一事件:
\`\`\`
YYYY-MM-DD | action change-name | +added-file -removed-file
\`\`\`
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Wiki Log
> Append-only log of wiki changes. One line per event.
## Format
\`\`\`
YYYY-MM-DD | action change-name | +added-file -removed-file
\`\`\`
## Entries
(No entries yet — these are appended during corgispec-archive)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Architecture Index
> Structural insights about the codebase. Add entries as architecture knowledge is discovered.
## Pages
- [[wiki/architecture/implicit-contracts|Implicit Contracts]]
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Implicit Contracts
> Unwritten rules discovered during development. Each entry explains what breaks if violated.
## Contracts
(No implicit contracts discovered yet — these are added during corgi apply sessions when hidden dependencies or assumptions are found)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Patterns Index
> Reusable approaches extracted from completed changes.
## Patterns
(No patterns extracted yet — these are created during corgi archive)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Research Index
> Investigation results from corgi explore sessions.
## Topics
(No research topics yet — these are created during corgi explore)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Session Index
> Summaries of completed changes, extracted at archive time.
## Sessions
(No session summaries yet — these are created during corgi archive)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Decisions Index
> Key decisions made during reviews and implementation.
## Decisions
(No decisions recorded yet — these are created when reviews approve significant choices)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Questions Index
> Human questions asked via Obsidian, answered by AI from vault context.
## Questions
(No questions yet — create a markdown file here with `status: pending` frontmatter to ask a question)
---
type: wiki
updated: <today's date YYYY-MM-DD>
---
# Meta Index
> Lint reports, dashboards, and memory health metrics.
## Reports
(No lint reports yet — run `/corgi-lint` to generate one)
Check the agent configuration file for an existing ## Session Memory Protocol section:
CLAUDE.md exists → check for ## Session Memory ProtocolAGENTS.md exists → check for ## Session Memory ProtocolIf the section already exists → skip injection, report "Session Memory Protocol already present."
If the section does NOT exist → append the following block to the end of the primary config file (CLAUDE.md if it exists, otherwise AGENTS.md):
## Session Memory Protocol
### Startup (every session)
Read in order, max 3 files:
1. `memory/session-bridge.md` — last session's state
2. `wiki/hot.md` — current project context (~500 words, hard cap 600)
3. `wiki/index.md` — jump to relevant domain page
Then read `docs/` or code as needed.
### Retrieval Budget
- Startup: max 3 files (session-bridge + hot + index), then on-demand
- Per-question: max 2 wiki pages before answering
- If >5 pages needed: say "this needs a deep session"
### File Size Limits (hard caps)
| File | Target | Hard Cap | Overflow Action |
|------|--------|----------|-----------------|
| wiki/hot.md | 500 words | 600 words | Trim oldest entries |
| wiki/index.md | 40 lines | 80 lines | Archive completed entries |
| memory/pitfalls.md | 10 active | 20 active | Rotate oldest 10 |
| memory/session-bridge.md | 30 lines | 50 lines | Archive old Done items |
### Shutdown (every session end)
Update `memory/session-bridge.md`: Done / Waiting / New Pitfalls / New Discoveries
### corgi Apply → Long-term Memory
After each Task Group completes:
- New pitfalls → append to `memory/pitfalls.md` (link source change)
- New implicit rules → append to `wiki/architecture/implicit-contracts.md`
- Update `wiki/hot.md` Recent Decisions
### Compaction Triggers (agent self-maintains)
- Every archive: compress session-bridge
- pitfalls > 20 entries: rotate oldest 10 to Archive section
- hot.md > 550 words: trim oldest entries
- Every 10 corgi sessions: suggest running /corgi-lint
Throughout all steps, enforce these rules:
## Session Memory Protocol already exists in the config file, do not duplicate it.Print a structured summary:
## Memory Init Complete
**Project**: <name>
**Created**: N files
**Skipped**: M files (already existed)
**Protocol**: Injected into <file> / Already present / No config file
### Created Files
- memory/MEMORY.md
- memory/session-bridge.md
- memory/pitfalls.md
- wiki/hot.md
- wiki/index.md
- wiki/schema.md
- wiki/log.md
- wiki/architecture/_index.md
- wiki/architecture/implicit-contracts.md
- wiki/patterns/_index.md
- wiki/research/_index.md
- wiki/sessions/_index.md
- wiki/decisions/_index.md
- wiki/questions/_index.md
- wiki/meta/_index.md
### Next Steps
1. Review `memory/MEMORY.md` — fill in any placeholders
2. Run `/corgi-propose` to create your first change
3. Memory will auto-update during apply and archive phases