AgentSkillsCN

fix

当用户希望通过实时诊断与日志分析快速修复 Bug,重现故障(如 API 或 UI 竞争条件),应用最小化修复方案,并端到端验证修复效果时,此技能便应被启用。可通过“修复这个”、“读取日志并修复”、“自主修复 Bug”、“竞争条件”、“500 错误”、“按钮无法点击”、“通知未标记为已读”等短语触发。

SKILL.md
--- frontmatter
name: fix
description: Use when the user asks to fix bugs quickly by reading live diagnostics/logs, reproducing failures (API or UI race conditions), applying minimal fixes, and verifying the repair loop end-to-end. Triggers: "fix this", "read logs and fix", "autonomous bug fixing", "race condition", "500 errors", "buttons not clickable", "notifications not marking read".

Fix Skill

Goal

Close the bug loop fast: capture evidence -> reproduce -> fix root cause -> verify -> watch for recurrence.

Modes

  • log-first: Start from live error data and incident reports.
  • repro-first: Start from automated reproduction when logs are weak or missing.

Choose log-first when 500s/exceptions are present. Choose repro-first for race conditions, stale UI state, click dead zones, and timing bugs.

Repo-Specific Inputs (TheRxSpot)

  • Live diagnostics endpoint: auth/api/live-errors.php
  • Client error ingest: auth/api/log-client-error.php
  • Structured diagnostics log: auth/logs/live-errors-YYYY-MM-DD.jsonl
  • Auth bootstrap correlation: auth/auth-helper.php (X-Request-Id)
  • Additional reference: references/therxspot-fix-loop.md

Safety Rules

  • Keep diagnostics gated:
    • RXSPOT_LIVE_ERROR_API=1 only during active triage windows.
    • Prefer header token auth (Authorization: Bearer ...), never query-string tokens.
  • Never modify runtime data files directly (auth/data/app.db, .db_initialized, sessions).
  • Never expose internals in client responses; keep details in logs only.

Workflow

  1. Confirm symptom and pick mode (log-first or repro-first).
  2. Acquire evidence.
  • log-first:
    • Query recent events from auth/api/live-errors.php with filters (limit, lookback_minutes, search, sources).
    • Group by signature: endpoint + message + stack fragment.
  • repro-first:
    • Run deterministic probes (API replay or Playwright interaction loops).
    • Capture request IDs, console errors, network failures, and timing windows.
  1. Build minimal repro.
  • For API failures: replay exact method/path/headers/body.
  • For UI race failures: script rapid navigation + repeated click/open/close interactions with small randomized delays.
  1. Fix root cause minimally.
  • Prefer lifecycle-safe init patterns for SPA/bfcache/turbo navigation.
  • Make handlers idempotent; prevent duplicate listeners; guard stale async responses.
  • Add contextual error logging with request/user/route context.
  1. Verify.
  • Required gates:
    • npm run lint
    • npm run test:php
  • If UI/race issue: rerun targeted Playwright scenario multiple iterations (>=20).
  • Re-query live diagnostics and confirm the failing signature drops or disappears.
  1. Report.
  • Include changed files, root cause, verification evidence, and residual risk.

TheRxSpot Command Patterns

  • Pull live errors:
bash
curl -H "Authorization: Bearer $RXSPOT_LIVE_ERROR_API_TOKEN" \
  "https://therxspot.com/auth/api/live-errors.php?limit=200&lookback_minutes=180&sources=live,php,client"
  • Submit manual incident:
bash
curl -X POST \
  -H "Authorization: Bearer $RXSPOT_LIVE_ERROR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message":"notifications not marking read","severity":"error","type":"manual_report","steps":["open bell","click item"],"actual":"stays unread"}' \
  "https://therxspot.com/auth/api/live-errors.php"
  • Verification:
bash
npm run lint
npm run test:php

Race-Condition Playbook

Use this when symptoms are "works after refresh" or "buttons dead until reload":

  • Re-initialize page logic on multiple lifecycles (DOMContentLoaded, SPA navigation events, pageshow).
  • Ensure init is idempotent and abort/replace old listeners.
  • Add short-lived diagnostics around event binding and async state transitions.
  • Run repeated navigation/interactions with jitter and collect failures by step index.

Autonomous Long-Run Loop

For unattended stabilization sessions:

  1. Poll live diagnostics every N minutes.
  2. Rank top recurring signatures by frequency + recency.
  3. Attempt one fix at a time (highest-impact first).
  4. Run verification gates and targeted repro iterations.
  5. Re-poll for regression.
  6. Stop when no critical signatures remain for a defined window.

Keep one fix per loop iteration to avoid confounding variables.

Completion Standard

Do not claim fixed unless:

  • Repro exists (or historical signature is clearly captured),
  • Root cause is identified,
  • Verification passes,
  • Post-fix diagnostics show improvement.