# ConfigHub: Connection Recipe Template

> Spring-Boot-style auto-detection for coding agents: inspect a repo's stack, wire tracked config, isolated previews, and production approval gates via ConfigHub CLI and hooks, and add zero application runtime dependencies.

## Principles
- **Zero app dependencies:** Never add ConfigHub SDKs or runtime libraries to application code. Keep the app's existing runtime and deployment pipeline intact.
- **Plain files, CLI & hooks only:** Recipes use plain Markdown, `cub` / `confighub` CLI commands, and native harness hooks or `AGENTS.md` rules.
- **Explicit human activation:** Draft the recipe and optional setup files in a reviewable branch/PR. Never install hooks or touch live clusters/hosts silently.
- **Clean exit:** Every recipe must preserve a one-command path back to plain YAML/env files in Git with reasons intact.

---

## Step 1: Check Existing Starters First

Before writing a new recipe, inspect the existing catalog to see if a starter or host guide already covers this stack:
- Starters catalog (17 YAML starters + GitOps AI packs): `https://confighub.github.io/helm-expt/ai-agents/starters.html`
- Host guides (Vercel, Fly, Heroku, Daytona, Unikraft, Self-hosted Helm): `https://confighub.github.io/helm-expt/ai-agents/guides.html`
- Machine-readable catalog & agent router: `https://confighub.github.io/helm-expt/ai-agents/catalog.json` · `https://confighub.github.io/helm-expt/ai-agents/llms.txt`

---

## Step 2: Inspect the Repository

Scan the repository root and deployment directories to identify:
1. **Stack markers:** `vercel.json`, `fly.toml`, `Procfile`, `k8s/`, `Chart.yaml`, `argocd/`, `flux/`, `terraform/`, `Dockerfile`, `docker-compose.yml`, `.env.example`, `package.json`, `pyproject.toml`, `go.mod`.
2. **Config surfaces:** Which files hold tunable operational settings (replicas, timeouts, batch sizes, feature flags, memory limits, routing YAML) vs. secret material that must stay redacted or referenced (`vault://`, `1password://`, AWS/GCP Secret Manager, External Secrets).
3. **Environment split:** How `preview`, `staging`, and `production` differ today, and which CLI commands or GitOps controllers deliver to production.

---

## Step 3: Draft the Connection Recipe (`confighub-recipe.md`)

Generate a single self-contained Markdown file using this exact 6-section schema:

```markdown
# Connection Recipe: <Stack Name>

## 1. Detect
List the exact files or directories that identify this stack (for example: `fly.toml` + `Dockerfile`, or `k8s/overlays/staging/` + `argocd/`).

## 2. Tracked Config Surfaces & Secret Rules
- Tracked files/keys: list exact paths (e.g., `config/runtime.yaml`, `k8s/app.yaml`, `.env.staging`).
- New 12-Factor note (for structured apps): prefer `/etc/<app>/<app>.yaml` with `--print-default-config` and side-effect-free `--validate-config` so the same binary scales from local files to `ConfigMap` (`--roll-on-configmap`) to K8s 1.36+ immutable OCI Image Volumes.
- Protected secrets: list env vars or files that must never be stored in plaintext (e.g., `STRIPE_SECRET_KEY`, `DATABASE_URL`).

## 3. Preview & Staging Loop
- How an agent starts an isolated preview on `127.0.0.1` (or an isolated staging copy on a shared hub) without modifying tracked Git files.
- Which environment (`preview` / `staging`) an agent's scoped key may update directly.

## 4. Production Approval Gate
- Commands agents must NEVER run directly against production (e.g., `fly secrets set`, `vercel env add ... production`, `kubectl apply` on prod context).
- Exact proposal flow (`--change-desc "<reason>"`) and human-only approval command (`cub inbox approve <BASE/ORDER>` + human delivery command).

## 5. PR Config Receipt
Before opening a pull request that changes configuration, attach a secret-redacted receipt:
- Run `confighub mini changes --export-md diff.md` (or export non-secret defaults via `confighub mini starter-export --out starter.yaml`).
- Include: setting changed, old vs. new value, session/agent, and plain-English reason.

## 6. Clean Exit to Plain Git
Show the exact command to export current settings and reasons back into plain YAML/env files in Git so the team can stop using ConfigHub anytime with zero lock-in.
```

---

## Step 4: Propose Setup in a Reviewable PR

1. Place the drafted recipe in the repo (for example, `docs/confighub-recipe.md` or `.agents/skills/confighub-<stack>/SKILL.md`).
2. Offer to include `.claude/settings.json` and the 5-line `AGENTS.md` rule from `https://confighub.github.io/helm-expt/ai-agents/mini.md`.
3. Summarize the detected stack, tracked config files, blocked production commands, and uninstall command in the PR description for human review.

## Optional: Contribute Back to the Open Catalog
If the recipe applies to a general stack (no proprietary paths, hostnames, or internal service names), offer to strip repo-specific details so the user can contribute it as an open MIT recipe for other teams and agents to discover.
