跳到正文
cccskills
免费在 GitHub 公开

dev-environment

Start, stop, and manage the local dev stack (Docker infra, backend, frontend). Works in any directory — worktree or main repo.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core星标 34(GitHub 34 + cccskills 0)
集成工具DockerPostgreSQL

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md7.6 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Dev Environment

Starting the Stack

The ./dev script manages the local development stack. It works from any checkout — worktree or main repo.

By default, ./dev up omits the slow anonymisation service. Use this for routine backend, frontend, migration, and QA work:

# Requires a slot number on first run
./dev up --slot 2

# Subsequent runs remember the slot
./dev up

Before starting the stack, decide whether the task actually exercises anonymisation. Only include the service when the task tests or changes anonymisation behavior:

./dev up --slot 2 --with-anonymisation

What ./dev up does

  1. Starts Docker infrastructure (postgres, minio, mailcatcher, code-execution, redis, gotenberg, plus anonymize only when --with-anonymisation is set)
  2. Generates .env.dev with localhost connection config for the slot
  3. Runs database migrations
  4. Starts the backend natively (nest start --watch)
  5. Starts the frontend natively (vite)
  6. Waits for the backend health check, prints port summary, returns

Local Backend Environment Overrides

Put personal or task-specific backend settings in ayunis-core-backend/.env.local. This is the generic local override mechanism for feature flags, temporary API keys, service endpoints, and any other backend environment variable:

FEATURE_<NAME>_ENABLED=true

The file is gitignored, is not rewritten by ./dev, and has the highest precedence: .env.local overrides Infisical or other injected process values, the generated .env.dev, and .env.

Do not prefix ./dev up with an environment variable; the detached backend does not reliably inherit the invoking shell's environment. Do not edit .env.dev, because ./dev up regenerates it, and do not change a source-code default for a local configuration need.

The backend reads environment configuration at process startup. Restart after adding, changing, or removing an override:

./dev down
./dev up

Remove task-specific entries from .env.local when they are no longer needed.

Port Reference

Ports are offset by slot × 10:

ServiceFormulaSlot 2Slot 3Slot 4
Backend3000 + offset302030303040
Frontend3001 + offset302130313041
Postgres5432 + offset545254625472
MinIO9000 + offset902090309040

Avoid slots 0 and 1 — their ports (5432, 3000, etc.) often conflict with existing services on the host.

Checking Status and Logs

./dev status                      # Overview of all services
./dev logs backend                # Backend logs (last 80 lines)
./dev logs frontend               # Frontend logs
./dev logs infra                  # Docker infrastructure logs
./dev logs --tail 200 backend     # More lines

Restarting

The backend runs nest start --watch — it auto-reloads on code changes. If it crashes:

./dev logs backend    # Check what went wrong
./dev down
./dev up              # Slot is remembered; add --with-anonymisation only if needed

Stopping

./dev down

Troubleshooting

If ./dev up fails, check logs:

./dev logs backend
./dev logs infra

Migration fails with 42P07 duplicate-table — stale Postgres volume

Slots reuse their Postgres data volume across branches. If a previous branch on this slot already ran a migration that creates the same table as the current branch's pending migration, ./dev up fails with:

error: relation "<table>" already exists (PostgreSQL 42P07)

The volume is stale — it has the table but no record of the migration that created it. Resolving it means wiping the slot's Postgres volume so ./dev up replays migrations from scratch.

Do not run this yourself. Wiping a volume requires a destructive Docker flag (docker compose down -v), which is on the Forbidden Actions list in CLAUDE.md — volumes hold database data that cannot be restored. Instead, surface the situation to the user and let them decide. Tell them the slot's Postgres volume is stale and that recovering it requires:

# Run by the user — destroys the slot's Postgres data
docker compose -p ayunis-dev-<SLOT> down -v
./dev up --slot <SLOT>

Slots are per-developer scratch state (not shared), so this is normally safe — but it is the user's call, not the agent's.

Cross-worktree slot squat — frontend OR backend

When two worktrees both think they own the same slot (e.g. both ran ./dev up --slot 2 at different times), one of the slot's ports can end up held by a process from worktree A while you ./dev up in worktree B. Two flavors:

Frontend squat — vite/node from worktree A holds 3021/3031/... ./dev up sees the port bound, silently skips frontend startup, and the backend comes up fresh against your branch's code while the frontend serves worktree A's old code. ./dev status looks healthy.

Backend squat — nest/node from worktree A holds 3020/3030/3040/... The ./dev up in worktree B either skips backend startup or fails a health check. More insidiously, any tool that hits the backend port from worktree B (e.g. pnpm run openapi:update, which fetches http://localhost:<port>/api/docs-json) will silently pull from worktree A's server — regenerating a stale OpenAPI client that's missing endpoints you just added in worktree B.

Diagnose (same recipe, use the port relevant to the symptom):

# Frontend port: 3021 = slot 2, 3031 = slot 3, 3041 = slot 4
# Backend port:  3020 = slot 2, 3030 = slot 3, 3040 = slot 4
lsof -nP -iTCP:3040 -sTCP:LISTEN

# Inspect that process's cwd — if it points to a different worktree, that's the squatter
lsof -p <PID> | grep cwd

Before regenerating any code from a running dev server (OpenAPI schema, GraphQL codegen, etc.), verify the process serving the port is rooted in the current worktree — not another slot's stale backend.

Fix: the squatter must be stopped before ./dev up --slot <SLOT> succeeds and before any codegen-from-running-server is trustworthy. Do not kill it yourself — killing processes is on the Forbidden Actions list in CLAUDE.md. Report the offending PID and its worktree cwd to the user and let them stop it. If you want to keep both worktrees running, give them different slots instead.

Orphaned processes from a trashed worktree

When a git worktree is removed via git worktree remove — or moved to .git/wt/trash/… — while its ./dev stack is still running, the native nest/vite/esbuild children survive the worktree deletion and keep holding the slot's ports. Next ./dev up --slot <SLOT> from any worktree fails because those ports are still bound.

The distinguishing signal from a live cross-worktree squat is the cwd: an orphaned process's lsof -p <PID> | grep cwd resolves to a path under .git/wt/trash/… (or is deleted entirely and shows up as cwd (deleted)), not a real live worktree.

Prevent: always ./dev down in a worktree before trashing/removing it. The worktree skill's cleanup section names this too — respect it.

Recover: because the parent worktree is already gone, there's no ambiguity about whether the process is still owned — it isn't. Report the orphan PIDs plus the trashed cwd to the user and ask permission to kill <PID> them. Once approved, ./dev up --slot <SLOT> from your current worktree comes up clean. docker compose down alone does not clean these up — they're native processes, not containers.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Query Ayunis deployed-environment telemetry in AppSignal — incidents, occurrence counts and error traces via the `appsignal-cli` binary; structured log attributes (user.id, org.id, nestjs.context, custom metadata) via the v2 logs API. Use when investigating a production/staging incident or log data — NOT for local dev logs (see backend-debugging).

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Ayunis Core backend specifics — module boundaries, key files, and project conventions. Complements the nestjs-hexagonal-backend skill.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Frontend development in ayunis-core. Use when creating, modifying, or debugging frontend code (React, Feature-Sliced Design, API client).

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Debug backend runtime errors (500s, crashes, unexpected behavior). Use when something is broken at runtime — not for writing new code.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Shared test fixtures for backend specs — port mock factories, domain builders, and shared IDs in a per-module testing/ folder. Use when a module's *.use-case.spec.ts files repeat the same mock-repository literal, inline entity construction, or hardcoded UUIDs across files.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

Analyze Cursor Bugbot PR comments through a root-cause lens: is the finding valid, and is the suggested fix the real fix or a bandaid over a deeper problem? Use when the user asks to check, assess, or triage bugbot comments.

中文简介正在准备中。当前显示原文说明。

ayunis-core/ayunis-core342026年10月26日 更新

查看 ayunis-core 的全部技能

报告此技能的问题