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
package/lib/update.mjs ADDED
@@ -0,0 +1,198 @@
1
+ import { existsSync, readFileSync, writeFileSync } from 'fs';
2
+ import { join } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { dirname } from 'path';
5
+ import { copyTemplateGroup, walkDir, fileHash } from './copy.mjs';
6
+ import { confirm } from './prompts.mjs';
7
+
8
+ const __filename = fileURLToPath(import.meta.url);
9
+ const __dirname = dirname(__filename);
10
+ const TEMPLATES_DIR = join(__dirname, '..', 'templates');
11
+ const PKG = JSON.parse(readFileSync(join(__dirname, '..', 'package.json'), 'utf8'));
12
+
13
+ function loadInstalledVersion(targetDir) {
14
+ const syncPath = join(targetDir, '.context', '_meta', 'last-sync.json');
15
+ if (!existsSync(syncPath)) return null;
16
+ try {
17
+ const data = JSON.parse(readFileSync(syncPath, 'utf8'));
18
+ return data.contextEngineerVersion || null;
19
+ } catch {
20
+ return null;
21
+ }
22
+ }
23
+
24
+ function detectInstalledGroups(targetDir) {
25
+ const groups = [];
26
+ if (existsSync(join(targetDir, '.context'))) groups.push('core');
27
+ if (existsSync(join(targetDir, '.claude'))) groups.push('claude');
28
+ if (existsSync(join(targetDir, '.cursor'))) groups.push('cursor');
29
+ if (existsSync(join(targetDir, '.github', 'copilot-instructions.md'))) groups.push('github');
30
+ return groups;
31
+ }
32
+
33
+ function loadInstalledChecksums(targetDir) {
34
+ const checksumPath = join(targetDir, '.context', '_meta', '.ce-checksums.json');
35
+ if (!existsSync(checksumPath)) return {};
36
+ try {
37
+ return JSON.parse(readFileSync(checksumPath, 'utf8'));
38
+ } catch {
39
+ return {};
40
+ }
41
+ }
42
+
43
+ function saveInstalledChecksums(targetDir, checksums) {
44
+ const checksumPath = join(targetDir, '.context', '_meta', '.ce-checksums.json');
45
+ writeFileSync(checksumPath, JSON.stringify(checksums, null, 2) + '\n');
46
+ }
47
+
48
+ export async function runUpdate(flags) {
49
+ const targetDir = flags.dir || process.cwd();
50
+ const { force = false, check = false } = flags;
51
+
52
+ console.log(`\n context-engineer v${PKG.version}`);
53
+ console.log(' Checking for updates...\n');
54
+
55
+ const installedVersion = loadInstalledVersion(targetDir);
56
+ if (!installedVersion) {
57
+ console.log(' No context-engineer installation detected in this directory.');
58
+ console.log(' Run "context-engineer init" first.\n');
59
+ process.exit(1);
60
+ }
61
+
62
+ console.log(` Installed version: ${installedVersion}`);
63
+ console.log(` Available version: ${PKG.version}\n`);
64
+
65
+ if (installedVersion === PKG.version && !force) {
66
+ console.log(' Already up to date!\n');
67
+ return;
68
+ }
69
+
70
+ const installedGroups = detectInstalledGroups(targetDir);
71
+ const installedChecksums = loadInstalledChecksums(targetDir);
72
+
73
+ // Categorize files: new, modified (user untouched), modified (user customized)
74
+ const newFiles = [];
75
+ const updatable = [];
76
+ const customized = [];
77
+
78
+ for (const groupId of installedGroups) {
79
+ const groupDir = join(TEMPLATES_DIR, groupId);
80
+ if (!existsSync(groupDir)) continue;
81
+
82
+ for (const relPath of walkDir(groupDir)) {
83
+ const destPath = join(targetDir, relPath);
84
+ const srcPath = join(groupDir, relPath);
85
+
86
+ if (!existsSync(destPath)) {
87
+ newFiles.push(relPath);
88
+ } else {
89
+ // Compare current file with new template
90
+ const currentHash = fileHash(destPath);
91
+ const templateHash = fileHash(srcPath);
92
+
93
+ if (currentHash === templateHash) {
94
+ // File already matches new template — no update needed
95
+ continue;
96
+ }
97
+
98
+ // Check if user has customized the file since install
99
+ // Compare user's file against the hash saved at install time
100
+ const originalHash = installedChecksums[relPath];
101
+
102
+ if (originalHash && currentHash === originalHash) {
103
+ // User hasn't modified it since install — safe to update
104
+ updatable.push(relPath);
105
+ } else {
106
+ // User has customized this file, or no install record — don't touch
107
+ customized.push(relPath);
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ // Report
114
+ if (newFiles.length > 0) {
115
+ console.log(` New files (${newFiles.length}):`);
116
+ for (const f of newFiles) console.log(` + ${f}`);
117
+ console.log('');
118
+ }
119
+
120
+ if (updatable.length > 0) {
121
+ console.log(` Updatable files (${updatable.length}):`);
122
+ for (const f of updatable) console.log(` ~ ${f}`);
123
+ console.log('');
124
+ }
125
+
126
+ if (customized.length > 0) {
127
+ console.log(` Customized files — skipped (${customized.length}):`);
128
+ for (const f of customized) console.log(` ! ${f}`);
129
+ console.log('');
130
+ }
131
+
132
+ if (newFiles.length === 0 && updatable.length === 0) {
133
+ console.log(' No updates to apply.\n');
134
+ return;
135
+ }
136
+
137
+ if (check) {
138
+ console.log(' Run without --check to apply updates.\n');
139
+ return;
140
+ }
141
+
142
+ // Confirm
143
+ const totalUpdates = newFiles.length + updatable.length;
144
+ const proceed = force || (await confirm(`Apply ${totalUpdates} update(s)?`));
145
+ if (!proceed) {
146
+ console.log(' Cancelled.\n');
147
+ return;
148
+ }
149
+
150
+ // Apply updates — copy new and updatable files
151
+ let applied = 0;
152
+ const newChecksums = { ...installedChecksums };
153
+
154
+ for (const groupId of installedGroups) {
155
+ const groupDir = join(TEMPLATES_DIR, groupId);
156
+ if (!existsSync(groupDir)) continue;
157
+
158
+ const filesToUpdate = new Set([...newFiles, ...(force ? [...updatable, ...customized] : updatable)]);
159
+
160
+ for (const relPath of walkDir(groupDir)) {
161
+ if (!filesToUpdate.has(relPath)) continue;
162
+ const srcPath = join(groupDir, relPath);
163
+ const destPath = join(targetDir, relPath);
164
+
165
+ // Read and apply version replacement
166
+ let content = readFileSync(srcPath);
167
+ let text = content.toString('utf8');
168
+ text = text.split('__CE_VERSION__').join(PKG.version);
169
+ content = Buffer.from(text, 'utf8');
170
+
171
+ const { mkdirSync } = await import('fs');
172
+ const { dirname: dirnameFn } = await import('path');
173
+ mkdirSync(dirnameFn(destPath), { recursive: true });
174
+ writeFileSync(destPath, content);
175
+ applied++;
176
+
177
+ // Record new checksum for this file
178
+ newChecksums[relPath] = fileHash(destPath);
179
+ }
180
+ }
181
+
182
+ // Save updated checksums
183
+ saveInstalledChecksums(targetDir, newChecksums);
184
+
185
+ // Update version in last-sync.json
186
+ const syncPath = join(targetDir, '.context', '_meta', 'last-sync.json');
187
+ if (existsSync(syncPath)) {
188
+ try {
189
+ const data = JSON.parse(readFileSync(syncPath, 'utf8'));
190
+ data.contextEngineerVersion = PKG.version;
191
+ writeFileSync(syncPath, JSON.stringify(data, null, 2) + '\n');
192
+ } catch {
193
+ // If corrupted, just leave it
194
+ }
195
+ }
196
+
197
+ console.log(` Updated ${applied} file(s) to v${PKG.version}\n`);
198
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "context-engineer",
3
+ "version": "1.1.0",
4
+ "description": "Structured context management for AI coding agents. One command to install the .context/ system into any project.",
5
+ "type": "module",
6
+ "bin": {
7
+ "context-engineer": "./bin/cli.mjs"
8
+ },
9
+ "files": [
10
+ "bin/",
11
+ "lib/",
12
+ "templates/",
13
+ "README.md"
14
+ ],
15
+ "scripts": {
16
+ "prepublishOnly": "bash ../scripts/build-templates.sh"
17
+ },
18
+ "keywords": [
19
+ "ai",
20
+ "context",
21
+ "coding-agent",
22
+ "claude",
23
+ "cursor",
24
+ "copilot",
25
+ "developer-tools"
26
+ ],
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/humanrace-ai/context-engineer"
34
+ }
35
+ }
@@ -0,0 +1,68 @@
1
+ {
2
+ "core/.context/_meta/concepts.md": "74bde5d63183ce8c97d0c95fb3024e3996874d7b79e347d6b7351be8ef71838e",
3
+ "core/.context/_meta/drift-report.md": "670756bfdabc3d65fe627c52af5a6191aea91eca27323a0fcfbe85bc9efa9303",
4
+ "core/.context/_meta/last-sync.json": "c0ebaccd9763f9ae5213ac7fecfffba5569b8603370f27486d7313bf7f3b2edd",
5
+ "core/.context/_meta/schema.md": "4dd77777dc3e04aeef13a7e2475d85648cd772c519ab33eed871876a32eef9ee",
6
+ "core/.context/architecture/api-surface.md": "516c8b014d44267c840a299f78c6313e4df8419cfac500fcb75ff98cff62da52",
7
+ "core/.context/architecture/class-index.md": "b61d6aa3334ac737671c36c1c4ad5e250d50fa4cc4e9e3821baddf880a7d6e5a",
8
+ "core/.context/architecture/data-flow.md": "ac1b2d00627abfa216e0fb890fd8fbcf42547e133cf4b09d733da53c9a380558",
9
+ "core/.context/architecture/data-model.md": "fbfc1d2efb0927c32b543ad907e42791023a3123f35fd2a18da87468a03079e4",
10
+ "core/.context/architecture/decisions/001-template.md": "4f1e6b3295c2bd56feba0cd73816e574cbc17a58d808941bd592ecfc601ebd7d",
11
+ "core/.context/architecture/dependencies.md": "3297acf6570e0ad1d52e0aa87657c7c47ddfcdbd03949d59c422b1def4fb2f37",
12
+ "core/.context/architecture/infrastructure.md": "7eba26389e038d1057bee26776055759213a327a2ebc72cc11811c9043ce1ff3",
13
+ "core/.context/architecture/module-graph.md": "1c60d91a295628624a082b332c5e667564cc4042263c45a77a249270c1ff4619",
14
+ "core/.context/architecture/overview.md": "d15222390f55153144b2b0da6ce75565241105200a7b367c972a17af9a02c8a2",
15
+ "core/.context/business/domain-model.md": "ea5ac20dcce5b511354004c0c8b1c962bc76c707fa16a9457b77862da06bc90e",
16
+ "core/.context/business/glossary.md": "036af6b3f6cec76c07372d094a6cc0bb10fa4151149e6f65cb19d02bdae2d98c",
17
+ "core/.context/business/overview.md": "40132a96c4d83fb2b0cd5b8655cb6dc841c55910c2c95cd7f81988ded2267e67",
18
+ "core/.context/business/workflows.md": "c8ce4c76cc8f1f6d977401defa779f34d408b3d553c27f262469b807f2f8b1f8",
19
+ "core/.context/constitution.md": "a183a06c165ff88a32c72a966bf4aeec2c25d10ab6b12ac945fa29433469ed1a",
20
+ "core/.context/conventions/code-style.md": "59eb4f1022a74eaf55abf0135c302d9845187a348576bd048636782883e53766",
21
+ "core/.context/conventions/error-handling.md": "0d3e8805184fdb72c3dd465348f67cdbeb949f3153e7561f60bb6b07bd1f997b",
22
+ "core/.context/conventions/git.md": "043bf571cfb9477b9e4c1bf26df850c1ee9335de96bda8f0be4fffcfb3dc3163",
23
+ "core/.context/conventions/patterns.md": "abeb6602a1d38d7f50ce1c0ee55e63aa8c9b09109b73784416d0d325431b1bd1",
24
+ "core/.context/conventions/testing.md": "28db44f669a45cdeab8ecb796e621ed155503bdbd0168891d8bf2c94c044f4b4",
25
+ "core/.context/experience/debugging.md": "4467601549dbee4c3965a0e5857f9bef9877e879d8c7635a0e31676096d814b6",
26
+ "core/.context/experience/incidents.md": "2592bb9e3ac9cff1d4e642be9b452ac24c5a830b552d8ab61352db7d804c46e3",
27
+ "core/.context/experience/lessons.md": "920d084c61bc70da67689b43e54effd54038f442460f2f222b11a29c2f85c050",
28
+ "core/.context/experience/performance.md": "a1c8f4ba4f1dbdf158b78851945aaef299f31e6df4d288d4b9ba7f2be58221b0",
29
+ "core/.context/index.md": "a68cf7d7ffdc11082d79cbabb7d38e9f5e9f53d3fc2b88945f73062623fb1853",
30
+ "core/.context/progress/backlog.md": "fae3bdd0cfe38ecd60536325a2e3ab9ce23ac7909afbeb5766244b53180efc47",
31
+ "core/.context/progress/status.md": "8f3c32fd4f14268195e32d9ba4ef8aaf9aad85773fb5a7490c08db548d99abee",
32
+ "core/.context/workflow/artifacts/.gitkeep": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
33
+ "core/.context/workflow/config.md": "5dba519335d71b10df8f984ca11a06fa72adef9c864f2bfffc5d49195a1a91a7",
34
+ "core/AGENTS.md": "b41364e3aac1452a6839e2eff3b245478074a4c4e44d4b2c3f698cb9bb682cb8",
35
+ "core/scripts/compact-experience.sh": "b115333c6c77c3f76c843c2b6b47a9818d5149937a9c94544d7753947af7110b",
36
+ "core/scripts/detect-drift.sh": "0ab98593fe021b7e1f44d9d28dd42f6b3ece565b7033f3e084fe22fcda79e917",
37
+ "core/scripts/extract-structure.sh": "feaa0eea0a1154a1c519cdf213c15e70f28fdb5f6f090bbf4c786576c985b3b9",
38
+ "core/scripts/sync-context.sh": "b4753ce08c31a9308fd9d57acddfdf610033a70fbce77bd8b34077e056e2b3e7",
39
+ "claude/.claude/rules/context-maintenance.md": "a712145925641c54430a9cd3d0c56e807335493a1a826fab293e411ae4c7355d",
40
+ "claude/.claude/rules/experience-capture.md": "594856ba750e021e38c17547d66730538b87d793dc2f4bb02bc5b0766064967f",
41
+ "claude/.claude/settings.project.json": "1c2bbf83059dd4b0e30327e101ea4bf2c9cd592c7dabc7b3f97f5908fd5c56cc",
42
+ "claude/.claude/skills/bootstrap/SKILL.md": "7a1bda7ab0376188e261269a5d058083e21facc4834e6dd4c9190cc159695eb6",
43
+ "claude/.claude/skills/dev-capture/SKILL.md": "724bd8bbedb7f8b7311155f5e209c3964bc02ea39685973e7d22fd16f3f2bfd4",
44
+ "claude/.claude/skills/dev-commit/SKILL.md": "dc6b42e1f5264086d32a9942c820f8cf263408acdfb337a49d8d26eef7543424",
45
+ "claude/.claude/skills/dev-decompose/SKILL.md": "a4437cc742a11f6983bdaa4ad1c4849f5df1c51fa22619213d53190544782986",
46
+ "claude/.claude/skills/dev-deps/SKILL.md": "a279612324b00375975ef06b0530fefb5b5734573c78f019ff8d342c3a3067b1",
47
+ "claude/.claude/skills/dev-execute/SKILL.md": "8b74b031542210f5459d3792ff90069fdab0ab49dd0a4a7cde6a482f66407e1f",
48
+ "claude/.claude/skills/dev-prd/SKILL.md": "272effef0590d7a78693c2dc32e5f5781e670c2a5ab3131e92d16407ce93bf99",
49
+ "claude/.claude/skills/dev-quality/SKILL.md": "2ba7700b39fb6f6f37b8f8000a44ac4217d715fcf0d1f64391806f956326fc2d",
50
+ "claude/.claude/skills/dev-requirements/SKILL.md": "8b17af7c0a381d774ddd9a74d4fa9708498b075d7a7248fa6cbd460ed79c8ca0",
51
+ "claude/.claude/skills/dev/SKILL.md": "ff82a44d8f9e177fcdee277a9969336457f8bbcd3461a709634bd3d2bee71c78",
52
+ "claude/.claude/skills/review-context/SKILL.md": "49716a96b75d6e78dbe2405bf835ce31e432ee5eb9c146b19c0592707de18231",
53
+ "claude/.claude/skills/sync/SKILL.md": "00c51e26c8b945810901831324086344d7ca9bb391796fb14afe0ee2a4c8ed33",
54
+ "claude/.claude/skills/update-context/SKILL.md": "203be9a9ba9dcaf97ef04973d3107192cb5bc3a98ba5a2a23409f676a6208c44",
55
+ "claude/.claude/workflow/agents/implementer.md": "ca1329f1a23f6359f4a1167804c9a2c8a0eb749bc3bd06dcdb0eeaf2e0506ba7",
56
+ "claude/.claude/workflow/agents/reviewer.md": "335c8f2c49ecbd8c8304943c991c68ab8a7e39e8f32a57f522eeaa99dc623c56",
57
+ "claude/.claude/workflow/agents/team-config.md": "679a73ce17cd4dd0cbabf69ed665e840f4a21dc9b5f659c4bcd20c8e7b15f9a5",
58
+ "claude/.claude/workflow/agents/tester.md": "93b56bd201a6950e5a4cb66f5f0352a18b8c66c5619efd10fa84d7361c6bdff4",
59
+ "claude/.claude/workflow/interfaces/phase-contract.md": "9bfcb73a9ea23cac0a44a0b8fc77babda24450bd84b12fbe5b115b1c9a3b3b64",
60
+ "claude/CLAUDE.md": "a81997371fd35fec37fe38367f08d13256f68bd540a8bb126d908bbf4d2cc11d",
61
+ "cursor/.cursor/rules/always.mdc": "e653939afb8638e8ddd3bd081e8209632a8e004b466b8243029ea0fb77d2199f",
62
+ "cursor/.cursor/rules/backend.mdc": "1c42070f1a45ee2eafb2c24b9cc1da8e252c57a55941564134a07a9227e6336f",
63
+ "cursor/.cursor/rules/database.mdc": "844db9201176eb98281677828515242e6062e99f0e6091ed53660b78a72d3994",
64
+ "cursor/.cursor/rules/frontend.mdc": "1323496c8bbe14bd313d256282313716b44f5cabbd50ab743fa0e919bf4a3a37",
65
+ "cursor/.cursorrules": "83a03ad02ee0ebb61e6c9ee2f2a2df87aa2c969bd4bd7776320ac18985e83dba",
66
+ "github/.github/copilot-instructions.md": "5c9bc4166f203a41c99f99fd6ded0c0fae7ee8586da16db2b7346ff4ab763584",
67
+ "github/.github/workflows/context-drift.yml": "b434e322a528816f39588e91221d4fc2af100685fd824e5fa70361564ac9d33b"
68
+ }
@@ -0,0 +1,38 @@
1
+ ---
2
+ description: "Enforce context file maintenance when code changes affect documented areas"
3
+ ---
4
+
5
+ # Context Maintenance Rule
6
+
7
+ ## When Modifying Code
8
+
9
+ After writing or editing files, check if the changes affect any documented areas:
10
+
11
+ | If you changed... | Then update... |
12
+ |-------------------|---------------|
13
+ | Database models, migrations, schema files | `.context/architecture/data-model.md` |
14
+ | API routes, controllers, endpoints | `.context/architecture/api-surface.md` |
15
+ | Package manifests (package.json, *.csproj, etc.) | `.context/architecture/dependencies.md` |
16
+ | System architecture, major structural changes | `.context/architecture/overview.md` |
17
+ | Module boundaries, added/removed/moved modules | `.context/architecture/module-graph.md` |
18
+ | Data pipelines, processing flows, threading | `.context/architecture/data-flow.md` |
19
+ | Core classes, interfaces, inheritance hierarchies | `.context/architecture/class-index.md` (regenerate via `scripts/extract-structure.sh`) |
20
+ | CI/CD configs, Docker files, deployment configs | `.context/architecture/infrastructure.md` |
21
+ | Introduced new design patterns | `.context/conventions/patterns.md` |
22
+ | Changed error handling approach | `.context/conventions/error-handling.md` |
23
+
24
+ ## For Auto-Generated Files
25
+
26
+ Files marked with `<!-- AUTO-GENERATED -->` should be regenerated using `scripts/sync-context.sh` rather than edited manually. These include:
27
+ - `architecture/data-model.md`
28
+ - `architecture/api-surface.md`
29
+ - `architecture/dependencies.md`
30
+ - `architecture/class-index.md` (also regenerable via `scripts/extract-structure.sh`)
31
+
32
+ ## Update Progress
33
+
34
+ Before ending a session or when context compaction occurs, update `.context/progress/status.md` with:
35
+ - Current task status
36
+ - What was done
37
+ - What remains
38
+ - Key decisions made
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: "Capture development experience and knowledge after significant events"
3
+ ---
4
+
5
+ # Experience Capture Rule
6
+
7
+ ## After Fixing a Non-Trivial Bug
8
+
9
+ Append an entry to `.context/experience/debugging.md`:
10
+ ```markdown
11
+ ### "[Error Message or Symptom]"
12
+ - **Cause**: [Why this happened]
13
+ - **Fix**: [How it was resolved]
14
+ - **Prevention**: [How to avoid in future]
15
+ ```
16
+
17
+ ## After Resolving a Performance Issue
18
+
19
+ Append an entry to `.context/experience/performance.md`:
20
+ ```markdown
21
+ ### YYYY-MM-DD: [Optimization Title]
22
+ - **Before**: [Metric before]
23
+ - **After**: [Metric after]
24
+ - **What Changed**: [What was optimized]
25
+ - **Tags**: #tag1 #tag2
26
+ ```
27
+
28
+ ## After Making a Significant Architectural Decision
29
+
30
+ Create a new ADR file in `.context/architecture/decisions/`:
31
+ - Use the next available number (e.g., `002-decision-name.md`)
32
+ - Follow the template in `001-template.md`
33
+
34
+ ## After Discovering a Lesson or Anti-Pattern
35
+
36
+ Append to `.context/experience/lessons.md`:
37
+ ```markdown
38
+ ### YYYY-MM-DD: [Short Title]
39
+ - **Context**: [What was happening]
40
+ - **Root Cause**: [Why it happened]
41
+ - **Resolution**: [How it was fixed]
42
+ - **Prevention**: [Steps taken to prevent recurrence]
43
+ - **Tags**: #tag1 #tag2
44
+ ```
45
+
46
+ If a lesson reveals a pattern worth codifying, also add it to `.context/conventions/patterns.md`.
@@ -0,0 +1,22 @@
1
+ {
2
+ "hooks": {
3
+ "PostToolUse": [
4
+ {
5
+ "matcher": "Write|Edit",
6
+ "command": "echo '[Context Reminder] If this change affects architecture, data models, APIs, or conventions, remember to update the corresponding .context/ file.'"
7
+ }
8
+ ],
9
+ "SessionStart": [
10
+ {
11
+ "matcher": "compact",
12
+ "command": "cat .context/constitution.md 2>/dev/null || echo 'No constitution.md found. Run /bootstrap-context to initialize.'"
13
+ }
14
+ ],
15
+ "PreToolUse": [
16
+ {
17
+ "matcher": "Bash(git commit*)",
18
+ "command": "bash scripts/detect-drift.sh 2>/dev/null || echo '[Drift Detection] Script not found or failed. Consider running: bash scripts/detect-drift.sh'"
19
+ }
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,223 @@
1
+ ---
2
+ name: bootstrap-context
3
+ description: Build the .context/ system for a new or undocumented project by analyzing the existing codebase
4
+ triggers:
5
+ - bootstrap context
6
+ - setup context
7
+ - initialize context
8
+ - build context
9
+ ---
10
+
11
+ # Bootstrap Context Skill
12
+
13
+ Build a comprehensive `.context/` system for the current project by analyzing the existing codebase, documentation, and git history. This follows the ACE-FCA Research-Plan-Implement pattern.
14
+
15
+ ## Prerequisites
16
+
17
+ - The `.context/` directory structure must exist (copy from the ContextEngineer template)
18
+ - The project should have existing source code to analyze
19
+
20
+ ## Workflow
21
+
22
+ Execute bootstrap in **3 rounds with human checkpoints** between each round. This prevents errors from compounding and ensures the foundation is correct before building on it.
23
+
24
+ ---
25
+
26
+ ### Round 1: Foundation (Skeleton)
27
+
28
+ **Goal**: Establish project identity, tech stack, and high-level architecture.
29
+
30
+ #### 1a. Discovery
31
+
32
+ 1. **Project Structure Scan**
33
+ - Use Glob to map the complete directory structure
34
+ - Identify source code directories, test directories, config files, documentation
35
+
36
+ 2. **Tech Stack Detection**
37
+ - Scan for manifest files to identify languages and frameworks:
38
+ - `package.json` → Node.js/TypeScript (check for Express, NestJS, React, Vue, Angular)
39
+ - `*.csproj` / `*.sln` → .NET/C# (check for ASP.NET Core, EF Core)
40
+ - `requirements.txt` / `pyproject.toml` / `setup.py` → Python (check for Django, FastAPI, Flask)
41
+ - `go.mod` → Go
42
+ - `Cargo.toml` → Rust
43
+ - `pom.xml` / `build.gradle` → Java (check for Spring Boot)
44
+ - Read the manifest files to extract dependency lists
45
+
46
+ 3. **Existing Documentation**
47
+ - Read README.md, CONTRIBUTING.md, docs/ folder
48
+ - Check for existing CLAUDE.md, AGENTS.md, .cursorrules
49
+ - Check for OpenAPI/Swagger specs
50
+
51
+ #### 1b. Generate
52
+
53
+ 1. **`.context/constitution.md`** — Fill in:
54
+ - Project Identity (name, tech stack, language, repo)
55
+ - Non-negotiable Principles (inferred from code patterns + linting config)
56
+ - Build & Test Commands (from manifest files and scripts)
57
+ - Keep the Context Loading Route Table as-is (it's universal)
58
+
59
+ 2. **`.context/architecture/overview.md`** — Fill in:
60
+ - Tech stack table
61
+ - System architecture diagram (ASCII)
62
+ - Directory structure description
63
+ - Subsystem breakdown (one-line per subsystem)
64
+ - Key interfaces between subsystems
65
+ - Threading/concurrency model
66
+ - Key design decisions
67
+
68
+ #### 1c. Checkpoint
69
+
70
+ **STOP and present to the user:**
71
+ - Show the generated `constitution.md` and `overview.md`
72
+ - Ask the user to verify: project identity, tech stack, build commands, architecture description
73
+ - Ask: "Are the non-negotiable principles correct? Anything to add or remove?"
74
+ - **Do NOT proceed to Round 2 until the user confirms Round 1 is accurate.**
75
+
76
+ ---
77
+
78
+ ### Round 2: Architecture & Conventions (Detail)
79
+
80
+ **Goal**: Fill in detailed architecture docs and coding conventions.
81
+
82
+ #### 2a. Discovery
83
+
84
+ 4. **Code Pattern Analysis**
85
+ - Sample 5-10 representative source files across different layers
86
+ - Identify: naming conventions, file organization, error handling patterns
87
+ - Look for architectural patterns (MVC, Clean Architecture, CQRS, etc.)
88
+
89
+ 5. **Data Model Extraction**
90
+ - Search for ORM models, migration files, schema definitions
91
+ - Extract entities, relationships, key fields
92
+
93
+ 6. **API Surface Mapping**
94
+ - Search for route/controller definitions
95
+ - Extract endpoints, HTTP methods, path patterns
96
+
97
+ 7. **Git History Analysis**
98
+ - Check recent 20-50 commits for: commit message conventions, branch patterns
99
+ - Identify active contributors and development pace
100
+
101
+ 8. **Module Boundary Discovery**
102
+ - Scan all top-level source directories to identify subsystems/modules
103
+ - Analyze namespace, package, and directory structure
104
+ - Map directory → module → namespace relationships
105
+
106
+ 9. **Dependency Graph Extraction**
107
+ - Analyze #include / import / using statements across the codebase
108
+ - Build a module-level dependency graph (not file-level)
109
+ - Use `scripts/extract-structure.sh --module-graph` for automated extraction
110
+
111
+ 10. **Data Flow Analysis**
112
+ - Identify key execution paths (main → initialization → main loop → cleanup)
113
+ - Trace data transformation pipelines
114
+ - Identify async/multi-threaded data flows and synchronization points
115
+
116
+ 11. **Core Interface Extraction**
117
+ - Identify each module's public interface classes/functions
118
+ - Extract key inheritance hierarchies
119
+ - Use `scripts/extract-structure.sh --class-index` for automated extraction
120
+ - Focus on core classes only (5-15 per module)
121
+
122
+ #### 2b. Generate
123
+
124
+ 3. **`.context/architecture/module-graph.md`** — Fill in human-curated sections:
125
+ - Subsystems table (module, directory, responsibility, key classes)
126
+ - ASCII dependency graph
127
+ - Module interfaces (public entry points, depends on, depended by)
128
+ - Auto-generated sections via `scripts/extract-structure.sh`
129
+
130
+ 4. **`.context/architecture/data-flow.md`** — Fill in:
131
+ - Application lifecycle (startup → run → shutdown)
132
+ - Core pipelines with stage diagrams
133
+ - Threading/concurrency model with synchronization points
134
+ - Event/message flow if applicable
135
+
136
+ 5. **`.context/architecture/class-index.md`** — Auto-generate:
137
+ - Run `scripts/extract-structure.sh --class-index`
138
+ - Mark as `<!-- AUTO-GENERATED -->`
139
+
140
+ 6. **`.context/architecture/data-model.md`** — Auto-generate:
141
+ - Tables/collections list and relationships
142
+ - Mark as `<!-- AUTO-GENERATED -->`
143
+
144
+ 7. **`.context/architecture/api-surface.md`** — Auto-generate:
145
+ - Endpoints list with methods, paths, descriptions
146
+ - Mark as `<!-- AUTO-GENERATED -->`
147
+
148
+ 8. **`.context/architecture/dependencies.md`** — Auto-generate:
149
+ - Runtime and dev dependency lists
150
+ - Mark as `<!-- AUTO-GENERATED -->`
151
+
152
+ 9. **`.context/conventions/code-style.md`** — Infer from code:
153
+ - Naming conventions, formatting rules, import ordering
154
+
155
+ 10. **`.context/conventions/patterns.md`** — Infer from code:
156
+ - Identified architectural patterns and common code patterns
157
+
158
+ 11. **`.context/conventions/testing.md`** — Infer from test files:
159
+ - Testing framework, test file naming, test structure
160
+
161
+ 12. **`.context/conventions/git.md`** — Infer from git history:
162
+ - Commit message convention, branch naming patterns
163
+
164
+ 13. **`.context/business/overview.md`** — Infer from README + code:
165
+ - Product description (note: usually needs human input)
166
+
167
+ 14. **`.context/business/workflows.md`** — Fill in:
168
+ - Core business workflows (for web/business apps)
169
+ - Technical pipelines (for engines/frameworks/tools)
170
+
171
+ #### 2c. Checkpoint
172
+
173
+ **STOP and present to the user:**
174
+ - Summary of all generated files with confidence levels (high/medium/low)
175
+ - Highlight areas that need human input (especially business context)
176
+ - Note any uncertainties or ambiguities found
177
+ - Ask: "Please review the architecture and conventions. Any corrections?"
178
+ - **Do NOT proceed to Round 3 until the user confirms Round 2 is acceptable.**
179
+
180
+ ---
181
+
182
+ ### Round 3: Finalize (Adapters & Metadata)
183
+
184
+ **Goal**: Generate tool-specific adapters, update metadata, establish baseline.
185
+
186
+ #### 3a. Generate
187
+
188
+ 15. **`.context/index.md`** — Update to reflect actual content generated
189
+
190
+ 16. **Tool Adapters** — Generate after human validation:
191
+ - Update AGENTS.md with project-specific information
192
+ - Update CLAUDE.md with Claude-specific guidance
193
+ - Update .cursor/rules/*.mdc with Cursor-specific rules
194
+
195
+ #### 3b. Metadata
196
+
197
+ - Update `.context/_meta/last-sync.json` with timestamps
198
+ - Run `scripts/detect-drift.sh --semantic` to establish baseline
199
+
200
+ #### 3c. Final Report
201
+
202
+ Present completion summary:
203
+ - Total files generated, with confidence levels
204
+ - Remaining action items (files needing human input)
205
+ - Baseline drift report status
206
+
207
+ ---
208
+
209
+ ## File Markers
210
+
211
+ For each generated file, always add:
212
+ - `<!-- confidence: high|medium|low -->` based on analysis certainty
213
+ - `<!-- source: [files analyzed] -->` for traceability
214
+ - `<!-- last-updated: YYYY-MM-DD -->` with today's date
215
+
216
+ ## Output
217
+
218
+ The skill produces a fully populated `.context/` system with:
219
+ - All context files filled with analyzed content
220
+ - Confidence markers on every file
221
+ - Source traceability comments
222
+ - Tool-specific adapter files configured
223
+ - Updated metadata and baseline drift report