init-makefiles
Use if scaffolding Makefile targets for dev, tunnels, deploys, R2, Supabase, Railway, Vercel.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use if scaffolding Makefile targets for dev, tunnels, deploys, R2, Supabase, Railway, Vercel.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use skill if you are exhaustively testing or release-gating martool CLI commands in a source checkout or deployed Coolify container over SSH, without local Docker or provider spend.
Use if driving agent-browser for Chrome/CDP automation, @ref snapshots, tabs, or verification.
Use if testing or debugging an iOS app via agent-device CLI — simulator flows, evidence, bug triage.
Use if supervising Jean agents through MCP and Computer Use for monitoring, recovery, or closure.
Use if auditing or designing a CLI for agent/LLM use — JSON output, exit codes, non-interactive.
Use if auditing or designing an MCP server for agent-readiness — framework, security, context.
| name | init-makefiles |
| description | Use if scaffolding Makefile targets for dev, tunnels, deploys, R2, Supabase, Railway, Vercel. |
Make is the project's control plane. Generate one Makefile per app (root + up to 3 sub-Makefiles in monorepos), zero required arguments, scenario-appropriate targets only, with safe replacement of any prior scaffold.
This is the consolidated successor to the old make-local, make-railway, and make-vercel direction. Do not recreate provider-specific Makefile skills — classify the project's scenario here, then generate only the targets that scenario needs.
Trigger on any of these:
make local and make prod"make local is broken / port-stuck / out of date" — refresh stale targetsmake tunnel / make funnel" for Tailscale exposuremake deploy"Do NOT use this skill when:
run-railwayinit-agent-configbuild-mcp-use-servermake local binds 127.0.0.1. make local-lan binds 0.0.0.0. make tunnel runs Tailscale Serve (tailnet-only). make funnel is PUBLIC and gated behind explicit PUBLIC_FUNNEL=1. Funnel never enables as a side effect of any other command.make local PORT=4000) but defaults must work. Sole exception: make supabase-migrate-new name=<n>.SHELL := bash, .SHELLFLAGS := -eu -o pipefail -c, .ONESHELL:, .DELETE_ON_ERROR:, MAKEFLAGS += --warn-undefined-variables --no-builtin-rules, .DEFAULT_GOAL := help. Full preamble in references/makefile-base.md._free-port-% helper from references/port-hygiene.md. Only kill our own dev processes (node|next-server|turbo|turbopack|next|bun|deno); refuse foreign holders, suggest +10 port.make local-lan. Tailscale Serve via make tunnel (tailnet-only). Tailscale Funnel via make funnel (PUBLIC, opt-in only)._ (_check-vercel-tokens, _free-port-%, _print-banner-*). They do not appear in make help.Pick exactly one scenario per deployable app. The seven:
| # | Scenario | Primary signal | What's in scope |
|---|---|---|---|
| A | Frontend-only | next.config.* / vite.config.* / etc.; no backend dir; no Supabase | Local, LAN, tunnel; Vercel deploy by default. Cloudflare Pages is opt-in only — switch to it when (and only when) the user explicitly says "Cloudflare", "Pages", "Wrangler", or names the Pages product. Disk signals alone (a stray wrangler.toml for R2/Workers) never flip the default. |
| B | MCP server | @modelcontextprotocol/sdk or mcp-use in deps | Local; no deploy; inspect target |
| C | Frontend + backend | A signals + apps/api (or similar) with Express/Hono/Fastify | Frontend + Vercel + Railway |
| D | Frontend + Supabase | A signals + @supabase/supabase-js + supabase/ dir | Frontend + Vercel + Supabase CLI ops |
| E | Multi-service Railway | Multiple service dirs / railway.toml files | Railway only; parallel deploy where safe |
| F | Build-artifact | Cargo / Go / Swift / native CLI; no HTTP framework, no remote target | Build + run locally; no deploy |
| G | MacBook ship | .xcodeproj / Package.swift Mac target + remote-Mac SSH alias | Build + ship via rsync + atomic swap + verify |
For single-app projects, the final classification has one tag. For monorepos, each deployable app gets one tag and the root gets a dominant orchestration tag. Use the supported combined tag C+D only when a custom backend deploys separately and Supabase is also in scope.
If detection is ambiguous → ask one targeted question, never guess. Sample disambiguation prompts in references/scenario-detection.md.
Capture the project's state before writing anything:
# Package manager
ls bun.lockb pnpm-lock.yaml yarn.lock package-lock.json 2>/dev/null
# Framework signals (frontend)
ls next.config.* vite.config.* astro.config.* nuxt.config.* svelte.config.* remix.config.* 2>/dev/null
# Supabase
ls supabase/config.toml 2>/dev/null
jq -r '.dependencies | keys[]?' package.json 2>/dev/null | grep -i supabase
# Monorepo
ls turbo.json pnpm-workspace.yaml apps/ packages/ 2>/dev/null
jq -r '.workspaces' package.json 2>/dev/null
# Backend signals
find apps server services -maxdepth 2 -name "package.json" 2>/dev/null | head
# MCP server
jq -r '.dependencies | keys[]?' package.json 2>/dev/null | grep -E 'modelcontextprotocol|mcp-use'
# Mac signals
ls *.xcodeproj *.xcworkspace Package.swift Info.plist 2>/dev/null
# Existing Make scaffolding
ls Makefile *.mk scripts/dev.sh scripts/deploy.sh 2>/dev/null
find . -maxdepth 3 -name "Makefile" -not -path "./node_modules/*"
# AGENTS.md / CLAUDE.md state
ls -la AGENTS.md CLAUDE.md 2>/dev/null
Then run the bundled detector for a second, low-freedom signal pass. Resolve scripts/scenario-detect.sh relative to this skill directory and pass the downstream project root:
bash scripts/scenario-detect.sh /path/to/project
The detector is read-only and heuristic-only; it prints observed signals and candidate scenarios, not the final answer. Full detection cheat sheet in references/scenario-detection.md; detector implementation notes in scripts/scenario-detect.md.
If a precondition fails (no package.json, no dev script, no SSH alias for Mac scenario), surface it before generating. Do not generate something that breaks on first run.
Before generating files, print this block:
Scenario: <A-G, or C+D for supported combined shape>
Scope: <repo root or per-app paths>
Confidence: <high|medium>
Signals: <observed files/deps/commands>
Excluded scenarios: <why the near misses were rejected>
Provider scope: <Vercel/Railway/Supabase/MacBook/local-only>
Makefiles to generate: <root + app paths, max 4>
Ambiguity resolved: <none or the answered question>
Run the bundled wipe preview before touching files. Resolve scripts/preview-makefile-wipe.sh relative to this skill directory and pass the downstream project root:
bash scripts/preview-makefile-wipe.sh /path/to/project
bash scripts/preview-makefile-wipe.sh /path/to/project --paths-only > /tmp/init-makefiles-candidates.txt
The script is read-only. It prints exact paths, match reasons, tracked state, and uncommitted status; implementation notes live in scripts/preview-makefile-wipe.md.
For every candidate Makefile, *.mk, make-*.sh, scripts/dev.sh, and scripts/deploy.sh: read the file before classifying it as scaffold. Note useful patterns the user encoded (custom env handling, project-specific port choices, framework-specific dev commands) — those inform regenerated targets.
Write a deletion manifest containing only paths approved for replacement:
DELETION_MANIFEST=/tmp/init-makefiles-delete-manifest.txt
# write one approved path per line, exactly as printed by the preview
Refuse to continue if a candidate has uncommitted non-scaffold edits the agent cannot classify. If unrelated dirty files exist, leave them untouched and state that they were not snapshotted.
Create a targeted snapshot commit before deletion. Stage only manifest paths:
git status --porcelain
while IFS= read -r path; do
[ -n "$path" ] || continue
git add -- "$path"
done < "$DELETION_MANIFEST"
git commit -m "chore(make): snapshot existing scaffold before init-makefiles regen"
Never use git add -A for the snapshot. Never auto-commit unrelated work.
Print recovery before deleting:
SNAPSHOT_SHA=$(git rev-parse --short HEAD)
printf 'Recovery: git revert %s\n' "$SNAPSHOT_SHA"
printf 'Single file: git restore --source=%s -- path/to/Makefile\n' "$SNAPSHOT_SHA"
Delete only manifest paths:
while IFS= read -r path; do
[ -n "$path" ] || continue
rm -f -- "$path"
done < "$DELETION_MANIFEST"
Compose the new Makefile(s) from the scenario's references:
references/makefile-base.md (every Makefile uses this)references/makefile-frontend.md (local, local-lan, tunnel, deploy-vercel, verify, env-pull, build-check)references/makefile-cloudflare-pages.md (deploy-cloudflare, cf-project-init, cf-list, cf-tail, _redirects, Pages 25 MiB/file + 20k-file limits)references/makefile-r2-bulk.md (orthogonal — works regardless of whether the frontend is hosted on Vercel or Pages, opt-in when R2 is part of the workflow)references/makefile-backend.md (Railway deploy, multi-service parallel, healthcheck rules, railway.toml baseline)references/makefile-supabase.md (supabase-link, -migrate-*, -functions, -types, -secrets-*)references/makefile-macbook.md (preflights, rsync, atomic swap, kill-then-launch, verify)references/makefile-monorepo.mdAlways pull tunnel/funnel rules from references/tailscale-funnel-rules.md (macOS DNS quirks, Funnel port restrictions, ACL preflight) and port-kill behavior from references/port-hygiene.md (kill-only-our-own pattern, default-port squat list, SIGTERM-then-SIGKILL escalation).
Env conventions per scenario live in references/env-vars-conventions.md (.env.local vs .env.railway, Vercel sensitivity defaults, Railway built-in vars).
Apply the 5-state machine in references/agents-md-update.md. The contract:
## Make targets section is written/updated, listing every generated target, env-var knob, and what the skill will and will not doCLAUDE.md → AGENTS.md compatibility links are in scope## Make targets sections require explicit replacement consentinit-agent-configRun the verification ladder in references/verification-ladder.md. The skill claims at most rung 5 (external curl from this machine, no proxy). Rung 6 (independent client — phone on cellular) is a manual user step printed in the post-deploy banner.
Per scenario:
make local opens browser; make deploy returns Ready URL; make verify HTTP-probesmake local starts MCP on 127.0.0.1:<port>; make inspect returns tool schemamake deploy-all deploys services in parallel; make verify HTTP-probes eachmake build produces a binary; ./build/<name> --version runs without errormake ship rsyncs and pgrep -x "$(APP_NAME)" returns a PID after sleep 2Core generation is complete when Makefiles, AGENTS.md sync, and verification are done. The skill remains useful and complete if CI/CD is declined.
Ask first: "Generate GitHub Actions deploy wiring locally? (y/n)". If yes, follow references/ci-cd-workflow.md:
gh repo view --json nameWithOwner -q .nameWithOwner.github/workflows/deploy.yml for the providers in scope onlygh secret set <NAME> --body "$pasted" for each required secretgh secret listIf declined, leave .github/workflows/ untouched. No half-baked YAML.
make local binds 127.0.0.1. LAN exposure must be explicit (make local-lan).make funnel is the only target that uses Funnel, and only with PUBLIC_FUNNEL=1.LOCAL_BACKEND=1 is set explicitly.supabase/ exists. MacBook only if a Mac project + remote-Mac target.git log --oneline -- Makefile
git show --stat <snapshot-sha>
git revert <snapshot-sha>
# or restore a single file:
git restore --source=<snapshot-sha> -- path/to/Makefile
| Symptom | Cause | Fix |
|---|---|---|
make local fails with "port :PORT held by orbstack" | Foreign port holder; refused per port-hygiene rule | Pick a different port (make local PORT=4000); don't kill OrbStack |
make tunnel reports "tailscale not signed in" | Tailscale daemon up but account not linked | tailscale up interactively; this skill assumes Tailscale is signed in |
make deploy-vercel fails with "Project not found" | .vercel/project.json missing or wrong project name | Re-run vercel link --yes --project <name> --token=$VERCEL_TOKEN |
make deploy-railway returns 502 "Application Failed to Respond" | App listens on localhost:3000 not 0.0.0.0:$PORT | Fix app's bind address; redeploy |
make supabase-migrate-apply no-ops with "no migrations to apply" | Migration files already in remote history | Run make supabase-pull to detect drift |
make ship fails preflight with "ssh alias not found" | Host macbook not in ~/.ssh/config | Add the Host block; make ship re-checks |
| AGENTS.md and CLAUDE.md both exist with different content | State 1 of the symlink machine | Skill prompts user; merges into AGENTS.md per references/agents-md-update.md |
gh secret set fails with "auth required" | Not authenticated | gh auth login; CI/CD step re-runs |
| Vercel build fails with function over 250 MB | Heavy bundled deps | make build-check surfaces sizes; references/makefile-frontend.md lists mitigations |
make funnel rejects port 3000 | Funnel allows only 443/8443/10000 | Use make funnel TUNNEL_PORT=443 (and PUBLIC_FUNNEL=1) |
make tunnel works but host <node>.<tailnet>.ts.net fails on macOS | macOS DNS quirk: host/nslookup/bare dig bypass system resolver | Use tailscale dns query <fqdn> or dscacheutil -q host -a name <fqdn> |
Return this shape when the downstream project work is done:
Scenario: <chosen scenario and confidence>
Generated files: <paths>
Deleted/replaced scaffold paths: <paths or none>
Snapshot: <sha and recovery command>
AGENTS.md / CLAUDE.md: <state>
CI/CD: <skipped | generated locally | secrets wired | pushed>
Verification: <rung actually reached per target>
Manual verification still required: <targets, especially rung 6>
| File | Read when |
|---|---|
references/scenario-detection.md | Classifying a project; resolving ambiguity; sample disambiguation prompts |
references/makefile-base.md | Universal preamble, ANSI palette, helper conventions; every Makefile uses this |
references/makefile-frontend.md | Generating Scenarios A / C / D frontend targets (local, local-lan, tunnel, deploy-vercel, verify, env-pull, build-check) |
references/makefile-cloudflare-pages.md | Scenario A Cloudflare Pages variant — opt-in only. Read this reference only when the user explicitly mentions Cloudflare / Pages / Wrangler. The Scenario A default is Vercel (makefile-frontend.md). Contents: deploy-cloudflare, cf-project-init, cf-list, cf-tail, wrangler.toml shape, _redirects proxying, 25 MiB-per-file / 20k-file limit checks. |
references/makefile-r2-bulk.md | Cloudflare R2 media (opt-in when R2 is part of the workflow; works with either Vercel or Pages-hosted frontends): r2-info, r2-cors-apply, single-file r2-put/r2-get/r2-rm, hardlink r2-stage, rclone-configure/rclone-check, r2-sync (rclone copy — additive default for mixed-tenant safety), wrangler-OAuth bulk fallback, public-access audit |
references/makefile-backend.md | Generating Scenarios C / E backend targets (Railway deploy, multi-service parallel, healthcheck rules, railway.toml baseline) |
references/makefile-supabase.md | Generating Scenario D Supabase targets (supabase-link, -migrate-*, -functions, -types, -secrets-*) |
references/makefile-macbook.md | Generating Scenario G ship pipeline (preflights, rsync, atomic swap, kill-then-launch, verify) |
references/makefile-monorepo.md | Multi-Makefile delegation; 4-file ceiling; per-app namespacing; root-Makefile $(MAKE) -C pattern |
references/tailscale-funnel-rules.md | Tunnel/Funnel target generation; macOS DNS quirks; Funnel port restrictions; ACL preflight |
references/port-hygiene.md | The kill-only-our-own pattern; default-port squat list; SIGTERM-then-SIGKILL escalation; banner conventions |
references/agents-md-update.md | The 5-state machine for AGENTS.md / CLAUDE.md; the ## Make targets section template; idempotency rule |
references/ci-cd-workflow.md | Wiring GitHub Actions; gh secret set sequence; concurrency rules; rotation hint |
references/env-vars-conventions.md | Where envs live per scenario; .env.local vs .env.railway; Vercel sensitivity defaults; Railway built-in vars |
references/verification-ladder.md | The 6 rungs; per-target verification; banner template for the user's manual rung-6 step |
scripts/scenario-detect.md | Read-only heuristic detector script; use before final classification and ambiguity questions |
scripts/preview-makefile-wipe.md | Read-only wipe preview script; use before manifest, targeted snapshot, and deletion |
run-railway — for ad-hoc Railway CLI ops not covered by deploy targets (logs, scale, restart, env management beyond what the Makefile exposes)build-mcp-use-server — for hosted-MCP scenarios beyond local-only MCP servers (Scenario B is for local-facing MCP only)init-agent-config — for AGENTS hierarchy, REVIEW.md, folder-scoped agent config, and broad repo governancemake tunnel. Funnel only in make funnel with PUBLIC_FUNNEL=1 ack.tailscale serve reset / tailscale funnel reset without explicit user consent. They wipe ALL mappings on this node — other projects' included. Use targeted disable (tailscale serve --https=443 <port> off) instead.kill -9 foreign processes on a port. Port hygiene refuses, suggests +10.wrangler.toml commonly exists alongside Vercel-deployed frontends to drive R2 or Workers, with the frontend itself still on Vercel.make deploy ambiguous. The user's stated intent decides; signals only inform the question to ask.make r2-sync to rclone sync. R2 buckets are often multi-tenant; sync would delete other projects' data. Default to rclone copy (additive). See references/makefile-r2-bulk.md.cfat_* / cfut_* token. They are independent values — the dashboard issues both at token creation. rclone / aws-cli need the AKID + Secret pair, not the cfat_/cfut_ value. See references/makefile-r2-bulk.md..secrets/, .env, id_rsa, credentials.json) after first sync; surface anything 200 to the user.supabase/. Skip Scenarios A / B / C / E / F / G.gh secret set payloads. Never echo tokens back to the user.output: 'standalone' in next.config.js for Vercel-hosted Next.js. Standalone is for self-host (Railway/Docker) only.host / nslookup / bare dig to verify MagicDNS names on macOS — they bypass the system resolver. Use tailscale dns query <fqdn> or dscacheutil -q host -a name <fqdn>.RAILWAY_API_TOKEN (account scope) when a project token would do. CI uses project tokens..env.local into Vercel production. Dev secrets leak that way.Before declaring done:
make help lists every generated target with one-line descriptionsmake X runs cleanly)AGENTS.md ## Make targets section accurately reflects the generated MakefileCLAUDE.md is a symlink → AGENTS.md (or absent)git log before the regen commit.github/workflows/deploy.yml exists; gh secret list shows the wired secrets; push was separately authorizedPUBLIC_FUNNEL=1references/makefile-base.mdreferences/*.md use correct relative paths