Cline rules
.clinerules/project.mdCline rules
Quality
84/100
Scores the file, not the repository.Length
2,553 words
54 headings · 10 code blocksRepository
0
— · pushed 52 days agoLast changed
3 days ago
First indexed 3 days ago.1# Generated Project Configuration23> **Auto-generated by `analyze_project`**, customized manually4> **Project:** blue-green5> **Type:** infrastructure + TypeScript CLI6> **Last updated:** 2026-06-1178---910## 🚨 MANDATORY: Load CodeOps Rules Before Any Work1112**Before ANY planning or implementation, the AI agent MUST load these rules13using the codeops-mcp tools:**14151. `get_rule("agents")` — Load agent behavior rules **(REQUIRED FIRST)**162. `get_rule("code")` — Load coding standards173. `get_rule("testing")` — Load testing workflows184. `get_rule("git-commands")` — Load git commit protocols1920**Roadmap directive:** If `plans/00-roadmap.md` exists, you MUST read it at the start of every task and update it at every lifecycle stage transition. See `get_rule("roadmap")`.2122These rules are **mandatory** and must be consulted before every task.23**Do NOT skip this step. Do NOT proceed without reading these documents.**2425---2627## Project Overview2829- **Name:** blue-green30- **Description:** Blue-green deployment template and scaffold generator for BlendSDK/WebAFX applications. Provides zero-downtime deployments via Nginx-based blue/green routing, designed to run behind ProxyBuilder for SSL termination. Includes a curl-installable scaffold system that generates project-specific deployment infrastructure, and a TypeScript Deploy CLI that orchestrates deployments from CI runners via SSH.31- **Type:** infrastructure + TypeScript CLI3233### Architecture3435```36Internet → ProxyBuilder (SSL termination, passthrough mode)37 → HTTP → Blue-Green Nginx (security hardening, rate limiting, blue/green routing)38 → App replicas (BlendSDK/WebAFX)39```4041- **ProxyBuilder passthrough mode:** Only does SSL termination + basic proxy headers (Host, X-Real-IP, X-Forwarded-For/Proto/Host/Port). NO security headers, no gzip, no WAF.42- **Blue-Green Nginx:** Handles ALL security hardening, rate limiting, and blue/green traffic routing.43- **Ecosystem stack:** Every app = BlendSDK/WebAFX + blue-green template + ProxyBuilder4445### Deploy CLI4647The Deploy CLI is a TypeScript tool bundled via esbuild into a single JavaScript file (`deploy-cli.js`). It runs on CI runners and orchestrates blue-green deployments to remote servers over SSH.4849- **Source:** `src/deploy-cli/` (TypeScript, ~2800 lines across 15 files)50- **Bundle output:** `scaffold/templates/deployment/scripts/deploy-cli.js` (~41KB, ESM format)51- **Bundler:** esbuild (configured in `esbuild.config.mjs`)52- **Commands:** prepare, switch, deploy, upload, deploy-config, operate, registry53- **Two-phase deploy:** prepare (build/pull + start + health) → barrier → switch (nginx swap)54- **Multi-server support:** Parallel execution with configurable batching (`--max-parallel`)55- **Strategy auto-detection:** In-place (tarball + local build) or registry (pull pre-built image)5657### Deployment Strategies5859| Strategy | How it works | When to use |60|----------|-------------|-------------|61| `in-place` | Upload tarball, Docker builds locally on each server | Simple setups, few servers |62| `registry` | Build once on CI, push to registry, servers pull | Many servers, faster deploys |6364Strategy is auto-detected at runtime by `remote-ops.sh` based on `REGISTRY_URL` in `.env`.6566### Scaffold System6768```69curl -fsSL <repo-url>/install.sh | bash70 → Downloads repo tarball71 → Runs scaffold/scaffold.js (Node.js, zero external deps, built-in readline)72 → Interactive prompts: project name, app port, nginx port, entrypoint, replicas73 → Conditional: strategy, PostgreSQL, Redis, pg-backup (yes/no prompts)74 → Generates deployment/ directory with fully configured infrastructure75```7677- **Entry point:** `install.sh` (thin bash wrapper, downloads repo, invokes scaffold.js)78- **Generator:** `scaffold/scaffold.js` (~580 lines, zero external dependencies)79- **Templates:** `scaffold/templates/` (42 template files for deployment infrastructure)80- **Partials:** `scaffold/partials/` (16 conditional partial files for strategy/PostgreSQL/Redis/pg-backup)81- **Template placeholders:** `{{PROJECT_NAME}}`, `{{APP_PORT}}`, `{{NGINX_PORT}}`, `{{ENTRYPOINT}}`, `{{APP_REPLICAS}}`, `{{APP_BUILD_SECTION}}`82- **Conditional generation:** `{{PARTIAL_*}}` placeholders inject content from `scaffold/partials/` based on user answers83- **Comment-wrapped placeholders:** In bash templates, `# {{PARTIAL}}` so `bash -n` syntax checks pass on raw templates84- **Conflict detection:** Skips existing files by default; `--force` flag overwrites8586### Docker Compose Profiles8788| Profile | Services |89|---------|----------|90| `core` | nginx, postgres, redis |91| `blue` | app-blue replicas |92| `green` | app-green replicas |93| `all` | core + blue + green |94| `db` | postgres only |9596### Nginx Modular Config9798```99nginx/nginx.conf — Main config, includes all modules100nginx/conf.d/ — Server-level config (server-name)101nginx/includes/ — Shared includes (headers, proxy, timeouts, etc.)102nginx/locations/ — Location blocks (health, ping, status, default)103nginx/upstreams/ — Upstream definitions (blue, green, active)104```105106## Toolchain107108- **Language(s):** TypeScript (Deploy CLI), Docker, Nginx config, Bash scripts, Node.js (app + scaffold)109- **Framework(s):** BlendSDK/WebAFX (app layer)110- **Package Manager:** npm111- **Bundler:** esbuild (bundles TypeScript Deploy CLI to single JS file)112- **Test Framework:** Node.js built-in test runner (`node:test`) for Deploy CLI113- **Test Runner:** `node --experimental-strip-types --test src/deploy-cli/__tests__/*.test.ts`114- **Scaffold Runtime:** Node.js (zero external dependencies, built-in readline)115116**Manifest files found:** package.json, docker-compose.yml, app/package.json, scaffold/package.json, tsconfig.json117118## Commands119120All commands assume execution from the project root. Prefix all shell commands with `clear && sleep [delay] &&` (see Terminal Delay below).121122### Terminal Delay123124- **Delay (seconds):** 3125- The `clear` ensures a clean terminal; the `sleep` gives VS Code time to initialize the terminal before the command runs.126- Adjust the delay for your environment: `1` for fast machines, `3` (default) for normal, `5` for slower environments.127- All command examples below use `sleep 3` — replace `3` with your configured delay.128129### Build130131```bash132# Build Deploy CLI bundle133clear && sleep 3 && npm run build:cli134135# Build Docker containers136clear && sleep 3 && docker compose build137```138139### Test / Validate140141```bash142# Run Deploy CLI unit tests (57 tests)143clear && sleep 3 && npm run test:cli144145# Validate docker-compose configuration146clear && sleep 3 && docker compose config147148# Type-check TypeScript149clear && sleep 3 && npx tsc --noEmit150```151152### Verify (before commit)153154```bash155# Full verification — run this before any git commit156clear && sleep 3 && npm run verify && bash -n scaffold/templates/deployment/scripts/remote-ops.sh157```158159### Blue-Green Switch160161```bash162# Switch active environment (blue↔green)163clear && sleep 3 && bash scripts/switch-environment.sh164```165166### Scaffold (run from target project)167168```bash169# Install scaffold into a new project (from target project root)170curl -fsSL https://raw.githubusercontent.com/blendsdk/blue-green/master/install.sh | bash171172# Or run scaffold.js directly during development173clear && sleep 3 && node scaffold/scaffold.js174```175176## Project Structure177178### Type: Single repository179180### Directory Layout181182```183install.sh — Curl-installable entry point (downloads repo, runs scaffold.js)184package.json — Root package.json (type: module, esbuild + TypeScript devDeps)185tsconfig.json — TypeScript config (strict, ESNext, noEmit)186esbuild.config.mjs — esbuild bundler config for Deploy CLI187app/ — Application container (BlendSDK/WebAFX)188 Dockerfile — Multi-stage Node.js build189 package.json — App dependencies190 server.js — Application entry point191 start.sh — Container startup script192 healthcheck.sh — Docker health check script193data/194 postgresql/ — PostgreSQL data volume mount195nginx/ — Nginx configuration (modular)196 nginx.conf — Main config197 conf.d/ — Server-level includes198 includes/ — Shared config fragments199 locations/ — Location blocks (numbered for ordering)200 upstreams/ — Blue/green/active upstream definitions201src/deploy-cli/ — Deploy CLI TypeScript source202 index.ts — Entry point, argument parser, command dispatcher203 types.ts — All interfaces and type definitions204 lib/ — Core libraries205 process.ts — Spawn helper with timeout and stream capture206 logger.ts — Structured output with emoji prefixes207 ssh.ts — SSH setup, exec, SCP upload, cleanup208 config.ts — Config resolution ({ENV} placeholders)209 inventory.ts — Server inventory resolution (scope/filter)210 commands/ — Command implementations211 shared.ts — Common infrastructure (parseDeployOptions, executeOnServers)212 upload.ts — Multi-step file upload to servers213 deploy-config.ts — Config file deployment from secrets214 operate.ts — Generic remote-ops.sh subcommand runner215 prepare.ts — Blue-green prepare (phase 1)216 switch.ts — Blue-green switch (phase 2)217 deploy.ts — Coordinated deploy with barrier218 registry.ts — Docker build + push (CI-side)219 __tests__/ — Unit tests (57 tests)220 config.test.ts — Config resolution tests (13)221 inventory.test.ts — Server inventory tests (24)222 parser.test.ts — Argument parser tests (20)223 fixtures/ — Test fixture files224 deploy-config.json — Test config fixture225 deploy-inventory.json — Test inventory fixture226scaffold/ — Scaffold generator system227 package.json — CJS override (type: commonjs for scaffold.js)228 scaffold.js — Interactive generator (~580 lines, Node.js, zero deps)229 templates/ — Template files (42 files, mirrors deployment structure)230 .gitignore.template — Generated .gitignore for target projects231 deploy-config.json — Deploy configuration template232 deploy-inventory.json — Server inventory template233 deploy-package.sh — Deploy packaging script template234 deployment/ — Full deployment infrastructure templates235 .env.example — Environment variable template236 docker-compose.yml — Docker Compose template with conditional services237 Dockerfile — App Dockerfile template238 pg-backup.sh — PostgreSQL backup script (conditional)239 nginx/ — Nginx config templates (mirrors nginx/ structure)240 nginx.conf241 conf.d/server-name.conf242 includes/*.conf — All include templates243 locations/*.conf — All location templates244 upstreams/*.conf — All upstream templates245 scripts/ — Deployment scripts (3 files)246 deploy-cli.js — Deploy CLI bundle (ESM, ~41KB)247 remote-ops.sh — Remote operations script (SSH commands)248 health-check-wait.sh — Health check wait script249 .github/ — GitHub Actions workflow templates250 SECRETS-SETUP.md — GitHub Secrets documentation251 workflows/252 build-test.yml — CI: build + test on every push/PR253 release-single.yml — CD: single-server release254 release-multi.yml — CD: multi-server release (three-job barrier)255 operations-single.yml — Ops: single-server operations256 operations-multi.yml — Ops: multi-server operations257 local_data/ — Local data directory template258 .gitkeep — Keeps directory in git259 scripts/ — Project-level script templates260 push-secrets.sh — Secret pushing script template261 partials/ — Conditional partial files (16 files)262 compose-build-inplace.yml — In-place Docker build section263 compose-build-registry.yml — Registry Docker image section264 docker-compose-postgres.yml — PostgreSQL service block265 docker-compose-redis.yml — Redis service block266 docker-compose-pgbackup.yml — pg-backup service block267 env-postgres.txt — PostgreSQL env vars268 env-redis.txt — Redis env vars269 env-backup.txt — Backup env vars270 env-registry.txt — Registry env vars271 remote-ops-database-commands.sh — Database command functions272 remote-ops-dispatcher-database.sh — Database dispatcher entries273 remote-ops-health-check-db.sh — Database health check274 remote-ops-help-database.sh — Database help text275 operations-database-options.yml — GitHub Actions database options276 operations-database-steps.yml — GitHub Actions database steps277plans/ — Implementation plans and notes278 deploy-cli/ — Deploy CLI implementation plan (9 phases, 66 tasks)279 00-index.md — Plan index280 01-requirements.md — Requirements document281 02-current-state.md — Current state analysis282 03-deploy-cli-architecture.md — Deploy CLI architecture283 04-remote-ops-updates.md — Remote ops two-phase + registry updates284 05-registry-deployment.md — Registry deployment templates285 06-workflow-refactoring.md — Workflow YAML refactoring286 07-scaffold-updates.md — Scaffold generator updates287 08-scaffoldapp-migration.md — ScaffoldApp migration288 09-testing-strategy.md — Testing strategy289 99-execution-plan.md — Execution plan (66/66 tasks complete)290 scaffold-deployment/ — Scaffold system implementation plan (47/47 tasks complete)291 remove-internet-mode/ — Completed: removed internet/certbot mode292 refactor-blue-green/ — Original refactoring plan293 security-hardening/ — Security hardening plan (in progress)294 security-hardening-notes.md — Future security improvements295scripts/ — Operational scripts296 agent.sh — VS Code agent mode switching297 health-check-wait.sh — Wait for healthy containers298 switch-environment.sh — Blue↔green environment switcher299```300301## Coding Conventions302303### Naming304305- **Files:** kebab-case (`switch-environment.sh`, `proxy_headers.conf`)306- **TypeScript files:** kebab-case (`deploy-config.ts`, `shared.ts`)307- **Nginx configs:** Numbered prefix for ordering in `locations/` (`10-health.conf`, `99-default.conf`)308- **Scripts:** kebab-case with descriptive names309- **Environment variables:** UPPER_SNAKE_CASE (`ACTIVE_ENV`, `APP_REPLICAS`)310- **Template files:** Same name as target output file (e.g., `docker-compose.yml` template → generates `docker-compose.yml`)311- **Partial files:** Descriptive kebab-case with service prefix (`docker-compose-postgres.yml`, `env-redis.txt`, `remote-ops-health-check-db.sh`)312313### TypeScript / Deploy CLI Style314315- **Import convention:** All internal imports use `.ts` extensions for `--experimental-strip-types` compatibility316- **Module format:** ESM (`"type": "module"` in root package.json)317- **Type imports:** Use `import type { ... }` for type-only imports318- **JSDoc comments:** Required on all exported functions and interfaces319- **Constants:** UPPER_SNAKE_CASE for module-level constants320- **Error handling:** Commands exit with `process.exit(1)` on failure, never throw uncaught321- **No private members:** Use `protected` instead of `private` (per code.md)322323### Nginx Config Style324325- Use `include` directives for modularity — one concern per file326- Comment every config file with its purpose327- Reference ProxyBuilder in upstream/architecture comments328- Use `conf.d/`, `includes/`, `locations/`, `upstreams/` subdirectories329330### Shell Script Style331332- Always include `#!/bin/bash` shebang333- Use `set -e` for error handling334- Add descriptive comments explaining purpose335336### Scaffold Template Style337338- **Placeholders:** Use `{{UPPER_SNAKE_CASE}}` for variable substitution (e.g., `{{PROJECT_NAME}}`, `{{APP_PORT}}`)339- **Conditional partials:** Use `{{PARTIAL_NAME}}` for content injection from `scaffold/partials/`340- **Comment wrapping:** In bash/shell templates, wrap partials in comments: `# {{PARTIAL_NAME}}` so `bash -n` passes on raw templates341- **Template mirroring:** Templates in `scaffold/templates/deployment/` mirror the exact directory structure of the generated output342- **Zero dependencies:** scaffold.js uses only Node.js built-in modules (`fs`, `path`, `readline`)343344## Git & Commit Conventions345346### Commit Scope347348```349# Use module/feature as scope:350# feat(deploy-cli): description351# feat(nginx): description352# feat(docker): description353# feat(scripts): description354# feat(scaffold): description355# chore(plans): description356# docs(readme): description357```358359### Valid Scopes360361- `deploy-cli` — Deploy CLI TypeScript source and tests362- `nginx` — Nginx configuration changes363- `docker` — Docker Compose, Dockerfile changes364- `scripts` — Script additions/modifications365- `app` — Application code changes366- `scaffold` — Scaffold generator, templates, partials, install.sh367- `plans` — Plan documents368- `readme` / `docs` — Documentation369- `env` — Environment variable changes370- `security` — Security-related changes371372### Branch Strategy373374- **Main branch:** `master`375- **Feature branches:** `feature/[name]`376377## Special Rules (Project-Specific)378379### ProxyBuilder Awareness380381- This template NEVER handles SSL/TLS directly — ProxyBuilder does SSL termination382- HSTS headers are set at the Nginx layer but work because ProxyBuilder passes them through to browsers over HTTPS383- Security headers are ALL set at the blue-green Nginx layer (ProxyBuilder is a "dumb passthrough")384- No certbot, no SSL certificates, no HTTPS port in this template385386### Environment Variables387388- Core env vars: `COMPOSE_PROJECT_NAME`, `APP_REPLICAS`, `ACTIVE_ENV`, `NGINX_HTTP_PORT`389- Service-specific: `HEALTH_CHECK_*`, `POSTGRES_*`, `REDIS_*`390- Registry-specific: `REGISTRY_URL`, `REGISTRY_USER`, `REGISTRY_PASSWORD`, `IMAGE_NAME`391- No `NGINX_MODE`, `NGINX_HTTPS_PORT`, `DOMAIN_NAME`, or `CERTBOT_EMAIL` (removed in remove-internet-mode)392393### Security Model (rated 7/10)394395- Strong SSL at edge (ProxyBuilder), comprehensive headers at Nginx layer396- Rate limiting, IP anonymization via trusted_proxies397- Known gaps documented in `plans/security-hardening-notes.md`:398 - trusted_proxies too broad (trusts all private ranges)399 - No per-endpoint rate limits400 - CSP not flexible for HTML apps401 - No WAF402403### Deploy CLI Rules404405- **Bundle format:** ESM — runs in contexts where parent `package.json` has `"type": "module"`406- **scaffold/package.json** has `"type": "commonjs"` for scaffold.js — the bundle under `scaffold/templates/` inherits CJS context locally, but works in generated projects407- **SSH key is optional:** CI environments may provide key via `SSH_PRIVATE_KEY` env var, or use pre-configured SSH agents408- **Jump host:** Uses `ProxyCommand` with `ssh -W %h:%p` (not `ProxyJump`) for older SSH compatibility409- **DEPLOY_PATH:** Must be absolute path (`/opt/app`), NOT `~/path` (tilde expands on CI runner, not remote server)410- **Two-phase deploy safety:** If ANY server fails prepare, the deploy command aborts without switching any server411412### Scaffold System Rules413414- **Template placeholders** (`{{...}}`) are replaced at generation time — they do NOT appear in generated output415- **Partial injection** is all-or-nothing: if user says "no" to PostgreSQL, the entire PostgreSQL partial is omitted (empty string)416- **Conflict detection:** scaffold.js skips files that already exist unless `--force` is passed417- **Generated output structure:** Target project gets `deployment/`, `scripts/push-secrets.sh`, `deploy-config.json`, `deploy-inventory.json`, `deploy-package.sh`, `.gitignore`, `local_data/.gitkeep`, `.github/workflows/`, `.github/SECRETS-SETUP.md`418- **No runtime dependencies:** scaffold.js and all generated scripts use only bash and Node.js built-ins419- **install.sh requirements:** Must work with `curl -fsSL <url> | bash` — no interactivity in the download phase, interactivity starts when scaffold.js runs420- **GitHub Actions workflows** are generated into `.github/workflows/` — single-server gets `release.yml` + `operations.yml`, multi-server gets `release-multi.yml` + `operations-multi.yml`421422## Cross-References423424The generic rule files that read this `project.md`:425426- **make_plan.md** — Uses verify command, file paths, commit scope, task file path patterns427- **code.md** — Uses language conventions, architecture rules428- **testing.md** — Uses test commands, test locations, test framework429- **git-commands.md** — Uses commit scope, verify command430- **agents.md** — Uses shell commands, verify command431- **requirements.md** — Uses project type, tech stack, and conventions for requirements discovery432- **retro_requirements.md** — Uses project type, tech stack for codebase analysis adaptation433- **techdocs.md** — Uses project type, tech stack for documentation generation434- **upgrade_plan.md** — Uses project context for upgrade compatibility checks435- **grill_me.md** — Uses project context for deep disambiguation before planning or requirements436- **preflight.md** — Uses project type, tech stack, and conventions for grounded quality audits437- **roadmap.md** — Tracks RDs/plans across the feature-set lifecycle if a roadmap exists (make_roadmap)438
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| bashdeban/fastmind.clinerules/.project-consistency-keeper2.md · 5 | Cline rules | setupbuildtestlint-format+11 | 100/100 | 3 days ago | |
| JCodesMore/ai-website-cloner-template.clinerules · 31k | Cline rules | buildlint-formatstylearch+3 | 97/100 | 2 days ago | |
| BryaanF/LiantPortfolio.clinerules/project-guidelines.md · 0 | Cline rules | buildstylearchgit+2 | 96/100 | 3 days ago | |
| u9401066/zotero-keeper.clinerules/50-pubmed-project.md · 7 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| u9401066/zotero-keepervscode-extension/resources/repo-assets/pubmed-search-mcp/.clinerules/50-pubmed-project.md · 7 | Cline rules | testlint-formatstylearch+1 | 94/100 | 3 days ago | |
| VaillerTeeter/HoshimiNest.clinerules/project-identity.md · 1 | Cline rules | setuparchtypesdo-not | 93/100 | yesterday | |
| HerringtonDarkholme/megarepo.clinerules/02-development.md · 17 | Cline rules | setupbuildteststyle+3 | 92/100 | 3 days ago | |
| blendsdk/codeops-mcp.clinerules/project.md · 0 | Cline rules | buildteststylearch+7 | 91/100 | 3 days ago |
