moflo 4.9.10 → 4.9.11

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 (31) hide show
  1. package/.claude/guidance/shipped/moflo-cli-reference.md +201 -0
  2. package/.claude/guidance/shipped/moflo-core-guidance.md +30 -391
  3. package/.claude/guidance/shipped/moflo-cross-platform.md +20 -1
  4. package/.claude/guidance/shipped/moflo-guidance-rules.md +144 -0
  5. package/.claude/guidance/shipped/moflo-memory-strategy.md +1 -0
  6. package/.claude/guidance/shipped/moflo-memorydb-maintenance.md +33 -6
  7. package/.claude/guidance/shipped/moflo-session-start.md +154 -0
  8. package/.claude/guidance/shipped/moflo-settings-injection.md +124 -0
  9. package/.claude/guidance/shipped/moflo-source-hygiene.md +1 -1
  10. package/.claude/guidance/shipped/moflo-spell-custom-steps.md +126 -0
  11. package/.claude/guidance/shipped/moflo-spell-engine.md +4 -101
  12. package/.claude/guidance/shipped/moflo-subagents.md +10 -0
  13. package/.claude/guidance/shipped/moflo-task-icons.md +9 -0
  14. package/.claude/guidance/shipped/moflo-user-facing-language.md +8 -0
  15. package/.claude/guidance/shipped/moflo-yaml-reference.md +191 -0
  16. package/.claude/skills/connector-builder/SKILL.md +1 -1
  17. package/.claude/skills/guidance/SKILL.md +158 -0
  18. package/.claude/skills/publish/SKILL.md +16 -0
  19. package/.claude/skills/spell-builder/SKILL.md +2 -2
  20. package/.claude/skills/spell-builder/architecture.md +1 -1
  21. package/.claude/skills/spell-schedule/SKILL.md +167 -0
  22. package/bin/session-start-launcher.mjs +20 -7
  23. package/dist/src/cli/commands/doctor.js +30 -0
  24. package/dist/src/cli/index.js +18 -0
  25. package/dist/src/cli/init/moflo-init.js +14 -1
  26. package/dist/src/cli/init/settings-generator.js +18 -3
  27. package/dist/src/cli/services/daemon-readiness.js +12 -0
  28. package/dist/src/cli/services/hook-wiring.js +54 -1
  29. package/dist/src/cli/services/process-registry.js +58 -0
  30. package/dist/src/cli/version.js +1 -1
  31. package/package.json +2 -2
@@ -122,7 +122,7 @@ steps:
122
122
 
123
123
  ## Step Command Types
124
124
 
125
- **Nine built-in step types are registered automatically.** Each implements `execute()`, `validate()`, `describeOutputs()`, and optional `rollback()`. Additional step types can be added via [pluggable step discovery](#pluggable-step-commands).
125
+ **Nine built-in step types are registered automatically.** Each implements `execute()`, `validate()`, `describeOutputs()`, and optional `rollback()`. Additional step types can be added via pluggable step discovery — see `moflo-spell-custom-steps.md` for the JS/TS, YAML, and npm-package extension paths.
126
126
 
127
127
  ### bash — Run a Shell Command
128
128
 
@@ -276,107 +276,9 @@ Supports 8 actions: `create-issue`, `create-pr`, `add-label`, `remove-label`, `c
276
276
 
277
277
  ---
278
278
 
279
- ## Pluggable Step Commands
280
-
281
- **Drop JS/TS or YAML files into a step directory to extend the spell engine with custom step types.** User-defined steps are auto-discovered and registered alongside built-in commands.
282
-
283
- ### Discovery Sources (Priority Order)
284
-
285
- | Priority | Source | Path |
286
- |----------|--------|------|
287
- | Lowest | npm packages | `node_modules/moflo-step-*` |
288
- | Medium | Built-in | Registered by `createRunner()` |
289
- | Highest | User directories | `workflows/steps/` or `.claude/workflows/steps/` |
290
-
291
- **Later sources override earlier ones by step type name.** A user step named `bash` replaces the built-in `bash` command.
292
-
293
- ### JS/TS Step Files
294
-
295
- **Export a `StepCommand` object as the default export, or as `stepCommand` or `command` named export.**
296
-
297
- ```javascript
298
- // workflows/steps/file-stats.js
299
- module.exports = {
300
- type: 'file-stats',
301
- description: 'Report file statistics',
302
- configSchema: { type: 'object', properties: { path: { type: 'string' } }, required: ['path'] },
303
- capabilities: [{ type: 'fs:read' }],
304
- validate(config) {
305
- const errors = [];
306
- if (!config.path) errors.push({ path: 'path', message: 'path is required' });
307
- return { valid: errors.length === 0, errors };
308
- },
309
- async execute(config) {
310
- const { readFileSync, statSync } = require('node:fs');
311
- const content = readFileSync(config.path, 'utf-8');
312
- return { success: true, data: { lines: content.split('\n').length, bytes: statSync(config.path).size } };
313
- },
314
- describeOutputs() { return [{ name: 'lines', type: 'number' }, { name: 'bytes', type: 'number' }]; },
315
- };
316
- ```
317
-
318
- See `examples/spell-steps/file-stats.js` for a complete, well-commented example.
319
-
320
- ### YAML Composite Steps
321
-
322
- **YAML files define reusable composite spell steps with declared inputs, tool dependencies, and sequential actions.**
323
-
324
- ```yaml
325
- # workflows/steps/notify.yaml
326
- name: notify
327
- description: Log a formatted notification message
328
- inputs:
329
- level:
330
- type: string
331
- required: false
332
- default: "info"
333
- message:
334
- type: string
335
- required: true
336
- actions:
337
- - command: "echo [${inputs.level}] ${inputs.message}"
338
- ```
339
-
340
- | YAML Field | Required | Description |
341
- |------------|----------|-------------|
342
- | `name` | Yes | Step type name (used as `type` in spell definitions) |
343
- | `description` | No | Human-readable description |
344
- | `tool` | No | Declares tool dependency (maps to `net` capability and prerequisites) |
345
- | `inputs` | No | Input schema with `type`, `required`, `default`, `description` per field |
346
- | `actions` | Yes | Sequential actions to execute; each has `tool`/`action`/`command` + `params` |
347
-
348
- **Use `${inputs.X}` in action params for input interpolation.** Required inputs are validated before execution.
349
-
350
- ### npm Package Discovery
351
-
352
- **Install a package named `moflo-step-*` and its exported StepCommand is auto-discovered.**
353
-
354
- The loader reads `package.json` for a `moflo.stepCommand` field pointing to the entry file. Falls back to the package's `main` field if absent.
355
-
356
- ```json
357
- {
358
- "name": "moflo-step-slack-notify",
359
- "main": "index.js",
360
- "moflo": { "stepCommand": "lib/step.js" }
361
- }
362
- ```
363
-
364
- ### Configuring Step Discovery in createRunner
365
-
366
- **Pass `stepDirs` and `projectRoot` to `createRunner()` to enable pluggable step discovery.**
367
-
368
- ```typescript
369
- import { createRunner } from 'moflo/dist/src/cli/spells/index.js';
370
-
371
- const runner = createRunner({
372
- stepDirs: ['workflows/steps/', '.claude/workflows/steps/'],
373
- projectRoot: process.cwd(), // Enables npm moflo-step-* discovery
374
- });
375
- ```
376
-
377
- ### Invalid Files Are Warnings, Not Errors
279
+ ## Custom Step Commands
378
280
 
379
- **Files that don't export a valid StepCommand are skipped with a warning.** This prevents one bad file from breaking all step discovery. Invalid conditions: missing exports, wrong interface shape, syntax errors, malformed YAML.
281
+ **To register custom step types, see `moflo-spell-custom-steps.md`.** That doc covers the three extension paths (JS/TS step files, YAML composite steps, `moflo-step-*` npm packages), priority ordering, and how to configure `createRunner()` for discovery.
380
282
 
381
283
  ---
382
284
 
@@ -505,6 +407,7 @@ Credential values listed in `RunnerOptions.credentialValues` are automatically r
505
407
 
506
408
  ## See Also
507
409
 
410
+ - `.claude/guidance/shipped/moflo-spell-custom-steps.md` — Pluggable step commands: JS/TS, YAML, and `moflo-step-*` npm packages
508
411
  - `.claude/guidance/shipped/moflo-spell-connectors.md` — Connectors: resource adapters, registry, step-vs-connector decision
509
412
  - `.claude/guidance/shipped/moflo-spell-sandboxing.md` — Capability-based security for steps
510
413
  - `.claude/guidance/shipped/moflo-spell-engine-architecture.md` — Architecture decisions for Epic #100
@@ -138,3 +138,13 @@ npx flo memory store --namespace patterns --key "brief-descriptive-key" --value
138
138
  1. Report findings to coordinator
139
139
  2. Store learnings if you discovered something new
140
140
  3. Coordinator will mark your task as completed
141
+
142
+ ---
143
+
144
+ ## See Also
145
+
146
+ - `.claude/guidance/shipped/moflo-task-icons.md` — Mandatory ICON + [Role] format for every `TaskCreate` and `Agent` description spawned by a coordinator
147
+ - `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` — How task lists and swarm coordinators cooperate when subagents are spawned in batches
148
+ - `.claude/guidance/shipped/moflo-memory-strategy.md` — The memory-search-first rule this protocol enforces, with namespace-selection guidance
149
+ - `.claude/guidance/shipped/moflo-memorydb-maintenance.md` — How the memory namespaces are populated and refreshed; required reading when search returns no results
150
+ - `.claude/guidance/shipped/moflo-core-guidance.md` — Full CLI/MCP reference including the spell gates that block subagent spawn before memory is searched
@@ -61,3 +61,12 @@ The spinner is the primary visual feedback during agent execution. Without icons
61
61
  - What type of agent is working
62
62
  - Whether the right specialist was chosen
63
63
  - When agent types change during multi-step workflows
64
+
65
+ ---
66
+
67
+ ## See Also
68
+
69
+ - `.claude/guidance/shipped/moflo-subagents.md` — Subagent protocol; `TaskCreate`/`Agent` icon rule is enforced as part of the spawning checklist
70
+ - `.claude/guidance/shipped/moflo-claude-swarm-cohesion.md` — How task lists and swarms cooperate; icons distinguish swarm-spawned vs single-agent work
71
+ - `.claude/guidance/shipped/moflo-user-facing-language.md` — Companion UX rule for any text shown to end users
72
+ - `.claude/guidance/shipped/moflo-core-guidance.md` — Spell Gate that enforces icon format on `TaskCreate`
@@ -32,3 +32,11 @@
32
32
  - Debug/trace logs gated behind verbose flags
33
33
  - Code comments and docstrings
34
34
  - Test descriptions
35
+
36
+ ---
37
+
38
+ ## See Also
39
+
40
+ - `.claude/guidance/shipped/moflo-task-icons.md` — Companion UX rule: spinner text must use ICON + [Role] so non-technical users can identify the working agent
41
+ - `.claude/guidance/shipped/moflo-spell-sandboxing.md` — Permission disclosure output where this language rule has the largest user-visible surface
42
+ - `.claude/guidance/shipped/moflo-error-handling.md` — Sibling rule for what error messages must contain; this doc governs how those messages are phrased
@@ -0,0 +1,191 @@
1
+ # moflo.yaml + Runtime Environment Reference
2
+
3
+ **Purpose:** Complete schema for `moflo.yaml`, runtime environment variable overrides, and `.mcp.json` setup. Reference this when configuring a moflo project, debugging "why is gate X not firing", or wiring moflo into a fresh repo.
4
+
5
+ ---
6
+
7
+ ## Project Configuration (moflo.yaml)
8
+
9
+ Moflo reads `moflo.yaml` (or `moflo.config.json`) from the project root. All fields have sensible defaults — the file is optional. If it's missing on first run, `flo init` writes one with the defaults below.
10
+
11
+ ### Full Reference
12
+
13
+ ```yaml
14
+ project:
15
+ name: "my-project" # Project name (default: directory name)
16
+
17
+ # Guidance/knowledge docs to index for semantic search
18
+ guidance:
19
+ directories: # Directories to scan for .md files
20
+ - .claude/guidance # Default
21
+ - docs/guides # Default
22
+ namespace: guidance # Memory namespace for indexed docs
23
+
24
+ # Source directories for code navigation map
25
+ code_map:
26
+ directories: # Directories to scan for source files
27
+ - src # Default
28
+ - packages
29
+ - lib
30
+ - app
31
+ extensions: [".ts", ".tsx", ".js", ".jsx", ".py", ".go", ".rs", ".java"]
32
+ exclude: [node_modules, dist, .next, coverage, build, __pycache__, target, .git]
33
+ namespace: code-map
34
+
35
+ # Workflow gates (enforced via Claude Code hooks)
36
+ # Memory-first is enforced at the scan/read layer (Glob, Grep, Read gates).
37
+ # Agent spawning is never blocked — SubagentStart hook injects guidance directive.
38
+ gates:
39
+ memory_first: true # Block Glob/Grep/Read until memory is searched
40
+ task_create_first: true # Advisory reminder before Agent tool (not blocking)
41
+ context_tracking: true # Track context bracket (FRESH/MODERATE/DEPLETED/CRITICAL)
42
+
43
+ # Auto-index on session start
44
+ auto_index:
45
+ guidance: true # Run flo-index (guidance RAG indexer)
46
+ code_map: true # Run flo-codemap (structural code index)
47
+
48
+ # Memory backend
49
+ memory:
50
+ backend: sql.js # sql.js (WASM) | json
51
+ embedding_model: Xenova/all-MiniLM-L6-v2 # 384-dim neural embeddings
52
+ namespace: default # Default namespace for memory operations
53
+
54
+ # Hook toggles (all on by default — disable to slim down)
55
+ hooks:
56
+ pre_edit: true # Track file edits for learning
57
+ post_edit: true # Record edit outcomes, train neural patterns
58
+ pre_task: true # Get agent routing before task spawn
59
+ post_task: true # Record task results for learning
60
+ gate: true # Workflow gate enforcement (memory-first at scan/read layer)
61
+ route: true # Intelligent task routing on each prompt
62
+ stop_hook: true # Session-end persistence and metric export
63
+ session_restore: true # Restore session state on start
64
+ notification: true # Hook into Claude Code notifications
65
+
66
+ # Model preferences (haiku, sonnet, opus)
67
+ models:
68
+ default: opus # General tasks
69
+ research: sonnet # Research/exploration agents
70
+ review: opus # Code review agents
71
+ test: sonnet # Test-writing agents
72
+
73
+ # Intelligent model routing (auto-selects haiku/sonnet/opus per task)
74
+ model_routing:
75
+ enabled: false # Set true to enable dynamic routing
76
+ confidence_threshold: 0.85 # Min confidence before escalating
77
+ cost_optimization: true # Prefer cheaper models when confident
78
+ circuit_breaker: true # Penalize models that fail repeatedly
79
+ # agent_overrides:
80
+ # security-architect: opus
81
+ # researcher: sonnet
82
+
83
+ # Status line display
84
+ status_line:
85
+ enabled: true # Show status line at all
86
+ branding: "Moflo V4" # Text in status bar
87
+ mode: single-line # single-line (default) or dashboard (multi-line)
88
+ show_git: true # Git branch, changes, ahead/behind
89
+ show_model: true # Current model name
90
+ show_session: true # Session duration
91
+ show_intelligence: true # Intelligence % indicator
92
+ show_swarm: true # Active swarm agents count
93
+ show_hooks: true # Enabled hooks count
94
+ show_mcp: true # MCP server count
95
+ show_security: true # CVE/security status (dashboard only)
96
+ show_adrs: true # ADR compliance (dashboard only)
97
+ show_tests: true # Test file count (dashboard only)
98
+
99
+ # Spell step sandboxing (OS-level process isolation for bash steps)
100
+ # Platform support: macOS (sandbox-exec), Linux/WSL (bwrap). Windows has no OS sandbox.
101
+ sandbox:
102
+ enabled: false # Set to true to wrap bash steps in an OS sandbox
103
+ tier: auto # auto | denylist-only | full
104
+ ```
105
+
106
+ If your `moflo.yaml` predates the `sandbox:` block, it is auto-appended on the next session start — you never need to re-run `moflo init` after a version bump.
107
+
108
+ ### Key Behaviors
109
+
110
+ | Config | Effect |
111
+ |--------|--------|
112
+ | `auto_index.guidance: false` | Skip guidance indexing on session start |
113
+ | `auto_index.code_map: false` | Skip code map generation on session start |
114
+ | `gates.memory_first: true` | Block Glob/Grep/Read until memory is searched first |
115
+ | `gates.task_create_first: true` | Advisory reminder before Agent tool (not blocking) |
116
+ | `gates.context_tracking: true` | Show FRESH/MODERATE/DEPLETED/CRITICAL context bracket |
117
+ | `hooks.pre_edit: false` | Disable file-edit tracking (skips pre-edit hook) |
118
+ | `hooks.post_edit: false` | Disable edit outcome recording and neural training |
119
+ | `hooks.pre_task: false` | Disable agent routing recommendations before spawn |
120
+ | `hooks.post_task: false` | Disable task result recording for learning |
121
+ | `hooks.gate: false` | Disable all workflow gates (memory-first, task-create-first) |
122
+ | `hooks.route: false` | Disable intelligent task routing on each prompt |
123
+ | `hooks.stop_hook: false` | Disable session-end persistence and metric export |
124
+ | `hooks.notification: false` | Disable notification hook |
125
+ | `model_routing.enabled: true` | Auto-select haiku/sonnet/opus based on task complexity |
126
+ | `status_line.mode: dashboard` | Switch to multi-line status display |
127
+ | `status_line.show_swarm: false` | Hide swarm agent count from status bar |
128
+ | `sandbox.enabled: true` | Wrap bash steps in an OS sandbox (macOS/Linux/WSL) — absolute disable when `false`, regardless of tier |
129
+ | `sandbox.tier: full` | Require OS sandbox; throw at runtime if the platform tool is unavailable |
130
+ | `sandbox.tier: denylist-only` | Keep Layer 1 denylist only; skip OS isolation even when enabled |
131
+
132
+ ---
133
+
134
+ ## Environment Variables
135
+
136
+ Config is loaded from `moflo.yaml` at the project root — there is no env var that points at a config file. The variables below override specific values at runtime:
137
+
138
+ ```bash
139
+ # Logging
140
+ CLAUDE_FLOW_LOG_LEVEL=info # debug | info | warn | error
141
+
142
+ # MCP Server (stdio transport — no port)
143
+ CLAUDE_FLOW_MCP_TRANSPORT=stdio
144
+
145
+ # Memory backend
146
+ CLAUDE_FLOW_MEMORY_BACKEND=hybrid # hybrid | sqlite | agentdb (legacy)
147
+ CLAUDE_FLOW_MEMORY_TYPE=sqlite # storage type override
148
+ ```
149
+
150
+ Variable names retain the `CLAUDE_FLOW_` prefix for backward compatibility with consumers upgraded from claude-flow.
151
+
152
+ ---
153
+
154
+ ## .mcp.json — MCP Tool Wiring
155
+
156
+ ### Project-Level (Recommended)
157
+
158
+ Configure `.mcp.json` in the project root:
159
+
160
+ ```json
161
+ {
162
+ "mcpServers": {
163
+ "moflo": {
164
+ "command": "node",
165
+ "args": ["node_modules/moflo/bin/cli.js", "mcp", "start"]
166
+ }
167
+ }
168
+ }
169
+ ```
170
+
171
+ `flo init` writes this file automatically; only edit it if you need a non-default invocation (custom node binary, alternate `args`, etc.).
172
+
173
+ ### Alternative: Global MCP Registration
174
+
175
+ ```bash
176
+ claude mcp add moflo -- npx moflo@alpha
177
+ npx flo daemon start
178
+ npx flo doctor --fix
179
+ ```
180
+
181
+ Global registration is useful for ad-hoc projects where you don't want to commit `.mcp.json`. For long-lived projects, prefer the project-level form so the configuration is version-controlled with the code.
182
+
183
+ ---
184
+
185
+ ## See Also
186
+
187
+ - `.claude/guidance/shipped/moflo-core-guidance.md` — Hub: getting started, anti-drift defaults, troubleshooting
188
+ - `.claude/guidance/shipped/moflo-cli-reference.md` — Commands, agents, hooks, hive-mind, ruvector — the surfaces this config gates
189
+ - `.claude/guidance/shipped/moflo-spell-sandboxing.md` — What `sandbox:` actually does at the bash-step boundary, with capability/permission interaction
190
+ - `.claude/guidance/shipped/moflo-session-start.md` — Where these config fields are read and applied during session start
191
+ - `.claude/guidance/shipped/moflo-settings-injection.md` — What moflo writes into `.claude/settings.json` (the hook wiring; complementary to `moflo.yaml` toggles)
@@ -32,7 +32,7 @@ Ask the user:
32
32
 
33
33
  **Important:** Simple service integrations (Slack webhook, S3 upload, Jira comment) should compose existing connectors (`http`, `github-cli`, `playwright`) in spell YAML — no dedicated connector needed. However, platforms requiring complex multi-step browser interaction (like Outlook.com web UI) DO warrant a dedicated connector. See `.claude/skills/spell-builder/architecture.md` for the decision tree.
34
34
 
35
- **Documentation requirement:** When creating any new step command or connector, you MUST also create a README.md following `.claude/guidance/internal/guidance-rules.md`. Use existing READMEs in `.claude/skills/spell-builder/steps/` or `connectors/` as templates. Apply automatically — the user should never need to ask.
35
+ **Documentation requirement:** When creating any new step command or connector, you MUST also create a README.md following `.claude/guidance/shipped/moflo-guidance-rules.md`. Use existing READMEs in `.claude/skills/spell-builder/steps/` or `connectors/` as templates. Apply automatically — the user should never need to ask.
36
36
 
37
37
  Then follow the appropriate section below.
38
38
 
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: guidance
3
+ description: Add, edit, or audit guidance docs in this project's .claude/guidance/ directory following moflo's universal guidance rules. Default mode walks the user through one doc (creating or improving it); the -a flag audits every doc in the directory and offers per-file improvements.
4
+ arguments: "[-a] [<topic-or-path>]"
5
+ ---
6
+
7
+ # /guidance — Author and audit project guidance
8
+
9
+ Help the user write, edit, or audit guidance files in their `.claude/guidance/` directory so Claude actually follows the rules they wrote. The skill applies the universal rules from `.claude/guidance/shipped/moflo-guidance-rules.md` — that doc is the single source of truth, do not paraphrase or duplicate it here.
10
+
11
+ **Arguments:** $ARGUMENTS
12
+
13
+ ## Modes
14
+
15
+ | Mode | Trigger | What it does |
16
+ |------|---------|--------------|
17
+ | Single-doc | no flag, optional `<topic-or-path>` arg | Walk the user through creating one new doc OR improving one existing doc |
18
+ | Audit | `-a` flag | Scan every `.md` in `.claude/guidance/` (recursively), score each against the rules, present a triage report, then offer to fix per-file or in batch |
19
+
20
+ ## Step 0 — Memory First
21
+
22
+ Before reading any files, run a memory search:
23
+
24
+ ```
25
+ mcp__moflo__memory_search { query: "guidance rules writing project conventions", namespace: "guidance" }
26
+ ```
27
+
28
+ This pulls the user's project-specific guidance conventions (if any) plus the moflo universal rules into context. The memory-first gate will block file reads otherwise.
29
+
30
+ ## Step 1 — Pick the Mode and Target
31
+
32
+ Parse the argument:
33
+
34
+ | Input | Mode | Target |
35
+ |-------|------|--------|
36
+ | empty | single-doc | Ask the user for a topic; default destination is `.claude/guidance/<kebab-topic>.md` |
37
+ | `<topic>` (no slash) | single-doc | Use `.claude/guidance/<kebab-topic>.md`; if it exists, edit; else create |
38
+ | `<path>` (has `.claude/guidance/`) | single-doc | Edit that exact file; if it doesn't exist, create at that path |
39
+ | `-a` | audit | All `.md` files under `.claude/guidance/` recursively |
40
+ | `-a <subdir>` | audit | All `.md` files under `.claude/guidance/<subdir>/` recursively |
41
+
42
+ If single-doc and the file already exists, briefly summarize what it contains (one sentence) before walking the user through edits — confirm you have the right file.
43
+
44
+ ## Step 2 — Single-Doc Mode
45
+
46
+ Apply the universal rules from `.claude/guidance/shipped/moflo-guidance-rules.md`. The rules cover (do not paraphrase — read the source):
47
+
48
+ 1. Lead with `**Purpose:**` line after the H1
49
+ 2. Be imperative, not descriptive
50
+ 3. Use tables for decision logic
51
+ 4. Code examples must be concrete
52
+ 5. Keep files under 500 lines
53
+ 6. Headings must be specific
54
+ 7. Avoid the listed anti-patterns
55
+ 8. Optimize for RAG chunking
56
+ 9. End with a `## See Also` section
57
+
58
+ ### Creating a new doc — scaffold this shape
59
+
60
+ ```markdown
61
+ # <Specific Title — what this doc is and when to use>
62
+
63
+ **Purpose:** <one sentence on what this doc covers and when to reference it>
64
+
65
+ ---
66
+
67
+ ## <Specific H2 — first actionable rule or topic>
68
+
69
+ <Imperative rule, then rationale, then example.>
70
+
71
+ ---
72
+
73
+ ## <Specific H2 — second>
74
+
75
+ <Same shape.>
76
+
77
+ ---
78
+
79
+ ## See Also
80
+
81
+ - `.claude/guidance/<related-doc>.md` — One-line description of why related
82
+ - `.claude/guidance/<another>.md` — One-line description
83
+ ```
84
+
85
+ After scaffolding, ask the user 2–4 targeted questions to populate the body — never auto-write opinionated content into the user's project. Their guidance must reflect their conventions, not Claude's.
86
+
87
+ ### Editing an existing doc — checklist before proposing changes
88
+
89
+ For the loaded file, evaluate against the universal rules and report findings as a short table BEFORE editing:
90
+
91
+ | Check | Status |
92
+ |-------|--------|
93
+ | Has `**Purpose:**` line right after H1 | yes / no |
94
+ | Has `## See Also` section at end | yes / no |
95
+ | Under 500 lines | <count> lines |
96
+ | H2 headings are specific (not "Overview", "Configuration", "Examples") | list any generic ones |
97
+ | Uses imperative voice for rules ("must"/"always"/"never") not hedged ("should"/"might"/"consider") | list hedged phrases found |
98
+ | Has prose preamble before first rule | yes / no |
99
+
100
+ Then propose edits as concrete diffs — never rewrite the whole file unless the user asks.
101
+
102
+ ## Step 3 — Audit Mode (`-a`)
103
+
104
+ When `-a` is passed, scan the guidance directory and produce a triage report. Walk the directory yourself with `Glob` and `Read`; do not delegate to a subagent for the audit itself unless the user has 30+ files.
105
+
106
+ For each `.md` file:
107
+
108
+ 1. Count lines (`wc -l` via Bash, or read + split)
109
+ 2. Check for `**Purpose:**` line right after H1
110
+ 3. Check for `## See Also` (Title Case, capital A) at end
111
+ 4. Look for generic headings: `^## (Overview|Configuration|Examples|Rules|Notes|Details|Information)$`
112
+ 5. Look for hedged language: `\b(should|might|consider|may want to)\b` in rule contexts
113
+ 6. Detect prose preambles (>3 paragraphs between H1 and first H2 rule)
114
+
115
+ Render the report as a sortable table with one row per file, columns: file, lines, has-purpose, has-see-also, generic-headings count, hedged count. Highlight the worst offenders first.
116
+
117
+ After the table, list the **top 3–5 priority fixes** in plain English (not table format). For each, explain WHY (rule citation) and propose either a per-file fix or a batch fix.
118
+
119
+ Ask the user which to apply, then walk through the chosen fixes one at a time. **Never apply audit fixes without explicit per-file confirmation** — guidance is high-leverage; silent edits are dangerous.
120
+
121
+ ## Step 4 — After Editing
122
+
123
+ Once the user confirms the doc looks right:
124
+
125
+ 1. Save the file via `Write` (new) or `Edit` (existing).
126
+ 2. If you added a new doc, ask the user which existing doc should link to it via See Also (rule #9 needs bidirectional links to work).
127
+ 3. Suggest re-indexing if the user runs moflo: `node bin/index-guidance.mjs` (or just wait for next session-start auto-reindex).
128
+
129
+ ## Cheatsheet — Universal Rules Recap
130
+
131
+ The full rules live in `.claude/guidance/shipped/moflo-guidance-rules.md`. Quick recap:
132
+
133
+ | # | Rule | One-line |
134
+ |---|------|----------|
135
+ | 1 | Structure for scanability | Purpose line + specific H2s + rule-first ordering |
136
+ | 2 | Imperative voice | "Must" / "always" / "never", not "should" / "might" |
137
+ | 3 | Tables for decisions | Conditional logic in tables, not nested bullets |
138
+ | 4 | Concrete examples | Realistic values, not `[placeholder]` |
139
+ | 5 | <500 lines | Split by concern when over |
140
+ | 6 | Specific headings | Not "Overview" / "Configuration" |
141
+ | 7 | Anti-patterns | Single source of truth, no preambles, prose for rules (not code comments) |
142
+ | 8 | RAG chunking | 5–30 lines per H2, self-contained openings, `---` between sections |
143
+ | 9 | See Also | Title Case, end of every file, relative paths |
144
+
145
+ ## Important
146
+
147
+ - **Memory-first is mandatory.** Always run `mcp__moflo__memory_search` in step 0 — the gate blocks reads otherwise.
148
+ - **Never duplicate the rules in this skill.** Reference `.claude/guidance/shipped/moflo-guidance-rules.md` and ask the user to read it if they want depth.
149
+ - **Never auto-write opinionated content.** Guidance is the user's project policy; ask before injecting your own opinions.
150
+ - **Confirm per file in audit mode.** Bulk edits to the user's guidance directory are high-blast-radius — confirm each one.
151
+ - **The `moflo-` filename prefix is moflo-only.** Consumer projects writing their own guidance do not need it; it exists to avoid collisions when moflo's shipped guidance syncs into a consumer's directory.
152
+
153
+ ## See Also
154
+
155
+ - `.claude/guidance/shipped/moflo-guidance-rules.md` — Universal writing rules this skill enforces
156
+ - `.claude/guidance/shipped/moflo-memory-strategy.md` — How well-written guidance feeds the RAG index
157
+ - `.claude/guidance/shipped/moflo-task-icons.md` — UX rule the skill checks for any TaskCreate examples in the user's guidance
158
+ - `.claude/guidance/shipped/moflo-user-facing-language.md` — Companion rule for any user-visible text the user's guidance discusses
@@ -21,6 +21,14 @@ Automated release pipeline for moflo. Bumps version, commits, builds, tests, run
21
21
  /publish patch # explicit patch bump
22
22
  ```
23
23
 
24
+ ## Pre-Publish Gate — REQUIRED
25
+
26
+ **Before Step 1, walk the full pre-flight checklist in `.claude/guidance/internal/pre-publish-rules.md`.** That document is the authoritative ruleset for every publish — the seven layered gates (lint, build, tests, doctor, smoke, populated smoke, manifest sanity) plus the cross-platform and consumer-install posture checks. Do not paraphrase or shortcut the rules here; read them and confirm every item.
27
+
28
+ If you cannot confirm all ten checklist items at the bottom of `pre-publish-rules.md`, STOP. Fix the failing gate first and only then resume from Step 1 below. Skipping the gate to "just get this small change out" is the antipattern that produced the historical incidents named in the rules doc.
29
+
30
+ ---
31
+
24
32
  ## Step-by-Step Procedure
25
33
 
26
34
  Follow docs/BUILD.md exactly. Every step must succeed before proceeding to the next.
@@ -162,3 +170,11 @@ Installed: moflo@<new-version> (devDependency)
162
170
  - Never install moflo globally — it is always a local devDependency
163
171
  - If any step fails, stop and fix the issue before proceeding — do not skip steps
164
172
  - The `prepublishOnly` script in package.json runs `npm run build` automatically, so npm publish will fail-fast on any TypeScript or asset-bundling error
173
+ - Pre-publish rules live in `.claude/guidance/internal/pre-publish-rules.md` — never duplicate or paraphrase them in this skill; reference and follow
174
+
175
+ ## See Also
176
+
177
+ - `.claude/guidance/internal/pre-publish-rules.md` — Mandatory cross-platform + consumer-install gates that gate every publish
178
+ - `docs/BUILD.md` — Step-by-step build/publish process this skill mirrors
179
+ - `.claude/guidance/internal/dogfooding.md` — Why we catch consumer-facing regressions first as our own dependency
180
+ - `harness/consumer-smoke/README.md` — Smoke harness profiles (clean + populated) that prove a consumer install works
@@ -356,7 +356,7 @@ Write the updated YAML back to the original file (or a new path if requested).
356
356
 
357
357
  **Runtime source:** `src/cli/spells/commands/` — each step is a TypeScript file registered in `index.ts`.
358
358
 
359
- **Adding a new step:** Create a directory under `steps/<name>/` with a `README.md`. Follow `.claude/guidance/internal/guidance-rules.md` and use existing step READMEs as templates. The step command source goes in `src/cli/spells/commands/` and is registered in `index.ts`. No changes to this SKILL.md needed.
359
+ **Adding a new step:** Create a directory under `steps/<name>/` with a `README.md`. Follow `.claude/guidance/shipped/moflo-guidance-rules.md` and use existing step READMEs as templates. The step command source goes in `src/cli/spells/commands/` and is registered in `index.ts`. No changes to this SKILL.md needed.
360
360
 
361
361
  ### Connectors
362
362
 
@@ -371,7 +371,7 @@ Write the updated YAML back to the original file (or a new path if requested).
371
371
 
372
372
  **Runtime source:** `src/cli/spells/connectors/` — each connector is a TypeScript file registered in `index.ts`.
373
373
 
374
- **Adding a new connector:** Create a directory under `connectors/<name>/` with a `README.md`. Follow `.claude/guidance/internal/guidance-rules.md` and use existing connector READMEs as templates. The connector source goes in `src/cli/spells/connectors/` and is registered in `index.ts`. No changes to this SKILL.md needed.
374
+ **Adding a new connector:** Create a directory under `connectors/<name>/` with a `README.md`. Follow `.claude/guidance/shipped/moflo-guidance-rules.md` and use existing connector READMEs as templates. The connector source goes in `src/cli/spells/connectors/` and is registered in `index.ts`. No changes to this SKILL.md needed.
375
375
 
376
376
  **When to create a new connector vs composing existing ones:** See [architecture.md](architecture.md) for the decision tree.
377
377
 
@@ -153,7 +153,7 @@ steps:
153
153
 
154
154
  ## Documentation Rules for New Components
155
155
 
156
- **Every new step, connector, or spell MUST include a README.md.** Apply the rules in `.claude/guidance/internal/guidance-rules.md` automatically — do not wait for the user to ask. Use existing READMEs in `steps/` and `connectors/` as templates.
156
+ **Every new step, connector, or spell MUST include a README.md.** Apply the rules in `.claude/guidance/shipped/moflo-guidance-rules.md` automatically — do not wait for the user to ask. Use existing READMEs in `steps/` and `connectors/` as templates.
157
157
 
158
158
  **Where to put the README:**
159
159
  - Steps: `.claude/skills/spell-builder/steps/<name>/README.md`