You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life. — John 3:16
FaithStack Master Spec (v2.0)
"Whatever you do, work at it with all your heart, as working for the Lord." — Colossians 3:23
This repository contains the complete specification for building FaithStack projects. Copy these files into your project's spec_chirho/ directory, or reference them as your AI agent's instructions.
Files in This Gist
File
Purpose
Copy Into
00-README_CHIRHO.md
This file - overview and instructions
—
01-AGENTS_MASTER_CHIRHO.md
Complete AI agent instructions (13 sections)
AGENTS.md
02-TESTING_CHIRHO.md
Solo dev testing guide (fast, headless)
spec_chirho/TESTING_CHIRHO.md
03-COMMUNITY_FEEDBACK_CHIRHO.md
Feedback, tickets, Q&A, surveys, KB
spec_chirho/FEEDBACK_CHIRHO.md
04-DATABASE_AUDIT_CHIRHO.md
Audit pipeline for D1/R2
spec_chirho/AUDIT_CHIRHO.md
05-BEST_PRACTICES_CHIRHO.md
Legal, security, compliance (20 sections)
spec_chirho/BEST_PRACTICES_CHIRHO.md
CLAUDE.md should just contain:@AGENTS.md
Quick Start
New Project
Create your project directory
Copy 01-AGENTS_MASTER_CHIRHO.md to AGENTS.md (or CLAUDE.md)
Create spec_chirho/ directory
Copy relevant guides into spec_chirho/
Initialize git: git init && git add . && git commit -m "Initial commit — JESUS CHRIST IS LORD"
Existing Project
Add AGENTS.md with relevant sections from this spec
Create spec_chirho/ if missing
Add checklists from the guides to track implementation
What Makes a FaithStack Project?
A FaithStack project:
Glorifies God through excellent stewardship
Serves users with high-quality, accessible software
Sustains ministry through sustainable revenue
Uses Chirho conventions (_chirho suffix for our code)
Is spec-driven — spec_chirho/ is the source of truth
Has AI monitoring — feedback systems with escalation
Tech Stack
Layer
Technology
Runtime
Cloudflare Workers
Framework
SvelteKit (recommended)
Database
D1 (SQLite)
Storage
R2
Cache
KV
Email
2SMTP / Mailu
Payments
Stripe
Package Manager
Bun (NEVER npm/yarn/pnpm)
Key Principles
Spec is Truth — YAML schemas in spec_chirho/01_DATA_MODEL_CHIRHO/ define everything
Chirho Suffix — Our code uses _chirho suffix to distinguish from third-party
Git Authority — [AI-CHIRHO] commits indicate AI-assisted work
AI Monitoring — Every project has feedback → ticket → human escalation
Test What Matters — Money paths, auth, core APIs (<30 seconds total)
Database Auditing — All mutations logged to private R2 bucket
For God so loved the world, that He gave His only begotten Son, that all who believe in Him should not perish but have everlasting life. — John 3:16
FaithStack AI Agent Instructions (v2.0)
The Gospel: Jesus Christ, the Son of God, died for our sins, was buried, and rose again on the third day according to the Scriptures. Whoever believes in Him shall not perish but have eternal life. (1 Corinthians 15:3-4, John 3:16)
Section 1: Prime Directive
YOU ARE A SPEC-DRIVEN AI AGENT.
Your job is to implement exactly what is specified, no more, no less. The specification (spec_chirho/) is your single source of truth. When unclear, ASK the human rather than guess.
Critical Rules
SPEC FIRST — Read spec_chirho/ before writing any code
ASK IF UNCLEAR — Never assume. A wrong assumption wastes time.
CHIRHO SUFFIX — ALL our identifiers use _chirho, -chirho, or Chirho suffix
BUN ONLY — Use bun, bunx. NEVER npm, npx, yarn, pnpm.
MATCH PATTERNS — Look at existing code first. Match its style.
GIT AUTHORITY — Uncommitted changes need human confirmation
NO SECRETS IN GIT — NEVER put API keys in wrangler.toml or code
LATEST VERSIONS — Use latest wrangler, adapter-cloudflare (NOT pages)
Section 2: Project Setup Workflow
New Project Setup
Create CLAUDE.md pointing to AGENTS.md:
@AGENTS.md
Copy environment file:
cp ~/.env-chirho .env
Initialize with latest wrangler:
bunx wrangler@latest init project-name-chirho
# Choose: Cloudflare Workers (NOT Pages)# Use adapter-cloudflare, NOT adapter-cloudflare-pages
Copy AGENTS-MASTER-CHIRHO.md to AGENTS.md (customize for project)
Set secrets via wrangler (NEVER in wrangler.toml):
bunx wrangler secret put MASTER_2SMTP_API_KEY_CHIRHO
bunx wrangler secret put STRIPE_SECRET_KEY_CHIRHO
bunx wrangler secret put TURNSTILE_SECRET_KEY_CHIRHO
Section 3: COMPREHENSIVE Identifier Suffixing
CRITICAL: EVERY identifier we create MUST have the chirho suffix in appropriate case.
Standard properties:id, name, email when interfacing with external APIs
HTML attributes:class, id, href, src (but values can have -chirho)
Section 4: Secrets Management
NEVER Put Secrets In:
wrangler.toml
Source code
Git-tracked files
Comments or documentation
Where Secrets Go:
Local development:.env (git-ignored)
# .env (copy from ~/.env-chirho)
MASTER_2SMTP_API_KEY_CHIRHO=mk_...
STRIPE_SECRET_KEY_CHIRHO=sk_live_...
TURNSTILE_SECRET_KEY_CHIRHO=0x...
CLOUDFLARE_API_TOKEN_CHIRHO=...
Production: Wrangler secrets
bunx wrangler secret put MASTER_2SMTP_API_KEY_CHIRHO
bunx wrangler secret put STRIPE_SECRET_KEY_CHIRHO
bunx wrangler secret put TURNSTILE_SECRET_KEY_CHIRHO
Document in .env.example:
# .env.example (git-tracked, no values)
MASTER_2SMTP_API_KEY_CHIRHO=
STRIPE_SECRET_KEY_CHIRHO=
TURNSTILE_SECRET_KEY_CHIRHO=
# Setup
bun install # Install dependencies
cp ~/.env-chirho .env # Copy secrets# Development
bun run dev-chirho # Start dev server# Secrets (production)
bunx wrangler secret put MASTER_2SMTP_API_KEY_CHIRHO
bunx wrangler secret put STRIPE_SECRET_KEY_CHIRHO
bunx wrangler secret put TURNSTILE_SECRET_KEY_CHIRHO
# Database
bunx wrangler d1 create project-db-chirho
bunx wrangler d1 migrations apply DB_CHIRHO
# Deploy
bun run deploy-chirho # Test + deploy
Section 12: Checklist — New Project
### Setup-[ ] CLAUDE.md points to @AGENTS.md
-[ ] AGENTS.md customized from master
-[ ] .env copied from ~/.env-chirho
-[ ] .env.example created (no values)
-[ ] .gitignore includes .env
### Secrets-[ ] NO secrets in wrangler.toml
-[ ] Secrets documented in .env.example
-[ ] Production secrets via `wrangler secret put`### Identifiers-[ ] ALL variables use Chirho suffix
-[ ] ALL functions use Chirho suffix
-[ ] ALL constants use _CHIRHO suffix
-[ ] ALL routes use -chirho or -fe suffix
-[ ] ALL DB columns use _chirho suffix
-[ ] ALL lambda/error vars use Chirho suffix
-[ ] package.json scripts use -chirho suffix
### Features-[ ] Feedback bubble on every page
-[ ] Turnstile protection on forms
-[ ] Footer with fe | loveJesus | ☧ links
-[ ] Privacy/Terms/Contact pages
### Email-[ ] 2SMTP key configured
-[ ] SPF/DKIM/DMARC records set
-[ ] Email addresses use .fe suffix
Section 13: Summary
Key Rules
SUFFIX EVERYTHING — All our identifiers, no exceptions
NO SECRETS IN GIT — .env only, wrangler secret put for prod
LATEST VERSIONS — Use wrangler@latest, adapter-cloudflare
FEEDBACK ON EVERY PAGE — With Turnstile protection
FOOTER WITH LINKS — fe | loveJesus | ☧
IMAGES AS JPG — Convert generated images
Quick Reference
Category
Pattern
Example
TS Variables/Functions/Props
camelCase + Chirho
userDataChirho, fetchChirho()
Classes/Types/Interfaces
PascalCase + Chirho
UserChirho, ConfigChirho
Constants/Env
SCREAMING_SNAKE + _CHIRHO
MAX_SIZE_CHIRHO, API_KEY_CHIRHO
Directories/Files
kebab-case + -chirho
lib-chirho/, auth-chirho.ts
Routes
kebab-case + -chirho or -fe
/api-chirho/, /login-fe
DB Tables/Columns
snake_case + _chirho
users_chirho, created_at_chirho
CSS Classes
kebab-case + -chirho
.button-chirho, .hero-chirho
KV Keys
kebab-case + -chirho
session-chirho:id123-chirho
JSON API Props
camelCase + Chirho
successChirho, dataChirho
package.json scripts
kebab-case + -chirho
dev-chirho, build-chirho
"And whatever you do, in word or deed, do everything in the name of the Lord Jesus, giving thanks to God the Father through him." — Colossians 3:17
For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. — John 3:16
Solo Dev Testing Guide
Version: 1.0
"Trust in the LORD with all your heart, and do not lean on your own understanding." — Proverbs 3:5
But also write tests for the parts that make money.
Philosophy
You push frequently. You code on the go. You can't afford:
Browsers opening randomly
GitHub Actions burning minutes
5-minute test suites blocking deploys
Flaky tests that fail for no reason
So we test differently.
The Strategy
What We Test
Category
Example
Why
Payment logic
Stripe webhook handler
Money
Auth functions
Session validation
Security
Core utilities
Slugify, validation
Used everywhere
API handlers
POST /api/submit
User-facing
What We DON'T Test Automatically
Skip in CI
Why
Component rendering
Use E2E for user flows instead
Every possible path
Only test critical flows
Visual regression
Run manually when needed
Third-party APIs
Mock them
Critical Constraints
HEADLESS ONLY — No GUI popping up
NO CI ON EVERY PUSH — Tests run on deploy or locally
VITEST FOR UNIT — Fast, terminal-based
PLAYWRIGHT FOR E2E — Headless, critical flows only
// src/lib/server/auth-chirho.test.tsimport{describe,it,expect}from'vitest';import{validateSessionChirho,hashPasswordChirho}from'./auth-chirho';describe('Auth — protects user accounts',()=>{it('rejects expired sessions',()=>{constexpiredSession={expiresAt: Date.now()-1000};expect(validateSessionChirho(expiredSession)).toBe(false);});it('accepts valid sessions',()=>{constvalidSession={expiresAt: Date.now()+3600000};expect(validateSessionChirho(validSession)).toBe(true);});it('produces different hashes for same password',async()=>{consthash1=awaithashPasswordChirho('password123');consthash2=awaithashPasswordChirho('password123');expect(hash1).not.toBe(hash2);// Salted});});
API Validation
// src/routes/api-chirho/submit-chirho/submit.test.tsimport{describe,it,expect}from'vitest';import{validateSubmissionChirho}from'./validation-chirho';describe('Submit API — protects data integrity',()=>{it('rejects empty submissions',()=>{constresult=validateSubmissionChirho({title: '',url: ''});expect(result.valid).toBe(false);expect(result.errors).toContain('Title required');});it('accepts valid submissions',()=>{constresult=validateSubmissionChirho({title: 'Test Post',url: 'https://example.com'});expect(result.valid).toBe(true);});});
// tests-e2e-chirho/auth.e2e.tsimport{test,expect}from'@playwright/test';test.describe('Auth Flow',()=>{test('user can log in and see dashboard',async({ page })=>{awaitpage.goto('/login-fe');awaitpage.fill('[name="email"]','test@example.com');awaitpage.fill('[name="password"]','password123');awaitpage.click('button[type="submit"]');awaitexpect(page).toHaveURL('/dashboard-fe');awaitexpect(page.locator('h1')).toContainText('Dashboard');});test('invalid login shows error',async({ page })=>{awaitpage.goto('/login-fe');awaitpage.fill('[name="email"]','wrong@example.com');awaitpage.fill('[name="password"]','wrongpass');awaitpage.click('button[type="submit"]');awaitexpect(page.locator('.error')).toBeVisible();});});
CI Strategy
Option 1: Local Only (Simplest)
bun run deploy-chirho # Tests run locally before deploy
For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. — John 3:16
AI-Monitored Community Feedback Systems
Version: 1.0
"Listen to advice and accept instruction, that you may gain wisdom." — Proverbs 19:20
Every FaithStack project MUST implement these four AI-monitored systems.
<sectionclass="testimonials-chirho"><h2>What Users Are Saying</h2><divclass="building-in-public-chirho"><p>We're just getting started!</p><p>Be among our first users and share your experience.</p><ahref="/feedback-chirho">Share Your Feedback</a></div></section>
## AI Community Monitoring Instructions
As the AI agent, you monitor and respond to all community feedback.
### Responsibilities1.**Feedback Monitoring**- Review all incoming feedback
- Analyze sentiment
- Auto-respond to praise
- Escalate bugs to tickets
2.**Support Ticket Handling**- Auto-respond to FAQ matches
- Escalate if confidence < 0.7
- ALWAYS escalate billing to human
- Alert at 75% SLA deadline
3.**Feature Requests**- Detect duplicates
- Estimate complexity
- Alert at 10+ votes
- Notify voters when shipped
4.**Community Q&A**- AI answer after 30 min
- Escalate after 24 hours
- Flag inappropriate content
5.**Surveys**- Analyze sentiment
- Extract insights for KB
- Follow up with detractors
6.**Knowledge Base**- Query before responding
- Create from resolved tickets
- Track helpful ratings
7.**Daily Digest (8am)**- Feedback count + sentiment
- Open tickets + SLA status
- Top voted features
- Unanswered questions
"And whatever you do, in word or deed, do everything in the name of the Lord Jesus." — Colossians 3:17
For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. — John 3:16
Database Audit Pipeline
Version: 1.0
Every database mutation is logged to a PRIVATE R2 bucket with full user context.
import{createAuditedDbChirho}from'./db-audit-pipeline-chirho';exportdefault{asyncfetch(request: Request,env: Env): Promise<Response>{// Get user from sessionconstuserChirho=awaitgetUserFromSession(request,env);// Create audited databaseconstdbChirho=createAuditedDbChirho(env,request,'my-project-chirho',{userId: userChirho?.id,sessionId: userChirho?.sessionId,userEmail: userChirho?.email});// All mutations are automatically logged!awaitdbChirho.insertChirho('users_chirho',{id_chirho: crypto.randomUUID(),email_chirho: 'new@user.com',name_chirho: 'New User'});awaitdbChirho.updateChirho('users_chirho',{name_chirho: 'Updated Name'},'id_chirho = ?',['user-123']);awaitdbChirho.deleteChirho('sessions_chirho','expires_at_chirho < ?',[Date.now()]);// IMPORTANT: Flush at end of requestawaitdbChirho.flushAuditChirho();returnnewResponse('OK');}};
For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life. — John 3:16
Project Excellence & Best Practices
Version: 1.5
"Whatever you do, work at it with all your heart, as working for the Lord." — Colossians 3:23
// ❌ WRONG - This fails on WorkersconsteventChirho=stripeChirho.webhooks.constructEvent(payloadChirho,signatureChirho,webhookSecretChirho);// ✅ CORRECT - Use async versionconsteventChirho=awaitstripeChirho.webhooks.constructEventAsync(payloadChirho,signatureChirho,webhookSecretChirho);
12. Stripe Coupons & Promotions
Concepts
Concept
Description
Coupon
The discount (20% off, $10 off)
Promotion Code
Customer-facing code (WELCOME20)
Apply at Checkout
constsessionChirho=awaitstripe.checkout.sessions.create({mode: 'subscription',line_items: [{price: priceIdChirho,quantity: 1}],success_url: `${originChirho}/success-fe`,cancel_url: `${originChirho}/pricing-fe`,// Allow customers to enter codesallow_promotion_codes: true,});
13. Cloudflare Workers Project Setup
Use wrangler deploy (NOT wrangler pages deploy)
# ✅ CORRECT - Deploys to Workers
bunx wrangler deploy
# ❌ WRONG - This is for Pages projects
bunx wrangler pages deploy