Cascading Prompt Sheets

Proximity-based
AI governance.

.prompt files colocated with components, cascading resolution in a Node.js core, and a demo API with a debug endpoint to inspect effective rules.

[component: action-button]
[context: e-commerce-checkout]

@governance
  - tone: "urgent and direct"
  - restricted-terms: ["cheap", "free"]
  - accessibility-check: "always validate aria-label"

@logic-constraints
  - max-characters: 30
  - dynamic-state: "if loading, show spinner"
How it works
01

Cascading
inheritance

Rules in root global.prompt are inherited by all subdirectories.

tone: "profissional"
accessibility-check: "always validate WCAG 2.1"
02

Local
specificity

Local prompts load after globals within the same directory, preserving proximity-based resolution order.

loadGlobalPrompts → first
loadLocalPrompts → then
03

Context
injection

The POST /api/generate-prompt and POST /api/resolve-debug endpoints return the final prompt and resolution diagnostics.

filePath: "examples/components/Button.prompt"
userPrompt: "Create a buy button"
Technical implementation

Format and flow
of current runtime

The parser reads [component], [context], sections starting with @, and properties as - key: value. During parse, it converts arrays, booleans, and numbers before assembling the final prompt.

@governance @logic-constraints [component] [context] /api/prompts /api/generate-prompt /api/resolve-debug
const resolver = new PromptResolver('.')
const prompt = await resolver.generatePrompt(
  'examples/components/Button.jsx',
  '\"Buy\" button with aria-label=\"Buy\", visible focus, and AA contrast'
)
Reference implementation

Core

  • Per-directory cache using Map
  • Read global.prompt via inheritance
  • Read local .prompt files

API

  • POST /api/generate-prompt
  • GET /api/prompts/:filePath?
  • POST /api/resolve-debug

Runtime

  • Node.js 14+
  • Express 4.18
  • Page served at /

Each component governs
its own intelligence.

Start with global.prompt, evolve with local files in examples/components, and validate the flow via the generation endpoint.