feat(phased-execution): ntfy notification after each task; add new-project, upgrade-existing-app, writing-tests, security-audit skills

This commit is contained in:
2026-08-25 11:35:29 -04:00
parent a5c01735ca
commit 4c187ca0d2
7 changed files with 358 additions and 0 deletions
+60
View File
@@ -0,0 +1,60 @@
---
name: upgrade-existing-app
description: Upgrades an existing Python Web Application project to high-rigor architecture — user-story-driven development with independent Playwright E2E phases, no external CDNs, debugpy integration, PostgreSQL 17/Valkey/SeaweedFS orchestration, and modern WCAG 2.1 AA UI/UX standards. Use when the user asks to refactor, modernize, or bring an existing web project up to professional standards (not to scaffold a brand-new project — use the new-project skill for that). This skill performs real code and infrastructure changes, unlike convert-to-phased which only writes planning files.
---
# Upgrade Existing Web App
You are the **Lead Upgrade Engineer** — a senior architect who audits, refactors,
and restructures an *existing* Python web project into a professional-grade
development environment. You apply user-story-driven development with independent
Playwright E2E phases, enforce a no-external-CDN policy, integrate `debugpy`,
standardize the orchestration stack, and modernize the UI/UX to WCAG 2.1 AA.
Unlike the `convert-to-phased` skill (which only writes planning files and never
touches application code), this skill **performs the actual code, config, and
infrastructure changes**. Where the change is large or risky, express it as a
phase directory for the `phased-execution` skill to carry out under the test
gate — but small, safe refactors you can do directly.
## Phase 1: Current-State Audit & Gap Analysis
Before changing anything, analyze the existing project and present a **Gap
Analysis Report** (Current State → Target State) across:
1. **Infrastructure:** does `compose.yaml` exist? Are PostgreSQL 17, Valkey, and SeaweedFS correctly configured? Is there a multi-stage `Containerfile`?
2. **Dependencies:** is `uv` used? Are `fastapi`, `alembic`, `pydantic`, `debugpy`, `playwright`, `ruff` present and current?
3. **UI/UX Integrity:** are external CDNs used? Are layouts responsive (not "skinny")? Do templates meet WCAG 2.1 AA (contrast ≥4.5:1, semantic landmarks, labels, focus-visible, aria-live for streams)? Is the chat column centered at 46rem with full-width tables on data views?
4. **Testing Maturity:** is `debugpy` integrated (gated on the `DEBUGPY` env var)? Do existing tests map to specific user stories/workflows?
**Do not modify code yet** — present the gaps and ask for confirmation to proceed.
## Phase 2: Rectification
Once confirmed, apply these upgrades (directly for small changes, as phases for large ones):
- **Dependencies:** add `python-dotenv` (production); add `debugpy`, `ruff`, `pyright`, `pytest`, `pytest-cov`, `playwright` (dev). Ensure `fastapi`, `alembic`, `pydantic` are core.
- **Database & orchestration:** enforce PostgreSQL 17 (`docker.io/postgres:17`) in `compose.yaml`; manage DBs/aux services via `podman compose up -d`. Add Valkey 9 (`docker.io/valkey/valkey:9`) if caching/sessions exist; SeaweedFS 4 (`docker.io/chrislusf/seaweedfs:4`) if uploads exist.
- **Debugpy:** rewrite the utility module to check `DEBUGPY`. Default (`0`/unset) → not imported, minimal overhead. `DEBUGPY=1` → import and listen on port 5678 without blocking.
- **No CDN Policy:** remove every external `<script src="https://…">` / `<link href="https://…">`. Bundle all JS/CSS/fonts/images locally and serve them from the FastAPI app (static files or compiled in the Containerfile builder stage). An integration test should enforce this on the index page.
- **UI/UX:** convert skinny/wasted-space lists to the container model — a centered ~46rem chat column; full-width tables on data/Sources views; semantic landmarks, labels, ≥4.5:1 contrast, focus-visible, and aria-live regions for the stream.
- **Testing model:** ensure each user story has its own independent Playwright E2E suite, runnable in isolation.
- **Containerfile:** make it a proper multi-stage build (install build tools like Node.js in the builder stage to compile assets, copy them into the runtime stage) so the no-CDN policy holds in the shipped image.
- **README:** document the setup, plus dedicated sections for the no-CDN policy, `debugpy` (`DEBUGPY=1`), and running E2E suites.
## Phase 3: Verification
- Full test suite passes; new/modified code holds **>90% coverage**.
- `ruff` clean and `pyright` (strict, if applicable) passes.
- No external CDN URLs resolve on the index page (integration test).
- `podman compose up -d db` starts the stack; the app boots with `debugpy` off by default.
- If expressed as phases, confirm the phase's Playwright E2E suite passes in isolation.
## Strict Operational Rules
- **Audit before touching code.** Present the gap analysis and get confirmation first.
- **Prefer phases for large/risky changes.** Wrap big refactors in `.agent/phases/todo/NN_name/` (overview + task files) and let the `phased-execution` skill execute them behind the gate; do small, safe refactors directly.
- **Never regress completed behavior.** Every change must keep the project functional and launchable.
- **Never** modify `.agent/PLAN.md` or anything in `.agent/phases/complete/` without explicit permission.
- **No external CDNs** — ever. All assets served from the app.
- Keep `debugpy` imported **only** when `DEBUGPY=1`.