Skip to content

Commit d49269a

Browse files
committed
docs: add scripting governance policy to founder_rules.mdc
- Add Part II: Scripting Architecture & Policy - Section 15: Scripting Governance (4 authorized entry points) - Section 16: Where Scripts Live (5 authorized locations) - Section 17: Forbidden Practices (5 anti-patterns) - Dual interface pattern (CLI + module exports) - Script design requirements template - Reorganize TOC: Part II → Part III for Environment Policy - Document central authority: automation/scripts/ library - Define guardrails for each layer (Taskfile, Husky, GitHub, Skills) - No free-floating scripts allowed - Update date: 2025-11-11
1 parent 2642502 commit d49269a

File tree

1 file changed

+166
-9
lines changed

1 file changed

+166
-9
lines changed

.cursor/rules/founder_rules.mdc

Lines changed: 166 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,16 @@ description: "Non-negotiable development standards for ScreenGraph. Enforces arc
2727
13. [Handoff Documentation](#handoff-documentation)
2828
14. [Vibe Usage](#vibe-usage-engineering-personas)
2929

30-
### Part II: Environment Policy
31-
15. [Single Environment Execution](#single-environment-execution)
32-
16. [Worktree Usage](#worktree-usage)
33-
17. [Standard Ports](#standard-ports)
34-
18. [Git Operations](#git-operations)
35-
19. [Cursor Modes](#cursor-dropdown-modes)
36-
20. [Enforcement Rules](#enforcement-what-agents-cannot-do)
30+
### Part II: Scripting Architecture & Policy
31+
15. [Scripting Governance](#scripting-governance)
32+
16. [Where Scripts Live](#where-scripts-live)
33+
17. [Forbidden Practices](#forbidden-practices)
34+
35+
### Part III: Environment Policy
36+
18. [Single Environment Execution](#single-environment-execution)
37+
19. [Worktree Usage](#worktree-usage)
38+
20. [Standard Ports](#standard-ports)
39+
21. [Git Operations](#git-operations)
3740

3841
---
3942

@@ -320,7 +323,161 @@ Update after significant changes.
320323

321324
---
322325

323-
## Part II: Environment Policy
326+
## Part II: Scripting Architecture & Policy
327+
328+
### 🔧 Scripting Governance
329+
330+
**Single Source of Truth:**
331+
- All automation flows through **four entry points** that all call `automation/` library
332+
- No duplication across Husky, Taskfile, GitHub Actions, or Claude Skills
333+
- Each script is both CLI tool AND reusable module (dual interface pattern)
334+
335+
**Four Authorized Entry Points:**
336+
337+
| Entry Point | Location | Use Case | Guardrail |
338+
|------------|----------|----------|-----------|
339+
| **Taskfile** | `.cursor/commands/` | Primary dev/CI entry | Task descriptions ≤ 5 words |
340+
| **Husky Hooks** | `.husky/` | Git commit/push enforcement | Prevent bad commits/pushes |
341+
| **GitHub Actions** | `.github/workflows/` | CI/CD pipeline | Automated on pull/push |
342+
| **Claude Skills** | `.claude-skills/` | AI agent workflows | Call Tasks + MCP tools |
343+
344+
**All four layers call the same `automation/scripts/` library.** Never duplicate business logic.
345+
346+
---
347+
348+
### 📍 Where Scripts Live
349+
350+
**✅ AUTHORIZED Locations:**
351+
352+
1. **Central Authority: `automation/scripts/`**
353+
- Environment resolution (`env.mjs`)
354+
- Founder rules enforcement (`check-founder-rules.mjs`)
355+
- Documentation management (`cleanup-root-docs.mjs`)
356+
- **Rule**: Reusable modules with dual CLI + export interface
357+
- **Example**: `node automation/scripts/env.mjs status` OR `import { getPorts } from './automation/scripts/env.mjs'`
358+
359+
2. **Speckit Automation: `.specify/scripts/bash/`**
360+
- Spec creation (`create-new-feature.sh`)
361+
- Plan setup (`setup-plan.sh`)
362+
- Prerequisite checks (`check-prerequisites.sh`)
363+
- **Rule**: Bash scripts, used by spec-driven workflows
364+
- **Not part of standard dev cycle** — only for spec-kit operations
365+
366+
3. **Service NPM Scripts: `backend/package.json` & `frontend/package.json`**
367+
- Service-level dev/test commands
368+
- **Rule**: Must delegate to service code, not orchestration
369+
- **Examples**: `dev`, `test`, `lint`, `build`
370+
371+
4. **Backend Inspection Tools: `backend/scripts/`**
372+
- Debugging utilities (`check-agent-state.ts`, `inspect-run.ts`)
373+
- **Rule**: Must be prefixed with `check-` or `inspect-` (not part of workflow)
374+
- **Purpose**: Ad-hoc investigation only
375+
376+
---
377+
378+
### ❌ Forbidden Practices
379+
380+
**NEVER create:**
381+
382+
1. **Free-floating shell scripts at root or in service roots**
383+
- ❌ `./run-something.sh`
384+
- ❌ `./backend/debug.sh`
385+
- ✅ Either add to Taskfile OR put in `backend/scripts/check-*.sh`
386+
387+
2. **Helper scripts outside recognized locations**
388+
- ❌ `./helpers/my-script.sh`
389+
- ❌ `./scripts/utility.mjs`
390+
- ✅ Either add to `automation/scripts/` (if reusable) OR backend/scripts/check-* (if debug-only)
391+
392+
3. **Service commands that duplicate automation logic**
393+
- ❌ Backend NPM script that reimplements `check-founder-rules.mjs`
394+
- ✅ Backend NPM script that CALLS `node automation/scripts/check-founder-rules.mjs`
395+
396+
4. **Inline scripts in Taskfiles without module exports**
397+
- ❌ Complex bash logic directly in task YAML
398+
- ✅ Extract to `automation/scripts/` module, call from Taskfile
399+
400+
5. **Scripts with no CLI interface (import-only)**
401+
- ❌ Module that only works as `import { fn } from './script.mjs'`
402+
- ✅ Both: `node script.mjs [command]` AND `import { fn } from './script.mjs'`
403+
404+
---
405+
406+
### 📋 Script Design Requirements
407+
408+
**Every script MUST have:**
409+
410+
| Requirement | Example |
411+
|-------------|---------|
412+
| **Purpose comment** | `// Validates all Founder Rules before commits` |
413+
| **CLI usage** | Works when run directly: `node check-founder-rules.mjs` |
414+
| **Module exports** | `export function checkNoConsoleLog()` for reuse |
415+
| **Exit codes** | `0` = success, `1` = failure |
416+
| **Human-friendly output** | JSON-compatible but readable by default |
417+
| **Optional `--json` flag** | `node script.mjs --json` for machine parsing |
418+
| **Documentation** | Listed in `automation/README.md` or task description |
419+
420+
**Example Pattern:**
421+
```javascript
422+
#!/usr/bin/env node
423+
// Purpose: Check for console.log violations in TypeScript files
424+
425+
export async function checkNoConsoleLog() {
426+
// Implementation
427+
return { violations: [...], passed: boolean };
428+
}
429+
430+
// CLI interface
431+
if (import.meta.url === `file://${process.argv[1]}`) {
432+
const result = await checkNoConsoleLog();
433+
console.log(result.passed ? '✅ All checks passed' : '❌ Violations found');
434+
process.exit(result.passed ? 0 : 1);
435+
}
436+
```
437+
438+
---
439+
440+
### 🎯 Common Patterns
441+
442+
**Adding New Automation:**
443+
444+
1. **Is it recurring?** → Add to `automation/scripts/` (reusable + CLI)
445+
2. **Is it service-specific?** → Add to service NPM scripts
446+
3. **Is it debug-only?** → Add to `backend/scripts/check-*.ts` or `inspect-*.ts`
447+
4. **Is it one-time?** → Put in `.specify/scripts/` (spec-kit only)
448+
449+
**Calling Automation From Different Layers:**
450+
451+
```yaml
452+
# Taskfile: call automation script
453+
tasks:
454+
preflight:
455+
cmds:
456+
- node ../automation/scripts/check-founder-rules.mjs
457+
```
458+
459+
```bash
460+
# Husky hook: call automation script
461+
#!/bin/sh
462+
node automation/scripts/check-founder-rules.mjs
463+
```
464+
465+
```json
466+
// NPM script: delegate to automation
467+
"scripts": {
468+
"check:rules": "node ../automation/scripts/check-founder-rules.mjs"
469+
}
470+
```
471+
472+
```yaml
473+
# GitHub Action: call automation script
474+
- name: Validate
475+
run: node automation/scripts/check-founder-rules.mjs
476+
```
477+
478+
---
479+
480+
## Part III: Environment Policy
324481

325482
### Single Environment Execution
326483
- All local development uses the shared `.env` file checked into the repo.
@@ -361,4 +518,4 @@ cd frontend && bun run dev # Service-specific when needed
361518

362519
---
363520

364-
**Last Updated**: 2025-11-09
521+
**Last Updated**: 2025-11-11

0 commit comments

Comments
 (0)