@moritakaaz/markflow 0.0.0-stage → 0.2.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 (41) hide show
  1. package/README.md +32 -2
  2. package/package.json +21 -4
  3. package/src/agents.js +17 -0
  4. package/src/discover.js +188 -0
  5. package/src/doctor.js +284 -0
  6. package/src/hash.js +7 -0
  7. package/src/index.js +61 -0
  8. package/src/init.js +228 -0
  9. package/src/minimal.js +22 -0
  10. package/src/templates.js +17 -0
  11. package/src/update.js +146 -0
  12. package/src/versions.js +6 -0
  13. package/templates/AGENTS.md +26 -0
  14. package/templates/markflow/.agents/MEMORY.md +17 -0
  15. package/templates/markflow/.agents/PROMPTS.md +21 -0
  16. package/templates/markflow/.agents/RULES.md +7 -0
  17. package/templates/markflow/.agents/mcp.json +3 -0
  18. package/templates/markflow/.agents/workflows/create-feature.md +14 -0
  19. package/templates/markflow/.agents/workflows/implement-spec.md +13 -0
  20. package/templates/markflow/.agents/workflows/onboarding.md +22 -0
  21. package/templates/markflow/.agents/workflows/pre-deploy-check.md +13 -0
  22. package/templates/markflow/.agents/workflows/review-spec.md +13 -0
  23. package/templates/markflow/.agents/workflows/sync-docs.md +13 -0
  24. package/templates/markflow/CHANGELOG.md +9 -0
  25. package/templates/markflow/README.md +30 -0
  26. package/templates/markflow/TASKS.md +13 -0
  27. package/templates/markflow/docs/API.md +24 -0
  28. package/templates/markflow/docs/ARCHITECTURE.md +29 -0
  29. package/templates/markflow/docs/CODING_STANDARDS.md +40 -0
  30. package/templates/markflow/docs/DATA_MODEL.md +23 -0
  31. package/templates/markflow/docs/DEPLOY.md +23 -0
  32. package/templates/markflow/docs/GLOSSARY.md +16 -0
  33. package/templates/markflow/docs/MCP.md +19 -0
  34. package/templates/markflow/docs/PRD.md +29 -0
  35. package/templates/markflow/docs/STACK.md +19 -0
  36. package/templates/markflow/docs/TESTING.md +27 -0
  37. package/templates/markflow/docs/adr/001-initial-stack.md +25 -0
  38. package/templates/markflow/docs/adr/_template.md +27 -0
  39. package/templates/markflow/specs/_template.md +33 -0
  40. package/templates/markflow/specs/index.md +15 -0
  41. package/test/cli.test.js +590 -0
package/src/init.js ADDED
@@ -0,0 +1,228 @@
1
+ // Init copies the base templates into a repo.
2
+ // It is non-interactive by default.
3
+ // It never overwrites an existing file.
4
+ import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { discover } from "./discover.js";
8
+ import { hashText } from "./hash.js";
9
+ import { AGENTS } from "./agents.js";
10
+ import { findTemplatesDir } from "./templates.js";
11
+ import { METHODOLOGY_VERSION, TEMPLATE_VERSION } from "./versions.js";
12
+ import { MINIMAL_FILES } from "./minimal.js";
13
+
14
+ // True when any minimal file lives under this dir.
15
+ function underFilter(filter, dirRel) {
16
+ if (!filter) {
17
+ return true;
18
+ }
19
+ const prefix = "markflow/" + dirRel + "/";
20
+ for (const file of filter) {
21
+ if (file.startsWith(prefix)) {
22
+ return true;
23
+ }
24
+ }
25
+ return false;
26
+ }
27
+
28
+ async function copyDir(src, dest, projectName, base, createdPaths, filter) {
29
+ let created = 0;
30
+ const entries = await readdir(src, { withFileTypes: true });
31
+ for (const entry of entries) {
32
+ const srcPath = join(src, entry.name);
33
+ const destPath = join(dest, entry.name);
34
+ if (entry.isDirectory()) {
35
+ const dirRel = destPath.slice(base.length + 1);
36
+ if (!underFilter(filter, dirRel)) {
37
+ continue;
38
+ }
39
+ await mkdir(destPath, { recursive: true });
40
+ created += await copyDir(
41
+ srcPath,
42
+ destPath,
43
+ projectName,
44
+ base,
45
+ createdPaths,
46
+ filter
47
+ );
48
+ continue;
49
+ }
50
+ const rel = destPath.slice(base.length + 1);
51
+ if (filter && !filter.has("markflow/" + rel)) {
52
+ continue;
53
+ }
54
+ try {
55
+ await stat(destPath);
56
+ continue;
57
+ } catch {
58
+ // File does not exist yet, so init can create it.
59
+ }
60
+ const text = await readFile(srcPath, "utf8");
61
+ const replaced = text.split("{{project_name}}").join(projectName);
62
+ await mkdir(dirname(destPath), { recursive: true });
63
+ await writeFile(destPath, replaced);
64
+ createdPaths.push(rel);
65
+ created += 1;
66
+ }
67
+ return created;
68
+ }
69
+
70
+ // Fill the ARCHITECTURE.md template with discovery results.
71
+ // Throws when the template lines are gone, so a template
72
+ // change fails loudly instead of silently skipping the fill.
73
+ export function fillArchitecture(text, context) {
74
+ if (
75
+ !text.includes("- Language. TBD") ||
76
+ !text.includes("- Framework. TBD")
77
+ ) {
78
+ throw new Error("ARCHITECTURE.md template changed, fill failed.");
79
+ }
80
+ const names = context.stacks.map((s) => s.name).join(", ");
81
+ const evidence = context.stacks
82
+ .map((s) => s.evidence + " (" + s.confidence + ")")
83
+ .join(", ");
84
+ return text
85
+ .replace("- Language. TBD", "- Language. " + names)
86
+ .replace(
87
+ "- Framework. TBD",
88
+ "- Framework. TBD\n- Evidence. " +
89
+ evidence +
90
+ "\n- Monorepo. " +
91
+ (context.monorepo ? "Yes" : "No")
92
+ );
93
+ }
94
+
95
+ export async function runInit(options) {
96
+ const agent = options.agent || "generic";
97
+ if (!(agent in AGENTS)) {
98
+ console.log("Unknown agent.");
99
+ return { agent, copied: 0, ok: false };
100
+ }
101
+ const minimal = options.minimal === true;
102
+ const target = options.target || process.cwd();
103
+ const context = await discover(target);
104
+ const srcDir = dirname(fileURLToPath(import.meta.url));
105
+ const templatesDir = await findTemplatesDir();
106
+ const markflowDest = join(target, "markflow");
107
+ await mkdir(markflowDest, { recursive: true });
108
+ async function exists(path) {
109
+ try {
110
+ await stat(path);
111
+ return true;
112
+ } catch {
113
+ return false;
114
+ }
115
+ }
116
+ const archPath = join(markflowDest, "docs/ARCHITECTURE.md");
117
+ const stackPath = join(markflowDest, "docs/STACK.md");
118
+ const archExisted = await exists(archPath);
119
+ const stackExisted = await exists(stackPath);
120
+ const createdPaths = [];
121
+ const created = await copyDir(
122
+ join(templatesDir, "markflow"),
123
+ markflowDest,
124
+ context.projectName,
125
+ markflowDest,
126
+ createdPaths,
127
+ minimal ? new Set(MINIMAL_FILES) : null
128
+ );
129
+ if (context.stacks.length > 0) {
130
+ if (!archExisted) {
131
+ const arch = await readFile(archPath, "utf8");
132
+ await writeFile(archPath, fillArchitecture(arch, context));
133
+ }
134
+ if (!stackExisted && (await exists(stackPath))) {
135
+ const stack = await readFile(stackPath, "utf8");
136
+ const lines = context.stacks.map(
137
+ (s) => "- " + s.name + " from " + s.evidence + ", confidence " + s.confidence
138
+ );
139
+ const filled =
140
+ stack + "\n## Detected stacks\n\nDiscovery found these stacks.\n\n" + lines.join("\n") + "\n";
141
+ await writeFile(stackPath, filled);
142
+ }
143
+ }
144
+ const agentsSrc = join(templatesDir, "AGENTS.md");
145
+ const agentsDest = join(target, "AGENTS.md");
146
+ const rootFiles = {};
147
+ let agentsText = "";
148
+ try {
149
+ await stat(agentsDest);
150
+ console.log("AGENTS.md already exists.");
151
+ agentsText = await readFile(agentsDest, "utf8");
152
+ } catch {
153
+ const text = await readFile(agentsSrc, "utf8");
154
+ agentsText = text.split("{{project_name}}").join(context.projectName);
155
+ await writeFile(agentsDest, agentsText);
156
+ rootFiles["AGENTS.md"] = hashText(agentsText);
157
+ console.log("Created AGENTS.md.");
158
+ }
159
+ for (const file of AGENTS[agent]) {
160
+ const agentDest = join(target, file.path);
161
+ try {
162
+ await stat(agentDest);
163
+ console.log(file.path + " already exists.");
164
+ continue;
165
+ } catch {
166
+ // File does not exist yet, so init can create it.
167
+ }
168
+ const content = file.frontmatter
169
+ ? file.frontmatter + "\n" + agentsText
170
+ : agentsText;
171
+ await mkdir(dirname(agentDest), { recursive: true });
172
+ await writeFile(agentDest, content);
173
+ rootFiles[file.path] = hashText(content);
174
+ console.log("Created " + file.path + ".");
175
+ }
176
+ const pkg = JSON.parse(
177
+ await readFile(join(srcDir, "../package.json"), "utf8")
178
+ );
179
+ const markerPath = join(markflowDest, ".markflow.json");
180
+ let marker = null;
181
+ try {
182
+ marker = JSON.parse(await readFile(markerPath, "utf8"));
183
+ } catch {
184
+ marker = {
185
+ cli: pkg.version,
186
+ methodology: METHODOLOGY_VERSION,
187
+ template: TEMPLATE_VERSION,
188
+ project: context.projectName,
189
+ agent,
190
+ files: {},
191
+ rootFiles: {},
192
+ };
193
+ }
194
+ if (!marker.rootFiles) {
195
+ marker.rootFiles = {};
196
+ }
197
+ for (const [path, hash] of Object.entries(rootFiles)) {
198
+ if (!(path in marker.rootFiles)) {
199
+ marker.rootFiles[path] = hash;
200
+ }
201
+ }
202
+ marker.agent = marker.agent || agent;
203
+ marker.minimal = minimal;
204
+ marker.discovery = {
205
+ mode: context.mode,
206
+ stacks: context.stacks,
207
+ manifests: context.manifests,
208
+ monorepo: context.monorepo,
209
+ };
210
+ // Record hashes only for files this run created.
211
+ // A file the user wrote before init stays untracked,
212
+ // so update never treats it as a template file.
213
+ for (const rel of createdPaths) {
214
+ marker.files[rel] = hashText(
215
+ await readFile(join(markflowDest, rel), "utf8")
216
+ );
217
+ }
218
+ await writeFile(markerPath, JSON.stringify(marker, null, 2) + "\n");
219
+ let nextStep;
220
+ if (created > 0) {
221
+ console.log("Created markflow folder.");
222
+ nextStep = "Open your AI tool and say: start onboarding.";
223
+ console.log("Next step. " + nextStep);
224
+ } else {
225
+ console.log("markflow folder already exists.");
226
+ }
227
+ return { ...context, agent, copied: created, nextStep, minimal };
228
+ }
package/src/minimal.js ADDED
@@ -0,0 +1,22 @@
1
+ // Files init --minimal creates. Everything else stays out.
2
+ // Paths are relative to the project root.
3
+ export const MINIMAL_FILES = [
4
+ "AGENTS.md",
5
+ "markflow/README.md",
6
+ "markflow/TASKS.md",
7
+ "markflow/docs/PRD.md",
8
+ "markflow/docs/ARCHITECTURE.md",
9
+ "markflow/specs/index.md",
10
+ "markflow/specs/_template.md",
11
+ ];
12
+
13
+ // Files doctor checks in a minimal project.
14
+ export const MINIMAL_REQUIRED = [
15
+ "AGENTS.md",
16
+ "markflow/README.md",
17
+ "markflow/TASKS.md",
18
+ "markflow/docs/PRD.md",
19
+ "markflow/docs/ARCHITECTURE.md",
20
+ "markflow/specs/index.md",
21
+ "markflow/.markflow.json",
22
+ ];
@@ -0,0 +1,17 @@
1
+ // Find the templates folder.
2
+ // In the repo it lives at templates/base.
3
+ // In the published package it lives at packages/cli/templates.
4
+ import { access } from "node:fs/promises";
5
+ import { dirname, join, resolve } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ export async function findTemplatesDir() {
9
+ const srcDir = dirname(fileURLToPath(import.meta.url));
10
+ const packaged = resolve(srcDir, "../templates");
11
+ try {
12
+ await access(join(packaged, "AGENTS.md"));
13
+ return packaged;
14
+ } catch {
15
+ return resolve(srcDir, "../../../templates/base");
16
+ }
17
+ }
package/src/update.js ADDED
@@ -0,0 +1,146 @@
1
+ // Update restores missing files and updates unmodified files.
2
+ // It never overwrites a file the user changed.
3
+ // Use preview mode to see what would change without changing files.
4
+ import { mkdir, readFile, readdir, stat, writeFile } from "node:fs/promises";
5
+ import { dirname, join } from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import { hashText } from "./hash.js";
8
+ import { AGENTS } from "./agents.js";
9
+ import { findTemplatesDir } from "./templates.js";
10
+ import { METHODOLOGY_VERSION, TEMPLATE_VERSION } from "./versions.js";
11
+ import { MINIMAL_FILES } from "./minimal.js";
12
+
13
+ async function listFiles(dir, base, out) {
14
+ const entries = await readdir(dir, { withFileTypes: true });
15
+ for (const entry of entries) {
16
+ const full = join(dir, entry.name);
17
+ if (entry.isDirectory()) {
18
+ await listFiles(full, base, out);
19
+ continue;
20
+ }
21
+ out.push(full.slice(base.length + 1));
22
+ }
23
+ }
24
+
25
+ // Files init fills from discovery. After init they belong to the user.
26
+ // Update restores them when missing but never changes their content.
27
+ const USER_OWNED = new Set(["docs/ARCHITECTURE.md", "docs/STACK.md"]);
28
+
29
+ export async function runUpdate(options) {
30
+ const preview = options && options.preview;
31
+ const target = (options && options.target) || process.cwd();
32
+ const markerPath = join(target, "markflow/.markflow.json");
33
+ let marker;
34
+ try {
35
+ marker = JSON.parse(await readFile(markerPath, "utf8"));
36
+ } catch {
37
+ console.log("No version marker found.");
38
+ return { ok: false };
39
+ }
40
+ const srcDir = dirname(fileURLToPath(import.meta.url));
41
+ const templatesDir = await findTemplatesDir();
42
+ const pkg = JSON.parse(await readFile(join(srcDir, "../package.json"), "utf8"));
43
+ const projectName = marker.project || target.split("/").pop();
44
+ const agent = marker.agent && marker.agent in AGENTS ? marker.agent : "generic";
45
+ const stored = marker.files || {};
46
+ const storedRoot = marker.rootFiles || {};
47
+ const rels = [];
48
+ await listFiles(join(templatesDir, "markflow"), join(templatesDir, "markflow"), rels);
49
+ const templateSet = new Set(rels);
50
+ const syncRels =
51
+ marker.minimal === true
52
+ ? rels.filter((rel) => MINIMAL_FILES.includes("markflow/" + rel))
53
+ : rels;
54
+ let updated = 0;
55
+ let restored = 0;
56
+ let skipped = 0;
57
+ let kept = 0;
58
+ const files = { ...stored };
59
+ const rootFiles = { ...storedRoot };
60
+ async function sync(rel, dest, templateText, storedMap, newMap, userOwned) {
61
+ const templateHash = hashText(templateText);
62
+ let current = null;
63
+ try {
64
+ current = await readFile(dest, "utf8");
65
+ } catch {
66
+ console.log((preview ? "Would restore " : "Restored ") + rel);
67
+ if (!preview) {
68
+ await mkdir(dirname(dest), { recursive: true });
69
+ await writeFile(dest, templateText);
70
+ }
71
+ restored += 1;
72
+ newMap[rel] = templateHash;
73
+ return;
74
+ }
75
+ if (userOwned) {
76
+ console.log("Skipped " + rel + ", user owned.");
77
+ skipped += 1;
78
+ return;
79
+ }
80
+ if (storedMap[rel] && hashText(current) === storedMap[rel]) {
81
+ if (templateHash !== storedMap[rel]) {
82
+ console.log((preview ? "Would update " : "Updated ") + rel);
83
+ if (!preview) {
84
+ await writeFile(dest, templateText);
85
+ }
86
+ updated += 1;
87
+ newMap[rel] = templateHash;
88
+ }
89
+ return;
90
+ }
91
+ console.log("Skipped " + rel + ", modified.");
92
+ skipped += 1;
93
+ }
94
+ for (const rel of syncRels) {
95
+ const templateText = (await readFile(join(templatesDir, "markflow", rel), "utf8"))
96
+ .split("{{project_name}}")
97
+ .join(projectName);
98
+ await sync(rel, join(target, "markflow", rel), templateText, stored, files, USER_OWNED.has(rel));
99
+ }
100
+ for (const rel of Object.keys(stored)) {
101
+ if (!templateSet.has(rel)) {
102
+ console.log("Kept " + rel + ", no longer in template.");
103
+ kept += 1;
104
+ }
105
+ }
106
+ const agentsTemplate = (await readFile(join(templatesDir, "AGENTS.md"), "utf8"))
107
+ .split("{{project_name}}")
108
+ .join(projectName);
109
+ await sync("AGENTS.md", join(target, "AGENTS.md"), agentsTemplate, storedRoot, rootFiles);
110
+ let agentsText = agentsTemplate;
111
+ try {
112
+ agentsText = await readFile(join(target, "AGENTS.md"), "utf8");
113
+ } catch {
114
+ // AGENTS.md is missing, so the template text stays in use.
115
+ }
116
+ for (const file of AGENTS[agent]) {
117
+ if (!(file.path in storedRoot)) {
118
+ continue;
119
+ }
120
+ const content = file.frontmatter
121
+ ? file.frontmatter + "\n" + agentsText
122
+ : agentsText;
123
+ await sync(file.path, join(target, file.path), content, storedRoot, rootFiles);
124
+ }
125
+ if (preview) {
126
+ console.log("Preview only, no files changed.");
127
+ console.log(
128
+ "Would update " + updated + " files. Would restore " + restored + " files. Skipped " + skipped + " files. Kept " + kept + " files."
129
+ );
130
+ return { ok: true, updated, restored, skipped, kept, preview: true };
131
+ }
132
+ marker.cli = pkg.version;
133
+ marker.methodology = METHODOLOGY_VERSION;
134
+ marker.template = TEMPLATE_VERSION;
135
+ marker.project = projectName;
136
+ marker.agent = agent;
137
+ marker.files = files;
138
+ marker.rootFiles = rootFiles;
139
+ await writeFile(markerPath, JSON.stringify(marker, null, 2) + "\n");
140
+ if (updated === 0 && restored === 0 && skipped === 0 && kept === 0) {
141
+ console.log("Already up to date.");
142
+ } else {
143
+ console.log("Updated " + updated + " files. Restored " + restored + " files. Skipped " + skipped + " files. Kept " + kept + " files.");
144
+ }
145
+ return { ok: true, updated, restored, skipped, kept };
146
+ }
@@ -0,0 +1,6 @@
1
+ // Versions for the three parts of Markflow.
2
+ // Bump methodology when the docs in docs change.
3
+ // Bump template when the files in templates change.
4
+ // The CLI version comes from package.json.
5
+ export const METHODOLOGY_VERSION = "0.2.0";
6
+ export const TEMPLATE_VERSION = "0.2.0";
@@ -0,0 +1,26 @@
1
+ # AGENTS.md
2
+
3
+ This file is the router for AI agents in this project. Read it first.
4
+
5
+ ## Start here
6
+
7
+ All project context lives in the `markflow` folder. Do not create new Markdown files in the root.
8
+
9
+ Start with these files in order.
10
+
11
+ 1. Read `markflow/docs/PRD.md` to learn what this project is.
12
+ 2. Read `markflow/docs/ARCHITECTURE.md` to learn the stack and the layout of source code.
13
+ 3. Read `markflow/specs/index.md` to learn which spec is active.
14
+ 4. Read `markflow/docs/CODING_STANDARDS.md` before you write or review code.
15
+
16
+ ## Rules you must not break
17
+
18
+ - Code is in English. Docs are in English for this template. Change the doc language in `markflow/docs/PRD.md` when the project needs another language.
19
+ - All code lives in the source folder found during discovery. Tests live in the test folder found during discovery. Do not create new top level folders for code.
20
+ - Specs in `markflow/specs` are the source for intent and requirements. If code differs from a spec, stop and check both. Do not assume the spec is always right.
21
+ - Every claim in a doc comes from one of three places. What the user said. What the code shows. Or TBD. Never invent a decision or an architecture detail.
22
+ - All links inside `markflow` must be relative to that folder. Do not use absolute paths from the root.
23
+
24
+ ## If you are human and you do not use AI
25
+
26
+ Ignore the `markflow/.agents` folder. Read `README.md` and `CONTRIBUTING.md` in this project instead.
@@ -0,0 +1,17 @@
1
+ # MEMORY.md
2
+
3
+ Purpose. This file holds dynamic context for {{project_name}}.
4
+ Read when. You start a task and need lessons from past work.
5
+ Do not read when. You only need one spec. Open that spec instead.
6
+
7
+ ## Lessons
8
+
9
+ Add short lessons here. One line per lesson. Say what happened and what to do next time.
10
+
11
+ - TBD
12
+
13
+ ## Odd bugs
14
+
15
+ Add bugs that were hard to find. Say what the symptom was and what fixed it.
16
+
17
+ - TBD
@@ -0,0 +1,21 @@
1
+ # PROMPTS.md
2
+
3
+ Purpose. This file holds standard prompts for {{project_name}}.
4
+ Read when. You need a prompt for onboarding, review, refactor, or a new feature.
5
+ Do not read when. You already have a prompt that works. Use it.
6
+
7
+ ## Onboarding
8
+
9
+ Interview me one question at a time. Start with the problem and the users. Then write PRD.md and ARCHITECTURE.md from my answers and from the code. Mark what you do not know as TBD and list the open questions at the end.
10
+
11
+ ## Code review
12
+
13
+ Review the change against the spec and CODING_STANDARDS.md. List what breaks the spec. List what breaks the standards. Do not praise without reason.
14
+
15
+ ## Refactor
16
+
17
+ Refactor only the code in scope. Keep behavior the same. Run tests after the change. Show the test result.
18
+
19
+ ## New feature
20
+
21
+ Read the spec first. Read ARCHITECTURE.md next. Then write code and tests. Do not skip tests.
@@ -0,0 +1,7 @@
1
+ # RULES.md
2
+
3
+ Purpose. This file points to the code rules for {{project_name}}.
4
+ Read when. You need the code rules.
5
+ Do not read when. You already read CODING_STANDARDS.md. This file adds nothing new.
6
+
7
+ Read and follow `markflow/docs/CODING_STANDARDS.md`.
@@ -0,0 +1,3 @@
1
+ {
2
+ "mcpServers": {}
3
+ }
@@ -0,0 +1,14 @@
1
+ # Create Feature
2
+
3
+ Purpose. This file is the SOP to create a feature from a spec.
4
+ Read when. You start a new feature.
5
+ Do not read when. You fix a small bug. That does not need a full feature flow.
6
+
7
+ ## Steps
8
+
9
+ 1. Read the spec in `specs`. Check its status is Approved.
10
+ 2. Read ARCHITECTURE.md and CODING_STANDARDS.md.
11
+ 3. Write the code in the source folder.
12
+ 4. Write tests in the test folder.
13
+ 5. Run the tests. Fix failures before you move on.
14
+ 6. Update TASKS.md when the feature is done.
@@ -0,0 +1,13 @@
1
+ # Implement Spec
2
+
3
+ Purpose. This file is the SOP to build an approved spec.
4
+ Read when. A spec is Approved and you start coding.
5
+ Do not read when. The spec is not Approved yet. Review it first.
6
+
7
+ ## Steps
8
+
9
+ 1. Read the spec again. Note the acceptance cases.
10
+ 2. Read the related docs listed in the spec.
11
+ 3. Write code in small steps. Run tests often.
12
+ 4. Do not change code outside the spec scope.
13
+ 5. Stop and ask when the spec and the code disagree.
@@ -0,0 +1,22 @@
1
+ # Onboarding
2
+
3
+ Purpose. This file is the SOP to interview a new user and fill the first docs.
4
+ Read when. A project just got Markflow and the PRD is still the template.
5
+ Do not read when. The PRD is already filled. Use the other workflows instead.
6
+
7
+ ## Steps
8
+
9
+ 1. Ask one question at a time. Wait for the answer before you ask the next one.
10
+ 2. Start with the problem. What hurts today, and for whom.
11
+ 3. Ask who uses the product. Ask what each user must be able to do.
12
+ 4. Ask what the product must not do.
13
+ 5. Read the code to learn the stack and the layout. Use only what the code shows.
14
+ 6. Write PRD.md from the answers. Write ARCHITECTURE.md from the answers and from the code.
15
+ 7. Mark anything you do not know as TBD. Never invent a decision or an architecture detail.
16
+ 8. End with a list of open questions. The user answers them to clear the TBD marks.
17
+
18
+ ## Rules
19
+
20
+ - One question per message. No lists of questions.
21
+ - Every claim in PRD.md and ARCHITECTURE.md comes from the user, from the code, or is TBD.
22
+ - Do not write code in this workflow. Docs first. Code starts after the first spec is approved.
@@ -0,0 +1,13 @@
1
+ # Pre Deploy Check
2
+
3
+ Purpose. This file is the SOP to check before a release.
4
+ Read when. You are about to deploy.
5
+ Do not read when. You only work locally. That does not need a deploy check.
6
+
7
+ ## Steps
8
+
9
+ 1. Run all tests. All must pass.
10
+ 2. Check the spec acceptance cases. All must pass.
11
+ 3. Check env vars are set. Do not log real secrets.
12
+ 4. Check CHANGELOG.md is updated.
13
+ 5. Deploy only when all checks pass. If one fails, fix it first.
@@ -0,0 +1,13 @@
1
+ # Review Spec
2
+
3
+ Purpose. This file is the SOP to review a spec before it is built.
4
+ Read when. A spec is ready for review.
5
+ Do not read when. The spec is still a draft. Wait until it is ready.
6
+
7
+ ## Steps
8
+
9
+ 1. Read the spec. Check the goal is clear.
10
+ 2. Check each requirement is checkable.
11
+ 3. Check out of scope is written.
12
+ 4. Check acceptance cases exist.
13
+ 5. Mark the spec Approved only when all checks pass. If not, list what is missing.
@@ -0,0 +1,13 @@
1
+ # Sync Docs
2
+
3
+ Purpose. This file is the SOP to sync docs when code changes.
4
+ Read when. Code changed and docs may be out of date.
5
+ Do not read when. Only docs changed. That does not need a sync check.
6
+
7
+ ## Steps
8
+
9
+ 1. List the docs that describe the changed code.
10
+ 2. Check each doc still matches the code.
11
+ 3. Update the doc when it is wrong. Do not change code to match a wrong doc without a decision.
12
+ 4. Update STACK.md and MCP.md when a library changed.
13
+ 5. Run doctor checks when they exist.
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ Purpose. This file notes notable changes for {{project_name}}.
4
+ Read when. You want to know what changed in a release.
5
+ Do not read when. You want current tasks. Open `TASKS.md` instead.
6
+
7
+ ## Unreleased
8
+
9
+ - Initial Markflow docs
@@ -0,0 +1,30 @@
1
+ # markflow
2
+
3
+ Purpose. This folder holds all project context for {{project_name}}. It is the single place for intent, decisions, specs, and tasks.
4
+ Read when. You start work on this project or you need to know why something was built this way.
5
+ Do not read when. You only need one specific spec. Open that spec directly instead.
6
+
7
+ ## Map
8
+
9
+ - `docs/PRD.md`. Vision, users, and features. Read it when you start a new feature or check if a feature still fits the vision.
10
+ - `docs/ARCHITECTURE.md`. Stack, layout, and flow. Read it when you pick a stack or decide where code goes.
11
+ - `docs/DATA_MODEL.md`. Schema and relations. Read it when you change data.
12
+ - `docs/API.md`. Endpoints and payloads. Read it when you work on an API.
13
+ - `docs/TESTING.md`. Test strategy. Read it before you write tests.
14
+ - `docs/DEPLOY.md`. Release flow and env setup. Read it before you deploy.
15
+ - `docs/GLOSSARY.md`. Domain terms. Read it when a term is unclear.
16
+ - `docs/CODING_STANDARDS.md`. Code rules. Read it before you write or review code.
17
+ - `docs/STACK.md`. Libraries and their MCP servers. Read it when you add or replace a library.
18
+ - `docs/MCP.md`. MCP servers and setup. Read it when you set up an AI tool.
19
+ - `specs/index.md`. List of all specs plus status. Read it first before you open one spec.
20
+ - `specs/_template.md`. Template for a new spec. Use it when you create a spec.
21
+ - `.agents/MEMORY.md`. Dynamic context, lessons, and odd bugs.
22
+ - `.agents/PROMPTS.md`. Standard prompts.
23
+ - `.agents/RULES.md`. One line pointer to CODING_STANDARDS.md. It holds no duplicate rules.
24
+ - `.agents/mcp.json`. Master MCP config. Copy it to your AI tool location during sync. Do not put API keys here. Use env vars.
25
+ - `.agents/workflows`. Step by step SOPs, from review spec to pre deploy check.
26
+
27
+ ## Tasks and changes
28
+
29
+ - `TASKS.md`. Active work and progress.
30
+ - `CHANGELOG.md`. Release history.
@@ -0,0 +1,13 @@
1
+ # TASKS.md
2
+
3
+ Purpose. This file tracks active work for {{project_name}}.
4
+ Read when. You start work or you want to know what is done and what is left.
5
+ Do not read when. You only need one spec. Open that spec directly instead.
6
+
7
+ ## Active
8
+
9
+ - [ ] Add the first spec in `specs/index.md`
10
+
11
+ ## Done
12
+
13
+ - [ ] None yet