When to use
- •You changed
src/agent_loom/server/templates/*.htmland the change affects what the server returns. - •You changed the route/handler that serves HTML (wrapping/layout/headers/markers).
- •You refactored
src/agent_loom/server/templates/dashboard.htmlsubstantially.
Goal
Lock server-rendered HTML behavior with a request-level contract.
Checklist
- •
Identify the public surface
- •Which route returns the HTML?
- •Which markers/sections must remain stable for users and agents?
- •
Define stable invariants (avoid brittleness)
- •Assert on headings/section labels and
data-*hooks. - •Assert on deterministic ordering for repeated items.
- •Avoid asserting raw whitespace or full HTML unless explicitly intended.
- •Assert on headings/section labels and
- •
Keep diffs reviewable (diff hygiene)
- •Avoid formatting-only churn that obscures behavioral changes.
- •Preserve stable anchors even if structure changes.
- •If you must rename/remove an anchor, update the test invariants in the same change.
- •
Handle large template refactors safely
- •Prefer adding stable
data-*anchors over relying on CSS classes or deep DOM structure. - •Avoid loops that render in nondeterministic order; sort explicitly.
- •Prefer adding stable
- •
Update/add the contract test
- •Prefer
tests/test_server_api_contract.py. - •Exercise the real route/handler.
- •Assert required markers/sections and ordering.
- •Prefer
- •
Verification gate
- •
uv run basedpyright - •
uv run ruff check . - •
uv run pytest tests/test_server_api_contract.py
- •
Common failure modes
- •Template loops render in nondeterministic order.
- •Tests snapshot full HTML and become brittle due to formatting-only changes.
- •HTML includes machine-specific paths or other environment-specific values.
- •Refactors remove/rename anchors without updating the contract test.
Manual notes
This section is preserved when the skill is updated. Put human notes, caveats, and exceptions here.