memory-compact

$npx mdskill add Fr-e-d/GAAI-framework/memory-compact

Emergency single-pass memory compression when context window pressure is high mid-task

  • Identifies and compacts large categories of memory files.
  • Depends on filesystem-based AI coding agent for memory management.
  • Decides by category size, age, and relevance to current task.
  • Delivers compressed memory files for immediate use or archival.

SKILL.md

.github/skills/memory-compactView on GitHub ↗
---
name: memory-compact
description: Emergency single-pass memory compression when context window pressure is high mid-task. Activate when approaching token limits during active work. For scheduled end-of-phase cleanup, use memory-refresh instead.
license: ELv2
compatibility: Works with any filesystem-based AI coding agent
metadata:
  author: gaai-framework
  version: "1.0"
  category: cross
  track: cross-cutting
  id: SKILL-MEMORY-COMPACT-001
  updated_at: 2026-03-01
  status: stable
inputs:
  - contexts/memory/index.md
  - contexts/memory/**/*
outputs:
  - contexts/memory/summaries/*.summary.md
  - contexts/memory/archive/**
  - contexts/memory/index.md  (updated)
---

# Memory Compact

## Purpose / When to Activate

Activate when:
- Context window pressure is high
- Memory has grown across many sessions
- A single targeted compression pass is needed

More focused than `memory-refresh` — this is a single-pass compression operation.

---

## Process

1. **Select memory by category or tags.** Read `contexts/memory/index.md`. Prioritize categories by: (a) largest file count first, (b) oldest entries first, (c) categories not referenced by the current task last. Under extreme pressure, compact the single largest category only.

2. **Classify entries by durability (R7 gate).** Before compacting, classify each entry:
   - **Durable** (decisions, patterns, project, ops, contacts, domains): only entries with explicit supersession markers (`> SUPERSEDED by DEC-XX`, `> RETRACTED`, `> OBSOLETE — {reason}`) may be archived. All other entries are ACTIVE and MUST NOT be archived regardless of file size. Note: decisions are already individual ADR files (`decisions/DEC-{N}.md`). For other oversized durable files → domain-split, not archive.
   - **Ephemeral** (sessions): standard compaction applies — summarize and archive.

3. Extract key decisions, constraints, priorities

4. **Generate a single summary file replacing multiple entries.** Produce one summary file per compacted category using bullet format: one bullet per decision, constraint, or durable fact. Target ≤20% of the original token count. Use the format:

```markdown
# {Category} — Compact Summary
> Compacted from {N} files on {YYYY-MM-DD}
> Original token estimate: ~{X} | Summary: ~{Y}

## Key Decisions
- {decision 1}
- {decision 2}

## Active Constraints
- {constraint 1}

## Current State
- {fact 1}
```

5. **Archive detailed originals (ephemeral and superseded only).** Archive originals to `contexts/memory/archive/{category}-{YYYY-MM-DD}.archive.md`. If multiple compactions happen on the same day for the same category, append a sequence number: `{category}-{YYYY-MM-DD}-02.archive.md`.

6. Update memory index

---

## Outputs

- `contexts/memory/summaries/{category}.summary.md`
- `contexts/memory/archive/{category}-{YYYY-MM-DD}.archive.md`
- `contexts/memory/index.md` (updated — mandatory)

---

## Quality Checks

- One summary replaces many files
- Context remains precise and small
- No active constraints are lost
- Index reflects current state
- Summary preserves all active decisions and constraints from the originals
- Archive files are never deleted — only moved
- **No active durable memory entry archived** — only superseded/retracted entries may be archived (R7/R7b)

---

## Non-Goals

This skill must NOT:
- Create new project knowledge
- Invent or reinterpret decisions
- Delete (only archive) source files

**One summary replaces many files. Context stays precise and small.**

More from Fr-e-d/GAAI-framework

SkillDescription
abort-safe-handlerOrchestrator-level Stage 4 entry gate for /gaai:bootstrap. Presents a pre-loop "Skip Q&A entirely" option, delegates to qa-loop-ui when the user proceeds, and returns a unified abort_safe_result with telemetry on every path. Guarantees no partial state on skip or abort.
ambiguity-detectorTakes surface scan results, optional LLM synthesis open-question entries, and optional tree-sitter AST signals to score project ambiguities (1-10). Outputs structured ambiguity_feed for smart-question-generator. Pure heuristic — no LLM calls. Designed for Stage 3.5 of the /gaai:bootstrap pipeline (between LLM synthesis and Q&A).
approach-evaluationResearch industry standards and best practices, identify viable approaches for a given technical or architectural problem, and produce a structured factual comparison against project-specific constraints. Reports options — does not decide.
architecture-extractConvert raw project structure into clear architectural understanding — module boundaries, data flows, service relationships, and architectural patterns. Activate after codebase-scan during Bootstrap.
bootstrap-llm-synthesisConstruct the LLM synthesis prompt from project surface scan + optional tree-sitter context + optional Q&A answers. Call the LLM. Parse and validate the response into 6-8 structured memory entries with clarity tags and source traceability. Used as Stage 3 of the /gaai:bootstrap pipeline.
bootstrap-memory-ingest-cloudWrite structured memory entries to the Cloud workspace via gaai_memory.store MCP tool with source='bootstrap'. Loops over entries from bootstrap-llm-synthesis, calls the tool per entry, collects success/fail counts. Used as Stage 5 of the /gaai:bootstrap pipeline (Cloud path only).
browser-journey-testValidate user stories by simulating real user journeys in a live browser against deployed application. Activate after implementation to verify actual user experience against acceptance criteria, not just code logic.
build-agents-indexScan all agent and sub-agent definition files in .gaai/core/agents/, extract YAML frontmatter, merge with specialists.registry.yaml, and generate a derived agents-index.yaml at .gaai/core/agents/agents-index.yaml. Activate after adding, modifying, or removing any agent, sub-agent, or specialist entry.
build-skills-indexScan SKILL.md files in .gaai/core/skills/ and .gaai/project/skills/, extract YAML frontmatter, and regenerate separate skills indices for each layer. Core index ships with the OSS framework; project index is project-specific.
ci-watch-and-fixWatch GitHub Actions CI after PR creation, detect failures, extract logs, apply minimal fixes, and re-push — keeping the delivery session alive until CI resolves or escalating after 3 cycles. Activate immediately after gh pr create and before marking the story done.