Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

dev-stack-debug

БесплатноБез исполняемых скриптовНе проверен

Debug full-stack issues in a running dev stack (docker + API + worker + frontend) by reading logs directly, writing API tests, and targeting user stories…

pdl-openairот pdl-openair★ 16 звёзд на GitHub

Об этом скилле

Dev Stack Debug

When the user reports a bug in a running local dev stack, follow this workflow. The key principle: you can read logs and run API tests yourself — never ask the user to paste logs or error messages. They are your background processes.

1. Stack lifecycle

Starting the stack

# Terminal 1: infrastructure
docker compose up -d postgres minio

# Terminal 2: API (background)
cd services/api
.venv/Scripts/python.exe -m uvicorn app.main:app --host 127.0.0.1 --port 8000

# Terminal 3: Worker (background) — needed for research-start + execution
cd services/api
.venv/Scripts/python.exe -m worker.entrypoint

# Terminal 4: Frontend (background)
pnpm.cmd --filter @openair/web dev

All four components must run. Missing the worker → task creation hangs in "waiting". Missing the API → frontend has nothing to talk to.

Where logs live

Logs are written to $CLAUDE_JOB_DIR/tmp/{api,worker,web}.log. Read them directly with tail / grep — do not ask the user to copy-paste.

Health check sequence

curl -s http://127.0.0.1:8000/health          # API
grep "worker_first_poll_ready" worker.log      # Worker
curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:5173  # Frontend

Restarting after code changes

After fixing backend code: restart both API and worker (the worker imports the same modules). Frontend changes are picked up by Vite HMR automatically.

After migration changes: the API auto-applies migrations at bootstrap (migrations_auto_apply=true). For immediate testing, apply manually:

docker compose exec -T postgres psql -U openair -d openair -f - < services/api/migrations/<migration>.sql

2. Debug methodology

Step 1: Read the logs first

When a user reports "it failed" or "it's wrong", the logs tell you what happened before anything else. The sequence:

  1. API log: grep -E "<task_id>|→ [45][0-9][0-9]|Traceback|Exception|ERROR" api.log
  2. Worker log: grep -E "<task_id>|dispatch|failed|error|rejected|claimed" worker.log
  3. Frontend log: rarely needed (Vite HMR errors only)

Key log patterns:

  • → 200 with wrong data → projection/serialization bug (data correct in DB but API response wrong)
  • → 404 → scope mismatch or missing field in artifact/runtime data
  • → 409 → revision conflict or state precondition not met
  • → 428 → missing required request fields
  • → 500 → unhandled exception; read the traceback
  • → 503 → postgres middleware allowlist (new write route not registered in main.py)
  • quota_exhausted → user's daily token quota is spent (not a code bug)
  • artifact_schema_invalid → model under-produced a complex contract
  • worker_first_poll_ready absent → worker crashed at startup (read traceback)

Step 2: Inspect the DB

When logs show the API returning wrong data, compare the DB row vs the API response to find where the transformation breaks:

# Task state
docker compose exec -T postgres psql -U openair -d openair -c \
  "SELECT task_id, status, revision, payload->>'creationStatus',
   jsonb_array_length(payload->'substageRuntimeStates') AS srs,
   payload->'progressProjection' IS NOT NULL AS has_pp
   FROM openair_tasks WHERE task_id='<id>';"

# Artifact storage
docker compose exec -T postgres psql -U openair -d openair -c \
  "SELECT artifact_id, storage_type, source_task_id, content_sha256
   FROM openair_artifacts WHERE source_task_id='<id>';"

Step 3: Write an API test

Write a small Python script (using stdlib urllib) that hits the real API and asserts on the response. This is more reliable than asking the user to click through the UI and describe what they see.

import json, urllib.request

BASE = "http://127.0.0.1:8000"
H = {"X-OpenAIR-Owner-Id": "<owner>", "X-OpenAIR-Workspace-Id": "<ws>",
     "X-OpenAIR-Created-By": "<owner>", "Content-Type": "application/json"}

def get(path):
    r = urllib.request.Request(BASE + path, headers=H)
    with urllib.request.urlopen(r, timeout=20) as resp:
        return resp.status, json.loads(resp.read().decode())

# Test the failing endpoint
status, body = get("/api/tasks/<task_id>")
print(status, body.get("creationStatus"), body.get("progressProjection") is not None)

Save scripts to $CLAUDE_JOB_DIR/tmp/. Use ASCII-only request bodies (shell mangles UTF-8 in curl -d).

Step 4: Fix → restart → re-test

After fixing code:

  1. Restart the affected process (API, worker, or both)
  2. Re-run your API test script
  3. If it passes, tell the user to verify in the UI

Never hand off a fix to the user for UI testing without first verifying it via API yourself.

3. Known bug magnets

These are recurring failure patterns in this codebase. When debugging, check them first — they account for the majority of user-visible bugs.

progressProjection is null

Symptom: Workbench renders wrong stage count (shows all 4 stages instead of the design's actual instances), or start button is stuck.

**Root

Полный SKILL.md на GitHub

Установить dev-stack-debug в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл dev-stack-debug?

Debug full-stack issues in a running dev stack (docker + API + worker + frontend) by reading logs directly, writing API tests, and targeting user stories until they pass. Use this skill whenever the user reports a bug in a running local dev environment — frontend rendering wrong, button stuck, execution failed, clone broken, "暂不可用", blank workbench, 4xx/5xx errors. Covers: starting/monitoring the dev stack, reading API/worker logs, writing HTTP API verification scripts, identifying known bug magnets (progressProjection, clone fork fields, quota exhaustion), and iterating on fixes until user stories pass.

Как установить скилл dev-stack-debug?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл dev-stack-debug запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить dev-stack-debug с