context-engineer 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +88 -0
  2. package/bin/cli.mjs +91 -0
  3. package/lib/copy.mjs +102 -0
  4. package/lib/init.mjs +166 -0
  5. package/lib/prompts.mjs +144 -0
  6. package/lib/update.mjs +198 -0
  7. package/package.json +35 -0
  8. package/templates/checksums.json +68 -0
  9. package/templates/claude/.claude/rules/context-maintenance.md +38 -0
  10. package/templates/claude/.claude/rules/experience-capture.md +46 -0
  11. package/templates/claude/.claude/settings.project.json +22 -0
  12. package/templates/claude/.claude/skills/bootstrap/SKILL.md +223 -0
  13. package/templates/claude/.claude/skills/dev/SKILL.md +119 -0
  14. package/templates/claude/.claude/skills/dev-capture/SKILL.md +111 -0
  15. package/templates/claude/.claude/skills/dev-commit/SKILL.md +90 -0
  16. package/templates/claude/.claude/skills/dev-decompose/SKILL.md +113 -0
  17. package/templates/claude/.claude/skills/dev-deps/SKILL.md +108 -0
  18. package/templates/claude/.claude/skills/dev-execute/SKILL.md +196 -0
  19. package/templates/claude/.claude/skills/dev-prd/SKILL.md +100 -0
  20. package/templates/claude/.claude/skills/dev-quality/SKILL.md +109 -0
  21. package/templates/claude/.claude/skills/dev-requirements/SKILL.md +75 -0
  22. package/templates/claude/.claude/skills/review-context/SKILL.md +120 -0
  23. package/templates/claude/.claude/skills/sync/SKILL.md +107 -0
  24. package/templates/claude/.claude/skills/update-context/SKILL.md +105 -0
  25. package/templates/claude/.claude/workflow/agents/implementer.md +65 -0
  26. package/templates/claude/.claude/workflow/agents/reviewer.md +96 -0
  27. package/templates/claude/.claude/workflow/agents/team-config.md +97 -0
  28. package/templates/claude/.claude/workflow/agents/tester.md +98 -0
  29. package/templates/claude/.claude/workflow/interfaces/phase-contract.md +157 -0
  30. package/templates/claude/CLAUDE.md +50 -0
  31. package/templates/core/.context/_meta/concepts.md +9 -0
  32. package/templates/core/.context/_meta/drift-report.md +16 -0
  33. package/templates/core/.context/_meta/last-sync.json +6 -0
  34. package/templates/core/.context/_meta/schema.md +242 -0
  35. package/templates/core/.context/architecture/api-surface.md +52 -0
  36. package/templates/core/.context/architecture/class-index.md +49 -0
  37. package/templates/core/.context/architecture/data-flow.md +103 -0
  38. package/templates/core/.context/architecture/data-model.md +35 -0
  39. package/templates/core/.context/architecture/decisions/001-template.md +35 -0
  40. package/templates/core/.context/architecture/dependencies.md +35 -0
  41. package/templates/core/.context/architecture/infrastructure.md +42 -0
  42. package/templates/core/.context/architecture/module-graph.md +68 -0
  43. package/templates/core/.context/architecture/overview.md +87 -0
  44. package/templates/core/.context/business/domain-model.md +43 -0
  45. package/templates/core/.context/business/glossary.md +23 -0
  46. package/templates/core/.context/business/overview.md +29 -0
  47. package/templates/core/.context/business/workflows.md +61 -0
  48. package/templates/core/.context/constitution.md +84 -0
  49. package/templates/core/.context/conventions/code-style.md +47 -0
  50. package/templates/core/.context/conventions/error-handling.md +50 -0
  51. package/templates/core/.context/conventions/git.md +46 -0
  52. package/templates/core/.context/conventions/patterns.md +41 -0
  53. package/templates/core/.context/conventions/testing.md +49 -0
  54. package/templates/core/.context/experience/debugging.md +21 -0
  55. package/templates/core/.context/experience/incidents.md +26 -0
  56. package/templates/core/.context/experience/lessons.md +23 -0
  57. package/templates/core/.context/experience/performance.md +29 -0
  58. package/templates/core/.context/index.md +93 -0
  59. package/templates/core/.context/progress/backlog.md +23 -0
  60. package/templates/core/.context/progress/status.md +30 -0
  61. package/templates/core/.context/workflow/artifacts/.gitkeep +0 -0
  62. package/templates/core/.context/workflow/config.md +35 -0
  63. package/templates/core/AGENTS.md +53 -0
  64. package/templates/core/scripts/compact-experience.sh +83 -0
  65. package/templates/core/scripts/detect-drift.sh +388 -0
  66. package/templates/core/scripts/extract-structure.sh +757 -0
  67. package/templates/core/scripts/sync-context.sh +510 -0
  68. package/templates/cursor/.cursor/rules/always.mdc +18 -0
  69. package/templates/cursor/.cursor/rules/backend.mdc +16 -0
  70. package/templates/cursor/.cursor/rules/database.mdc +16 -0
  71. package/templates/cursor/.cursor/rules/frontend.mdc +13 -0
  72. package/templates/cursor/.cursorrules +23 -0
  73. package/templates/github/.github/copilot-instructions.md +15 -0
  74. package/templates/github/.github/workflows/context-drift.yml +73 -0
@@ -0,0 +1,46 @@
1
+ # Git Conventions
2
+
3
+ <!-- confidence: low -->
4
+ <!-- source: [TO BE FILLED BY BOOTSTRAP] -->
5
+ <!-- last-updated: YYYY-MM-DD -->
6
+
7
+ ## Summary
8
+
9
+ <!-- Branch strategy, commit message conventions, PR process -->
10
+
11
+ [PLACEHOLDER: Run `/bootstrap-context` to auto-generate from git history analysis.]
12
+
13
+ ## Branch Strategy
14
+
15
+ - **Main branch**: `main` (production-ready)
16
+ - **Development branch**: [e.g., `develop` or direct to `main`]
17
+ - **Feature branches**: `feature/[description]`
18
+ - **Bug fix branches**: `fix/[description]`
19
+ - **Release branches**: [if applicable]
20
+
21
+ ## Commit Message Convention
22
+
23
+ ```
24
+ [type]([scope]): [short description]
25
+
26
+ [optional body]
27
+
28
+ [optional footer]
29
+ ```
30
+
31
+ Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `perf`, `ci`
32
+
33
+ ## Pull Request Process
34
+
35
+ 1. Create a feature branch from `main`
36
+ 2. Make changes, ensure tests pass
37
+ 3. Create PR with description following template
38
+ 4. Request review from [team/person]
39
+ 5. Address feedback
40
+ 6. Squash merge to `main`
41
+
42
+ ## Protected Branches
43
+
44
+ | Branch | Rules |
45
+ |--------|-------|
46
+ | `main` | [e.g., Require PR, require CI pass, require 1 approval] |
@@ -0,0 +1,41 @@
1
+ # Design Patterns
2
+
3
+ <!-- confidence: low -->
4
+ <!-- source: [TO BE FILLED BY BOOTSTRAP] -->
5
+ <!-- last-updated: YYYY-MM-DD -->
6
+
7
+ ## Summary
8
+
9
+ <!-- Design patterns, architectural patterns, and reusable code patterns used in this project -->
10
+
11
+ [PLACEHOLDER: Run `/bootstrap-context` to auto-generate from code analysis.]
12
+
13
+ ## Architectural Patterns
14
+
15
+ ### [Pattern Name, e.g., Repository Pattern]
16
+ - **Where used**: [Which modules/layers]
17
+ - **Implementation**: [Brief description]
18
+ - **Example**: `[file path]`
19
+
20
+ ## Common Code Patterns
21
+
22
+ ### Error Handling Pattern
23
+ ```
24
+ [Code example showing the standard error handling approach]
25
+ ```
26
+
27
+ ### Service Layer Pattern
28
+ ```
29
+ [Code example showing how services are structured]
30
+ ```
31
+
32
+ ### Data Access Pattern
33
+ ```
34
+ [Code example showing how data access is done]
35
+ ```
36
+
37
+ ## Anti-Patterns to Avoid
38
+
39
+ | Anti-Pattern | Why It's Bad | What to Do Instead |
40
+ |-------------|-------------|-------------------|
41
+ | [Anti-pattern 1] | [Why] | [Alternative] |
@@ -0,0 +1,49 @@
1
+ # Testing Conventions
2
+
3
+ <!-- confidence: low -->
4
+ <!-- source: [TO BE FILLED BY BOOTSTRAP] -->
5
+ <!-- last-updated: YYYY-MM-DD -->
6
+
7
+ ## Summary
8
+
9
+ <!-- Testing strategy, frameworks, conventions, and examples -->
10
+
11
+ [PLACEHOLDER: Run `/bootstrap-context` to auto-generate from test file analysis.]
12
+
13
+ ## Testing Stack
14
+
15
+ | Type | Framework | Location |
16
+ |------|-----------|----------|
17
+ | Unit tests | [e.g., xUnit, Jest, pytest] | [e.g., tests/unit/] |
18
+ | Integration tests | [e.g., same + TestContainers] | [e.g., tests/integration/] |
19
+ | E2E tests | [e.g., Playwright, Cypress] | [e.g., tests/e2e/] |
20
+
21
+ ## Running Tests
22
+
23
+ ```bash
24
+ # Run all tests
25
+ [COMMAND]
26
+
27
+ # Run unit tests only
28
+ [COMMAND]
29
+
30
+ # Run with coverage
31
+ [COMMAND]
32
+
33
+ # Run specific test file
34
+ [COMMAND]
35
+ ```
36
+
37
+ ## Conventions
38
+
39
+ 1. **Test file naming**: [e.g., `*.test.ts`, `*Tests.cs`, `test_*.py`]
40
+ 2. **Test method naming**: [e.g., `Should_ExpectedResult_When_Condition`]
41
+ 3. **Arrange-Act-Assert**: Follow the AAA pattern
42
+ 4. **Independence**: Tests must not depend on execution order or shared state
43
+ 5. **Mocking**: [Preferred mocking library and approach]
44
+
45
+ ## Test Data
46
+
47
+ - **Fixtures**: [Where test fixtures are located]
48
+ - **Factories**: [How test data is generated]
49
+ - **Cleanup**: [How test data is cleaned up]
@@ -0,0 +1,21 @@
1
+ # Debugging Guide
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+
5
+ ## Summary
6
+
7
+ <!-- Common issues, their symptoms, root causes, and resolutions. -->
8
+ <!-- This file serves as a quick-reference troubleshooting guide for AI agents and developers. -->
9
+
10
+ ## Known Issues & Resolutions
11
+
12
+ <!-- Add new entries at the top. Use the format below:
13
+
14
+ ### "[Error Message or Symptom]"
15
+ - **Cause**: [Why this happens]
16
+ - **Fix**: [How to resolve it]
17
+ - **Prevention**: [How to avoid it in the future]
18
+
19
+ -->
20
+
21
+ [No entries yet. Debugging knowledge will be accumulated as issues are encountered and resolved.]
@@ -0,0 +1,26 @@
1
+ # Incident Post-Mortems
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+
5
+ ## Summary
6
+
7
+ <!-- Post-mortems and failure analyses from production incidents -->
8
+
9
+ ## Incidents
10
+
11
+ <!-- Add new entries at the top:
12
+
13
+ ### YYYY-MM-DD: [Incident Title]
14
+ - **Severity**: [P0/P1/P2/P3]
15
+ - **Duration**: [How long the incident lasted]
16
+ - **Impact**: [What was affected, how many users]
17
+ - **Root Cause**: [What caused the incident]
18
+ - **Resolution**: [How it was resolved]
19
+ - **Action Items**:
20
+ - [ ] [Preventive action 1]
21
+ - [ ] [Preventive action 2]
22
+ - **Lessons**: [Key takeaways → also add to lessons.md]
23
+
24
+ -->
25
+
26
+ [No incidents recorded yet.]
@@ -0,0 +1,23 @@
1
+ # Lessons Learned
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+
5
+ ## Summary
6
+
7
+ <!-- Accumulated lessons, anti-patterns discovered, and insights from development experience. -->
8
+ <!-- When this file exceeds 500 lines, run scripts/compact-experience.sh to archive older entries. -->
9
+
10
+ ## Entries
11
+
12
+ <!-- Add new entries at the top. Use the format below:
13
+
14
+ ### YYYY-MM-DD: [Short Title]
15
+ - **Context**: [What was happening when this was discovered]
16
+ - **Root Cause**: [Why it happened]
17
+ - **Resolution**: [How it was fixed]
18
+ - **Prevention**: [What was done to prevent recurrence, e.g., "Added to conventions/patterns.md"]
19
+ - **Tags**: #tag1 #tag2
20
+
21
+ -->
22
+
23
+ [No entries yet. Lessons will be accumulated as the project evolves.]
@@ -0,0 +1,29 @@
1
+ # Performance Insights
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+
5
+ ## Summary
6
+
7
+ <!-- Performance benchmarks, optimization discoveries, and tuning notes -->
8
+
9
+ ## Benchmarks
10
+
11
+ <!-- Baseline performance metrics for key operations -->
12
+
13
+ | Operation | Baseline | Target | Current |
14
+ |-----------|----------|--------|---------|
15
+ | [Operation] | [Time/Throughput] | [Target] | [Current] |
16
+
17
+ ## Optimization Notes
18
+
19
+ <!-- Add new entries at the top:
20
+
21
+ ### YYYY-MM-DD: [Optimization Title]
22
+ - **Before**: [Metric before optimization]
23
+ - **After**: [Metric after optimization]
24
+ - **What Changed**: [What was optimized]
25
+ - **Tags**: #tag1 #tag2
26
+
27
+ -->
28
+
29
+ [No entries yet.]
@@ -0,0 +1,93 @@
1
+ # Context Index
2
+
3
+ > This is the master index for the project's context system.
4
+ > AI agents should read this file first to understand what context is available and where to find it.
5
+
6
+ ## How to Use This Index
7
+
8
+ 1. Read `.context/constitution.md` for non-negotiable principles and the **Context Loading Route Table**
9
+ 2. Use the Route Table to determine which files to load based on your current task
10
+ 3. Only load files relevant to your task — do NOT load everything
11
+
12
+ ## Context Directory
13
+
14
+ ### Core (Always Read)
15
+ | File | Description |
16
+ |------|-------------|
17
+ | [constitution.md](constitution.md) | Non-negotiable principles, constraints, and the Context Loading Route Table |
18
+
19
+ ### Business Domain
20
+ | File | Description | Size Budget |
21
+ |------|-------------|-------------|
22
+ | [business/overview.md](business/overview.md) | What the product does, who it serves, why it exists | 300 lines |
23
+ | [business/domain-model.md](business/domain-model.md) | Core business entities, relationships, ubiquitous language (DDD) | 500 lines |
24
+ | [business/workflows.md](business/workflows.md) | Key processes, workflows, and technical pipelines | 400 lines |
25
+ | [business/glossary.md](business/glossary.md) | Domain terminology definitions | 300 lines |
26
+
27
+ ### Technical Architecture
28
+ | File | Description | Size Budget |
29
+ |------|-------------|-------------|
30
+ | [architecture/overview.md](architecture/overview.md) | System architecture, high-level design, subsystem breakdown | 800 lines |
31
+ | [architecture/module-graph.md](architecture/module-graph.md) | Module/subsystem dependency graph and interfaces | 500 lines |
32
+ | [architecture/data-flow.md](architecture/data-flow.md) | Data flow diagrams, pipelines, threading model | 500 lines |
33
+ | [architecture/class-index.md](architecture/class-index.md) | Core classes/interfaces index (auto-generated) | 500 lines |
34
+ | [architecture/data-model.md](architecture/data-model.md) | Database schema, entity relationships (auto-generated) | 500 lines |
35
+ | [architecture/api-surface.md](architecture/api-surface.md) | API contracts, endpoints, protocols (auto-generated) | 500 lines |
36
+ | [architecture/dependencies.md](architecture/dependencies.md) | External services, libraries, versions (auto-generated) | 300 lines |
37
+ | [architecture/infrastructure.md](architecture/infrastructure.md) | Deployment, CI/CD, environments | 300 lines |
38
+ | [architecture/decisions/](architecture/decisions/) | Architecture Decision Records (ADRs) | 200 lines each |
39
+
40
+ ### Coding Conventions
41
+ | File | Description | Size Budget |
42
+ |------|-------------|-------------|
43
+ | [conventions/code-style.md](conventions/code-style.md) | Naming, formatting, language-specific rules | 300 lines |
44
+ | [conventions/patterns.md](conventions/patterns.md) | Design patterns used in this project | 400 lines |
45
+ | [conventions/testing.md](conventions/testing.md) | Testing strategy, conventions, examples | 300 lines |
46
+ | [conventions/git.md](conventions/git.md) | Branch strategy, commit conventions, PR process | 200 lines |
47
+ | [conventions/error-handling.md](conventions/error-handling.md) | Error handling patterns, logging conventions | 200 lines |
48
+
49
+ ### Architecture Decisions (ADRs)
50
+ | File | Title | Status |
51
+ |------|-------|--------|
52
+ | [architecture/decisions/001-template.md](architecture/decisions/001-template.md) | Template | — |
53
+ <!-- /sync and /update-context maintain this table automatically -->
54
+
55
+ ### Feature Specifications (OpenSpec-style)
56
+ | Spec | Description |
57
+ |------|-------------|
58
+ <!-- No specs yet. Create specs/{feature}/spec.md to add one. -->
59
+ <!-- /sync and /update-context maintain this table automatically -->
60
+
61
+ ### Active Changes
62
+ | Change | Description |
63
+ |--------|-------------|
64
+ <!-- No active changes. Create changes/{name}/proposal.md to add one. -->
65
+ <!-- /sync and /update-context maintain this table automatically -->
66
+
67
+ ### Experience & Knowledge
68
+ | File | Description | Size Budget |
69
+ |------|-------------|-------------|
70
+ | [experience/lessons.md](experience/lessons.md) | Lessons learned, anti-patterns discovered | 500 lines |
71
+ | [experience/debugging.md](experience/debugging.md) | Common issues and resolutions | 500 lines |
72
+ | [experience/performance.md](experience/performance.md) | Performance insights, optimization notes | 300 lines |
73
+ | [experience/incidents.md](experience/incidents.md) | Post-mortems, failure analyses | 300 lines |
74
+
75
+ ### Session Continuity (Ralph Loop-style)
76
+ | File | Description |
77
+ |------|-------------|
78
+ | [progress/status.md](progress/status.md) | Current work-in-progress state |
79
+ | [progress/backlog.md](progress/backlog.md) | Planned work items |
80
+
81
+ ### Development Workflow
82
+ | File | Description |
83
+ |------|-------------|
84
+ | [workflow/config.md](workflow/config.md) | Pipeline configuration: phases, checkpoints, plugin overrides |
85
+ | [workflow/artifacts/](workflow/artifacts/) | Transient phase outputs (requirements.md, prd.md, tasks.json, dep-graph.json, etc.) |
86
+
87
+ ### System Metadata
88
+ | File | Description |
89
+ |------|-------------|
90
+ | [_meta/schema.md](_meta/schema.md) | Self-documenting schema for context files |
91
+ | [_meta/last-sync.json](_meta/last-sync.json) | Last sync timestamps per file |
92
+ | [_meta/concepts.md](_meta/concepts.md) | Concept-to-file inverted index (auto-generated) |
93
+ | [_meta/drift-report.md](_meta/drift-report.md) | Latest drift detection results |
@@ -0,0 +1,23 @@
1
+ # Backlog
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+
5
+ ## Summary
6
+
7
+ <!-- Planned work items, prioritized. This serves as a lightweight task tracker for AI agent sessions. -->
8
+
9
+ ## Priority Queue
10
+
11
+ <!-- Format:
12
+ ### [Priority] [Task Title]
13
+ - **Description**: [What needs to be done]
14
+ - **Context files**: [Which .context/ files are relevant]
15
+ - **Estimated complexity**: [Low | Medium | High]
16
+ - **Status**: [Pending | In Progress | Done]
17
+ -->
18
+
19
+ [No backlog items yet.]
20
+
21
+ ## Completed
22
+
23
+ <!-- Move completed items here with completion date -->
@@ -0,0 +1,30 @@
1
+ # Work In Progress Status
2
+
3
+ <!-- last-updated: YYYY-MM-DD -->
4
+ <!-- This file is updated before context compaction to preserve session continuity -->
5
+
6
+ ## Current Task
7
+
8
+ **Task**: [None]
9
+ **Status**: [Not started | In progress | Blocked | Complete]
10
+ **Branch**: [branch name if applicable]
11
+
12
+ ## What Was Done
13
+
14
+ - [List of completed steps in current task]
15
+
16
+ ## What Remains
17
+
18
+ - [List of remaining steps]
19
+
20
+ ## Blockers
21
+
22
+ - [Any blockers or decisions needed]
23
+
24
+ ## Key Decisions Made This Session
25
+
26
+ - [Important decisions or trade-offs made]
27
+
28
+ ## Files Modified
29
+
30
+ - [List of files changed in this session]
@@ -0,0 +1,35 @@
1
+ # Workflow Configuration
2
+
3
+ <!-- TEMPLATE: This file configures the /dev automated development workflow pipeline. -->
4
+ <!-- Customize checkpoints, execution settings, and plugin overrides for your project. -->
5
+
6
+ ## Pipeline Phases
7
+
8
+ | Phase | ID | Checkpoint | Override |
9
+ |-------|----|------------|----------|
10
+ | Requirements Gathering | P0 | false | — |
11
+ | PRD Generation | P1 | true | — |
12
+ | Task Decomposition | P2 | true | — |
13
+ | Dependency Analysis | P3 | false | — |
14
+ | Agent Execution | P4 | false | — |
15
+ | Quality Gate | P5 | false | — |
16
+ | Commit & Integration | P6 | false | — |
17
+ | Knowledge Capture | P7 | false | — |
18
+
19
+ ## Execution Settings
20
+
21
+ - **max_parallel_agents**: 3
22
+ - **isolation_strategy**: file-scope-first (fallback to worktree)
23
+ - **quality_gate_commands**: (use constitution.md build/test commands)
24
+ - **auto_commit**: false (require human confirmation)
25
+
26
+ ## Plugin Overrides
27
+
28
+ <!-- Add project-specific overrides here. -->
29
+ <!-- Priority: config override > convention directory (.claude/workflow/phases/) > built-in default -->
30
+ <!--
31
+ | Phase | Plugin Name | Type | Location |
32
+ |-------|-------------|------|----------|
33
+ | P5 | custom-e2e | skill | .claude/workflow/phases/quality-gate/SKILL.md |
34
+ | P5 | api-tests | mcp | mcp-server-name |
35
+ -->
@@ -0,0 +1,53 @@
1
+ # AGENTS.md
2
+
3
+ > Universal entry point for all AI coding agents. This file is automatically read by Claude Code, Cursor, Windsurf, OpenAI Codex, GitHub Copilot, and other AI tools.
4
+
5
+ ## Project: [PROJECT_NAME]
6
+
7
+ [One-line description of what this project does.]
8
+
9
+ ## Quick Start
10
+
11
+ ```bash
12
+ # Install dependencies
13
+ [INSTALL_COMMAND]
14
+
15
+ # Build
16
+ [BUILD_COMMAND]
17
+
18
+ # Test
19
+ [TEST_COMMAND]
20
+
21
+ # Run locally
22
+ [RUN_COMMAND]
23
+ ```
24
+
25
+ ## Context System
26
+
27
+ This project uses a structured context system at `.context/`. **Do NOT try to understand the entire codebase at once.** Instead:
28
+
29
+ 1. **Always read** `.context/constitution.md` — it contains non-negotiable principles and a **Context Loading Route Table** that tells you which files to load based on your task type.
30
+ 2. **Read the route table** and load ONLY the files relevant to your current task.
31
+ 3. **Read** `.context/index.md` for a full directory of available context.
32
+
33
+ ## Context Maintenance
34
+
35
+ When you modify code that affects any of the following, **update the corresponding `.context/` file in the same commit**:
36
+
37
+ - Architecture → `architecture/overview.md`
38
+ - Database schema → `architecture/data-model.md`
39
+ - API endpoints → `architecture/api-surface.md`
40
+ - Dependencies → `architecture/dependencies.md`
41
+ - Coding patterns → `conventions/patterns.md`
42
+
43
+ When you fix a non-trivial bug, record it in `experience/debugging.md`.
44
+
45
+ ## Key Conventions
46
+
47
+ <!-- Fill in your project's most critical conventions (keep this under 10 items) -->
48
+
49
+ 1. [Convention 1]
50
+ 2. [Convention 2]
51
+ 3. [Convention 3]
52
+
53
+ For full conventions, see `.context/conventions/`.
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # compact-experience.sh — Compact experience files that exceed their size budgets
4
+ #
5
+ # Usage: bash scripts/compact-experience.sh [--dry-run]
6
+ #
7
+ # This script checks experience files for size budget violations and helps
8
+ # archive older entries to keep the files within budget.
9
+
10
+ set -euo pipefail
11
+
12
+ CONTEXT_DIR=".context"
13
+ EXPERIENCE_DIR="$CONTEXT_DIR/experience"
14
+ ARCHIVE_DIR="$EXPERIENCE_DIR/archive"
15
+ DRY_RUN=false
16
+ BUDGET=500
17
+
18
+ for arg in "$@"; do
19
+ case $arg in
20
+ --dry-run) DRY_RUN=true ;;
21
+ esac
22
+ done
23
+
24
+ echo "========================================="
25
+ echo " Experience Compaction"
26
+ echo "========================================="
27
+ echo ""
28
+
29
+ # Check files and their sizes
30
+ check_file() {
31
+ local file=$1
32
+ local name
33
+ name=$(basename "$file")
34
+
35
+ if [ ! -f "$file" ]; then
36
+ echo " $name: not found (skip)"
37
+ return
38
+ fi
39
+
40
+ local lines
41
+ lines=$(wc -l < "$file")
42
+
43
+ if [ "$lines" -le "$BUDGET" ]; then
44
+ echo " $name: ${lines}/${BUDGET} lines (OK)"
45
+ else
46
+ local excess=$((lines - BUDGET))
47
+ echo " $name: ${lines}/${BUDGET} lines (OVER by $excess lines)"
48
+
49
+ if [ "$DRY_RUN" = true ]; then
50
+ echo " → [DRY RUN] Would archive older entries"
51
+ else
52
+ echo " → Creating archive..."
53
+ mkdir -p "$ARCHIVE_DIR"
54
+
55
+ local archive_file="$ARCHIVE_DIR/${name%.md}-$(date +%Y%m%d).md"
56
+
57
+ # Strategy: Keep the header and last BUDGET/2 entries, archive the rest
58
+ # This is a simple approach — the AI skills can do smarter compaction
59
+ echo " → Archiving to $archive_file"
60
+ echo " → NOTE: For intelligent compaction (merging related entries,"
61
+ echo " promoting patterns to conventions), use the '/review-context' skill."
62
+ echo ""
63
+ echo " Manual steps recommended:"
64
+ echo " 1. Review $file for entries that can be merged"
65
+ echo " 2. Move resolved/obsolete entries to $archive_file"
66
+ echo " 3. Promote frequently-referenced lessons to conventions/patterns.md"
67
+ fi
68
+ fi
69
+ }
70
+
71
+ echo "Checking experience file sizes (budget: $BUDGET lines)..."
72
+ echo ""
73
+
74
+ check_file "$EXPERIENCE_DIR/lessons.md"
75
+ check_file "$EXPERIENCE_DIR/debugging.md"
76
+ check_file "$EXPERIENCE_DIR/performance.md"
77
+ check_file "$EXPERIENCE_DIR/incidents.md"
78
+
79
+ echo ""
80
+ echo "Done."
81
+ if [ "$DRY_RUN" = true ]; then
82
+ echo "(Dry run — no changes made)"
83
+ fi