flight-rules 0.5.9

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 (35) hide show
  1. package/README.md +270 -0
  2. package/dist/commands/adapter.d.ts +35 -0
  3. package/dist/commands/adapter.js +308 -0
  4. package/dist/commands/init.d.ts +1 -0
  5. package/dist/commands/init.js +197 -0
  6. package/dist/commands/upgrade.d.ts +1 -0
  7. package/dist/commands/upgrade.js +255 -0
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +83 -0
  10. package/dist/utils/files.d.ts +75 -0
  11. package/dist/utils/files.js +245 -0
  12. package/dist/utils/interactive.d.ts +5 -0
  13. package/dist/utils/interactive.js +7 -0
  14. package/package.json +52 -0
  15. package/payload/.editorconfig +15 -0
  16. package/payload/AGENTS.md +247 -0
  17. package/payload/commands/dev-session.end.md +79 -0
  18. package/payload/commands/dev-session.start.md +54 -0
  19. package/payload/commands/impl.create.md +178 -0
  20. package/payload/commands/impl.outline.md +120 -0
  21. package/payload/commands/prd.clarify.md +139 -0
  22. package/payload/commands/prd.create.md +154 -0
  23. package/payload/commands/test.add.md +73 -0
  24. package/payload/commands/test.assess-current.md +75 -0
  25. package/payload/doc-templates/critical-learnings.md +21 -0
  26. package/payload/doc-templates/implementation/overview.md +27 -0
  27. package/payload/doc-templates/prd.md +49 -0
  28. package/payload/doc-templates/progress.md +19 -0
  29. package/payload/doc-templates/session-log.md +62 -0
  30. package/payload/doc-templates/tech-stack.md +101 -0
  31. package/payload/prompts/.gitkeep +0 -0
  32. package/payload/prompts/implementation/README.md +26 -0
  33. package/payload/prompts/implementation/plan-review.md +80 -0
  34. package/payload/prompts/prd/README.md +46 -0
  35. package/payload/prompts/prd/creation-conversational.md +46 -0
@@ -0,0 +1,245 @@
1
+ import { existsSync, mkdirSync, cpSync, createWriteStream, rmSync, readdirSync, readFileSync, writeFileSync } from 'fs';
2
+ import { join, dirname } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+ import { tmpdir } from 'os';
5
+ import { pipeline } from 'stream/promises';
6
+ import * as tar from 'tar';
7
+ const __filename = fileURLToPath(import.meta.url);
8
+ const __dirname = dirname(__filename);
9
+ const GITHUB_REPO = 'ryanpacker/flight-rules';
10
+ /**
11
+ * Get the CLI version from package.json
12
+ */
13
+ export function getCliVersion() {
14
+ // Structure: flight-rules/dist/utils/files.js
15
+ // Go up 2 levels to get to flight-rules/, then read package.json
16
+ const projectRoot = dirname(dirname(__dirname));
17
+ const packageJsonPath = join(projectRoot, 'package.json');
18
+ try {
19
+ const content = readFileSync(packageJsonPath, 'utf-8');
20
+ const pkg = JSON.parse(content);
21
+ return pkg.version || 'unknown';
22
+ }
23
+ catch {
24
+ return 'unknown';
25
+ }
26
+ }
27
+ /**
28
+ * Get the path to the payload directory (the Flight Rules content to install)
29
+ */
30
+ export function getPayloadPath() {
31
+ // Structure: flight-rules/dist/utils/files.js
32
+ // Go up 2 levels to get to flight-rules/, then into payload/
33
+ const projectRoot = dirname(dirname(__dirname));
34
+ return join(projectRoot, 'payload');
35
+ }
36
+ /**
37
+ * Check if Flight Rules is already installed in the target directory
38
+ */
39
+ export function isFlightRulesInstalled(targetDir) {
40
+ return existsSync(join(targetDir, '.flight-rules'));
41
+ }
42
+ /**
43
+ * Get the .flight-rules directory path in the target
44
+ */
45
+ export function getFlightRulesDir(targetDir) {
46
+ return join(targetDir, '.flight-rules');
47
+ }
48
+ /**
49
+ * Copy the payload to the target directory as .flight-rules
50
+ */
51
+ export function copyPayload(targetDir) {
52
+ const payloadPath = getPayloadPath();
53
+ const destPath = getFlightRulesDir(targetDir);
54
+ if (!existsSync(payloadPath)) {
55
+ throw new Error(`Payload not found at ${payloadPath}`);
56
+ }
57
+ cpSync(payloadPath, destPath, { recursive: true });
58
+ }
59
+ /**
60
+ * Copy only framework files (not docs/) during upgrade
61
+ */
62
+ export function copyFrameworkFiles(targetDir) {
63
+ const payloadPath = getPayloadPath();
64
+ const destPath = getFlightRulesDir(targetDir);
65
+ // Files/directories that are safe to replace on upgrade
66
+ const frameworkItems = [
67
+ 'AGENTS.md',
68
+ 'doc-templates',
69
+ 'commands',
70
+ 'prompts'
71
+ ];
72
+ for (const item of frameworkItems) {
73
+ const srcItem = join(payloadPath, item);
74
+ const destItem = join(destPath, item);
75
+ if (existsSync(srcItem)) {
76
+ cpSync(srcItem, destItem, { recursive: true });
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Ensure a directory exists
82
+ */
83
+ export function ensureDir(dir) {
84
+ if (!existsSync(dir)) {
85
+ mkdirSync(dir, { recursive: true });
86
+ }
87
+ }
88
+ /**
89
+ * Fetch the Flight Rules payload from GitHub
90
+ * @param version - Git ref to fetch (tag like 'v0.1.4', branch like 'main', or 'latest' for main)
91
+ * @returns Object with payloadPath, version string, and cleanup function
92
+ */
93
+ export async function fetchPayloadFromGitHub(version) {
94
+ const ref = (!version || version === 'latest') ? 'main' : version.startsWith('v') ? version : `v${version}`;
95
+ const tarballUrl = `https://github.com/${GITHUB_REPO}/tarball/${ref}`;
96
+ // Create temp directory
97
+ const tempDir = join(tmpdir(), `flight-rules-${Date.now()}`);
98
+ mkdirSync(tempDir, { recursive: true });
99
+ const tarballPath = join(tempDir, 'payload.tar.gz');
100
+ const extractDir = join(tempDir, 'extracted');
101
+ mkdirSync(extractDir, { recursive: true });
102
+ const cleanup = () => {
103
+ try {
104
+ rmSync(tempDir, { recursive: true, force: true });
105
+ }
106
+ catch {
107
+ // Ignore cleanup errors
108
+ }
109
+ };
110
+ try {
111
+ // Download tarball
112
+ const response = await fetch(tarballUrl, {
113
+ headers: { 'Accept': 'application/vnd.github+json' },
114
+ redirect: 'follow',
115
+ });
116
+ if (!response.ok) {
117
+ if (response.status === 404) {
118
+ throw new Error(`Version '${ref}' not found. Check available versions at https://github.com/${GITHUB_REPO}/tags`);
119
+ }
120
+ throw new Error(`Failed to download from GitHub: ${response.status} ${response.statusText}`);
121
+ }
122
+ if (!response.body) {
123
+ throw new Error('No response body received from GitHub');
124
+ }
125
+ // Write tarball to disk using Readable.fromWeb for proper stream compatibility
126
+ const { Readable } = await import('stream');
127
+ const fileStream = createWriteStream(tarballPath);
128
+ const nodeStream = Readable.fromWeb(response.body);
129
+ await pipeline(nodeStream, fileStream);
130
+ // Extract tarball
131
+ await tar.extract({
132
+ file: tarballPath,
133
+ cwd: extractDir,
134
+ });
135
+ // Find the extracted directory (GitHub creates a directory like 'user-repo-hash')
136
+ const extractedDirs = readdirSync(extractDir);
137
+ if (extractedDirs.length === 0) {
138
+ throw new Error('No files extracted from tarball');
139
+ }
140
+ const repoDir = join(extractDir, extractedDirs[0]);
141
+ const payloadPath = join(repoDir, 'payload');
142
+ if (!existsSync(payloadPath)) {
143
+ throw new Error('Payload directory not found in downloaded content');
144
+ }
145
+ // Read version from AGENTS.md
146
+ let detectedVersion = ref;
147
+ try {
148
+ const agentsMd = readFileSync(join(payloadPath, 'AGENTS.md'), 'utf-8');
149
+ const versionMatch = agentsMd.match(/flight_rules_version:\s*([\d.]+)/);
150
+ if (versionMatch) {
151
+ detectedVersion = versionMatch[1];
152
+ }
153
+ }
154
+ catch {
155
+ // Ignore version detection errors
156
+ }
157
+ return {
158
+ payloadPath,
159
+ version: detectedVersion,
160
+ cleanup,
161
+ };
162
+ }
163
+ catch (error) {
164
+ cleanup();
165
+ throw error;
166
+ }
167
+ }
168
+ /**
169
+ * Copy framework files from a source payload directory (used by both local and remote)
170
+ */
171
+ export function copyFrameworkFilesFrom(sourcePayloadPath, targetDir) {
172
+ const destPath = getFlightRulesDir(targetDir);
173
+ // Files/directories that are safe to replace on upgrade
174
+ const frameworkItems = [
175
+ 'AGENTS.md',
176
+ 'doc-templates',
177
+ 'commands',
178
+ 'prompts'
179
+ ];
180
+ for (const item of frameworkItems) {
181
+ const srcItem = join(sourcePayloadPath, item);
182
+ const destItem = join(destPath, item);
183
+ if (existsSync(srcItem)) {
184
+ cpSync(srcItem, destItem, { recursive: true });
185
+ }
186
+ }
187
+ }
188
+ /**
189
+ * Copy entire payload from a source directory (used by both local and remote)
190
+ */
191
+ export function copyPayloadFrom(sourcePayloadPath, targetDir) {
192
+ const destPath = getFlightRulesDir(targetDir);
193
+ if (!existsSync(sourcePayloadPath)) {
194
+ throw new Error(`Payload not found at ${sourcePayloadPath}`);
195
+ }
196
+ cpSync(sourcePayloadPath, destPath, { recursive: true });
197
+ }
198
+ /**
199
+ * Read the manifest.json from a Flight Rules installation
200
+ * @returns The manifest data, or null if not found
201
+ */
202
+ export function readManifest(targetDir) {
203
+ const manifestPath = join(getFlightRulesDir(targetDir), 'manifest.json');
204
+ if (!existsSync(manifestPath)) {
205
+ return null;
206
+ }
207
+ try {
208
+ const content = readFileSync(manifestPath, 'utf-8');
209
+ return JSON.parse(content);
210
+ }
211
+ catch {
212
+ return null;
213
+ }
214
+ }
215
+ /**
216
+ * Write the manifest.json to a Flight Rules installation
217
+ */
218
+ export function writeManifest(targetDir, data) {
219
+ const manifestPath = join(getFlightRulesDir(targetDir), 'manifest.json');
220
+ writeFileSync(manifestPath, JSON.stringify(data, null, 2) + '\n', 'utf-8');
221
+ }
222
+ /**
223
+ * Get the current version from manifest, falling back to AGENTS.md
224
+ * @returns The version string, or null if not found
225
+ */
226
+ export function getInstalledVersion(targetDir) {
227
+ // Try manifest first
228
+ const manifest = readManifest(targetDir);
229
+ if (manifest) {
230
+ return manifest.version;
231
+ }
232
+ // Fall back to AGENTS.md for older installations
233
+ const agentsMdPath = join(getFlightRulesDir(targetDir), 'AGENTS.md');
234
+ if (!existsSync(agentsMdPath)) {
235
+ return null;
236
+ }
237
+ try {
238
+ const content = readFileSync(agentsMdPath, 'utf-8');
239
+ const match = content.match(/flight_rules_version:\s*([\d.]+)/);
240
+ return match ? match[1] : null;
241
+ }
242
+ catch {
243
+ return null;
244
+ }
245
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Check if the CLI is running in an interactive terminal.
3
+ * Returns false in CI environments, piped output, or when called by agents.
4
+ */
5
+ export declare function isInteractive(): boolean;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if the CLI is running in an interactive terminal.
3
+ * Returns false in CI environments, piped output, or when called by agents.
4
+ */
5
+ export function isInteractive() {
6
+ return process.stdout.isTTY === true;
7
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "flight-rules",
3
+ "version": "0.5.9",
4
+ "description": "An opinionated framework for AI-assisted software development",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "flight-rules": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "payload"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/ryanpacker/flight-rules.git"
17
+ },
18
+ "publishConfig": {
19
+ "tag": "dev"
20
+ },
21
+ "scripts": {
22
+ "build": "tsc",
23
+ "dev": "tsc --watch",
24
+ "start": "node dist/index.js",
25
+ "test": "vitest run",
26
+ "test:watch": "vitest",
27
+ "test:coverage": "vitest run --coverage",
28
+ "prepublishOnly": "npm run build",
29
+ "version": "npm run build && node scripts/sync-version.js && git add payload/AGENTS.md dist/"
30
+ },
31
+ "keywords": [
32
+ "cli",
33
+ "ai",
34
+ "development",
35
+ "agents",
36
+ "documentation"
37
+ ],
38
+ "author": "",
39
+ "license": "MIT",
40
+ "devDependencies": {
41
+ "@types/node": "^20.10.0",
42
+ "@types/tar": "^6.1.13",
43
+ "@vitest/coverage-v8": "^4.0.16",
44
+ "typescript": "^5.3.0",
45
+ "vitest": "^4.0.16"
46
+ },
47
+ "dependencies": {
48
+ "@clack/prompts": "^0.7.0",
49
+ "picocolors": "^1.0.0",
50
+ "tar": "^7.5.2"
51
+ }
52
+ }
@@ -0,0 +1,15 @@
1
+ # EditorConfig helps maintain consistent coding styles
2
+ # https://editorconfig.org
3
+
4
+ root = true
5
+
6
+ [*]
7
+ insert_final_newline = true
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+
@@ -0,0 +1,247 @@
1
+ # Flight Rules – Agent Guidelines
2
+
3
+ flight_rules_version: 0.5.9
4
+
5
+ This file defines how agents (Claude Code, Cursor, etc.) should work on software projects using the Flight Rules system.
6
+
7
+ It explains:
8
+ - How project docs are structured
9
+ - How implementation specs work
10
+ - How to use start / end coding sessions
11
+ - Where progress and learnings are tracked
12
+
13
+ The goal: any agent (or human) should be able to understand the project's lifecycle and contribute without guesswork.
14
+
15
+ ---
16
+
17
+ ## 1. High-level lifecycle
18
+
19
+ Assume the following lifecycle for projects:
20
+
21
+ 1. **Idea & PRD** – captured in `docs/prd.md`
22
+ 2. **Implementation specs (iterative)** – The spec system (Areas → Task Groups → Tasks) lives under `docs/implementation/`. Usually, Areas and Task Groups are drafted first, but individual Tasks are typically fleshed out incrementally, often at the start of each coding session as part of setting the plan for that session.
23
+
24
+ 3. **Coding sessions** – At the beginning of a session, identify or refine the relevant Tasks within a Task Group, make a clear plan for implementation, and then execute against that plan.
25
+ - Each session should produce:
26
+ - Detailed documentation in `docs/session_logs/`
27
+ - A brief summary/log entry in `docs/progress.md` also links to the details in `session_logs`.
28
+ 4. **Critical learnings** – promoted into `docs/critical-learnings.md`
29
+ 5. **Commits & releases** – Git history + tags/releases reflect implementation of the specs
30
+
31
+ Agents should prefer working *with* this system rather than inventing their own structure.
32
+
33
+ ---
34
+
35
+ ## 2. Project structure
36
+
37
+ Projects using Flight Rules have two key locations:
38
+
39
+ ### `.flight-rules/` – Framework files
40
+
41
+ The `.flight-rules/` directory contains Flight Rules framework files. These can be replaced on upgrade.
42
+
43
+ - `.flight-rules/AGENTS.md` – This file; agent guidelines
44
+ - `.flight-rules/doc-templates/` – Templates for creating project docs
45
+ - `.flight-rules/commands/` – Workflow command files (start/end coding session)
46
+ - `.flight-rules/prompts/` – Reusable prompt templates
47
+
48
+ ### `docs/` – Your project documentation
49
+
50
+ The `docs/` directory at the project root contains your project content. These files are created by `flight-rules init` and new templates are added during `flight-rules upgrade`.
51
+
52
+ - `docs/prd.md`
53
+ - Product requirements and high-level goals.
54
+ - Agents should read this when clarifying "what are we building and why?"
55
+
56
+ - `docs/implementation/`
57
+ - Home of the implementation spec hierarchy (see next section).
58
+ - The **spec is the single source of truth** for what should exist in the codebase and why.
59
+
60
+ - `docs/progress.md`
61
+ - A running high-level log of sessions and milestones.
62
+ - Each session gets a short entry + link to its detailed log file.
63
+
64
+ - `docs/critical-learnings.md`
65
+ - A curated list of reusable insights, patterns, and "never again" notes.
66
+ - Agents should propose additions when a session reveals something important or reusable.
67
+
68
+ - `docs/tech-stack.md`
69
+ - Documents the project's technical environment (testing framework, runtime, key dependencies).
70
+ - Agents should read this when performing tech-dependent tasks like creating tests.
71
+ - Use `/test.assess-current` to auto-populate this file based on the project's setup.
72
+
73
+ - `docs/session_logs/`
74
+ - Session documentation created during coding sessions.
75
+ - Contains plans, summaries, and learnings from each session.
76
+ - Agents create new session logs following the structure in `.flight-rules/doc-templates/session-log.md`.
77
+
78
+ ---
79
+
80
+ ## 3. Implementation spec system (Areas, Task Groups, Tasks)
81
+
82
+ Implementation specs live in `docs/implementation/` and follow a 3-level hierarchy:
83
+
84
+ | Level | Name | Example | Description |
85
+ |-------|------|---------|-------------|
86
+ | 1 | **Area** | `1-foundation-shell/` | A major implementation area (directory) |
87
+ | 2 | **Task Group** | `1.4-application-shell.md` | A file containing related tasks |
88
+ | 3 | **Task** | `1.4.1. Routing Structure` | A specific unit of work with status |
89
+
90
+ ### Areas (Level 1)
91
+
92
+ - Listed in `docs/implementation/overview.md`
93
+ - Each Area is a directory: `docs/implementation/{N}-{kebab-topic}/`
94
+ - Contains an `index.md` with overview, goals, and architecture context
95
+ - Examples: "Foundation & Shell", "Core Domain Models", "API Integration"
96
+
97
+ ### Task Groups (Level 2)
98
+
99
+ - Files within an Area directory: `{N}.{M}-topic.md`
100
+ - Each Task Group covers a coherent piece of work
101
+ - Contains multiple related Tasks
102
+
103
+ ### Tasks (Level 3)
104
+
105
+ - Sections within a Task Group file (e.g., `1.4.1. Routing Structure`)
106
+ - Each Task includes:
107
+ - Clear goals and scope
108
+ - Constraints and decisions
109
+ - A breakdown of steps
110
+ - A `Status:` line
111
+
112
+ **Status tracking**
113
+
114
+ - Status is tracked **at the Task level** within Task Group files, not in code comments or random notes.
115
+ - Typical status values:
116
+ - `Status: 🔵 Planned`
117
+ - `Status: 🟡 In Progress`
118
+ - `Status: ✅ Complete`
119
+
120
+ **Core rule: the spec is the single source of truth**
121
+
122
+ - If the code deviates from the spec (because the user or agent made a change), that's acceptable **only if the spec is updated** to reflect reality.
123
+ - In an ideal world, someone could recreate the project from scratch by implementing each spec file one by one.
124
+
125
+ **Agent behavior with specs**
126
+
127
+ When working on code:
128
+
129
+ 1. Identify the relevant Area, Task Group, and Task(s) for the work.
130
+ 2. Explicitly reference the Task ID(s) (e.g., `1.4.2 Left Sidebar Implementation`) in your working notes / session plan.
131
+ 3. After implementation:
132
+ - Propose updates to the corresponding Task(s) for the user's approval:
133
+ - What was actually done
134
+ - Any deviations from original plan
135
+ - Updated `Status:` values
136
+
137
+ ---
138
+
139
+ ## 4. Coding sessions
140
+
141
+ The user will explicitly start and end sessions using commands or workflows like:
142
+
143
+ - **"start coding session"** → use `.flight-rules/commands/dev-session.start.md`
144
+ - **"end coding session"** → use `.flight-rules/commands/dev-session.end.md`
145
+
146
+ Agents **must not** initiate these workflows on their own; they are only run when the user asks.
147
+
148
+ ### 4.1 Start coding session
149
+
150
+ When the user triggers a start session command, follow the process defined in `.flight-rules/commands/dev-session.start.md`. The generic behavior:
151
+
152
+ 1. **Review project context**
153
+ - Read `docs/prd.md`, `docs/implementation/overview.md`, relevant spec files, and `docs/progress.md`.
154
+ - Read the most recent session log in `docs/session_logs/` if present.
155
+ - Scan code as needed to understand current state.
156
+
157
+ 2. **Establish session goals**
158
+ - Ask the user for goals for this session.
159
+ - Suggest goals based on "Next Steps" from the last session and spec statuses.
160
+ - Agree on a small set of specific, achievable goals.
161
+
162
+ 3. **Create a detailed implementation plan**
163
+ - Collaborate with the user on approach:
164
+ - Technical options (with pros/cons)
165
+ - Constraints
166
+ - Potential challenges and mitigations
167
+
168
+ 4. **Document the session plan**
169
+ - Create a session log in `docs/session_logs/` using the template at `.flight-rules/doc-templates/session-log.md`.
170
+ - Reference relevant Task Group and Task IDs.
171
+
172
+ 5. **Confirm before coding**
173
+ - Show the user the plan (or a summary).
174
+ - Ask explicitly:
175
+ > "The session plan has been documented. Are you ready for me to begin implementing this plan?"
176
+ - **Do not** begin implementation until they confirm.
177
+
178
+ ### 4.2 End coding session
179
+
180
+ When the user triggers an end session command, follow the process in `.flight-rules/commands/dev-session.end.md`. Generic behavior:
181
+
182
+ 1. **Review sandbox / scratch files**
183
+ - Identify temporary / sandbox code and determine, with the user, what to keep vs delete.
184
+
185
+ 2. **Summarize the session**
186
+ - Draft a summary covering:
187
+ - What was accomplished
188
+ - Key decisions (especially deviations from spec)
189
+ - Implementation details of note
190
+ - Challenges and how they were resolved
191
+ - Proposed next steps
192
+ - Present the summary to the user for edits/approval.
193
+
194
+ 3. **Update the session log**
195
+ - Update the session log in `docs/session_logs/` with the summary.
196
+ - Link to relevant Task Groups, Tasks, and code areas.
197
+
198
+ 4. **Update progress**
199
+ - Append a short entry to `docs/progress.md`:
200
+ - Date/time
201
+ - 2–4 bullet summary
202
+ - Link to the session log file.
203
+
204
+ 5. **Promote critical learnings**
205
+ - Scan the session details for reusable insights or "this will matter again" items.
206
+ - Propose additions to `docs/critical-learnings.md` and update that file when the user approves.
207
+
208
+ 6. **Offer to commit**
209
+ - Ask if the user wants to commit now.
210
+ - If yes, help prepare a concise, meaningful commit message summarizing the session.
211
+
212
+ ---
213
+
214
+ ## 5. Agent behavior & tone
215
+
216
+ - **Opinionated but not rigid**
217
+ - Prefer following this workflow, but do not block the user if they want to "just do X in file Y right now."
218
+ - It's appropriate to say things like:
219
+ - "We *could* create a quick session plan first; want to do that?"
220
+ - "This change touches multiple specs; should we update them before we stop?"
221
+
222
+ - **Ask questions when uncertain**
223
+ - If an instruction is ambiguous, ask for clarification rather than guessing.
224
+
225
+ - **Defer to project-specific overrides**
226
+ - If the project has its own `AGENTS.local.md` or agent-specific config that extends these rules, follow those where they differ.
227
+
228
+ ---
229
+
230
+ ## 6. Where to look for project-specific instructions
231
+
232
+ When working in a project that uses this system:
233
+
234
+ 1. Read this `.flight-rules/AGENTS.md` file.
235
+ 2. Look for project-specific overrides or additions in:
236
+ - `AGENTS.local.md` (if present at project root)
237
+ - Additional docs under `docs/` (e.g., `architecture.md`, project-specific guides)
238
+ 3. Treat project-specific content as authoritative where it narrows or extends these global rules.
239
+
240
+ ---
241
+
242
+ If you are an agent in this project, your default behavior should be:
243
+
244
+ 1. Respect the structure and workflows described here.
245
+ 2. Use the implementation spec as the single source of truth.
246
+ 3. Use start/end coding session workflows when the user explicitly invokes them.
247
+ 4. Help keep PRD, specs, progress, and learnings clean, accurate, and up-to-date.
@@ -0,0 +1,79 @@
1
+ # End Coding Session
2
+
3
+ When the user invokes "end coding session", follow this process:
4
+
5
+ ## 1. Review Work Done
6
+
7
+ Identify:
8
+ - What code was written or modified
9
+ - Any sandbox/scratch files that need to be kept or discarded
10
+ - Any temporary debugging code that should be removed
11
+
12
+ Ask the user about anything uncertain.
13
+
14
+ ## 2. Summarize the Session
15
+
16
+ Draft a summary covering:
17
+ - **What was accomplished** – Key deliverables
18
+ - **Key decisions** – Especially any deviations from the original plan
19
+ - **Implementation details** – Notable technical choices
20
+ - **Challenges and solutions** – Problems encountered and how they were resolved
21
+ - **Proposed next steps** – What should happen in future sessions
22
+
23
+ Present the summary to the user for review and approval.
24
+
25
+ ## 3. Update the Session Log
26
+
27
+ Update the session log file in `docs/session_logs/YYYYMMDD_HHMM_session.md`
28
+
29
+ Use the template at `.flight-rules/doc-templates/session-log.md` as a guide if creating a new log.
30
+
31
+ Include:
32
+ - Summary
33
+ - Goal completion status
34
+ - Detailed description of work
35
+ - Key decisions
36
+ - Challenges and solutions
37
+ - Code areas touched
38
+ - Spec updates needed
39
+ - Next steps
40
+
41
+ ## 4. Update Progress
42
+
43
+ Append a short entry to `docs/progress.md`:
44
+
45
+ ```markdown
46
+ ### YYYY-MM-DD HH:MM
47
+
48
+ - Brief summary point 1
49
+ - Brief summary point 2
50
+ - See: [session_logs/YYYYMMDD_HHMM_session.md](session_logs/YYYYMMDD_HHMM_session.md)
51
+ ```
52
+
53
+ ## 5. Propose Spec Updates
54
+
55
+ If implementation deviated from specs or completed spec items:
56
+ - Identify which spec files need updates
57
+ - Propose the specific changes to the user for approval
58
+ - Update specs when approved
59
+
60
+ ## 6. Promote Critical Learnings
61
+
62
+ Scan the session for reusable insights:
63
+ - Patterns that worked well
64
+ - Mistakes to avoid
65
+ - Important decisions that should inform future work
66
+
67
+ Propose additions to `docs/critical-learnings.md` and update when approved.
68
+
69
+ ## 7. Offer to Commit
70
+
71
+ Ask the user:
72
+ > "Would you like to commit these changes now?"
73
+
74
+ If yes, help prepare a commit message that:
75
+ - Summarizes what was accomplished
76
+ - References the session log file
77
+ - Is concise but meaningful
78
+
79
+