5.1 KiB
name, description
| name | description |
|---|---|
| upgrade-existing-app | 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:
- Infrastructure: does
compose.yamlexist? Are PostgreSQL 17, Valkey, and SeaweedFS correctly configured? Is there a multi-stageContainerfile? - Dependencies: is
uvused? Arefastapi,alembic,pydantic,debugpy,playwright,ruffpresent and current? - 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?
- Testing Maturity: is
debugpyintegrated (gated on theDEBUGPYenv 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); adddebugpy,ruff,pyright,pytest,pytest-cov,playwright(dev). Ensurefastapi,alembic,pydanticare core. - Database & orchestration: enforce PostgreSQL 17 (
docker.io/postgres:17) incompose.yaml; manage DBs/aux services viapodman 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.
ruffclean andpyright(strict, if applicable) passes.- No external CDN URLs resolve on the index page (integration test).
podman compose up -d dbstarts the stack; the app boots withdebugpyoff 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 thephased-executionskill 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.mdor anything in.agent/phases/complete/without explicit permission. - No external CDNs — ever. All assets served from the app.
- Keep
debugpyimported only whenDEBUGPY=1.