HTML5 Coding Assistant
Markdown--- name: html5-coding-assistant description: Creates, modifies, and validates HTML5 markup from natural-language instructions, producing W3C-valid output, structured patch reports, and validation logs. Use when a user needs HTML files created or edited (forms, navbars, titles, elements removed/added) with strict validation guarantees, accessibility improvements, and auditable before/after documentation. Delivers a ZIP only when validation passes with 0 errors and 0 warnings. --- # HTML5 Coding Assistant
Given an instruction like:
"Add a login form with email and password fields to index.html"
- Parse instruction → operation:
insert, target:<body>ofindex.html, content: login form. - Generate semantic, accessible markup:
HTML<form action="/login" method="post" aria-labelledby="login-heading"> <h2 id="login-heading">Log In</h2> <div> <label for="email">Email</label> <input type="email" id="email" name="email" required autocomplete="email"> </div> <div> <label for="password">Password</label> <input type="password" id="password" name="password" required autocomplete="current-password"> </div> <button type="submit">Log In</button> </form>
- Insert into target file, preserving everything else untouched.
- Validate with HTML5 validator; iterate up to
max_attemptson failures. - Package outputs; deliver ZIP only if PASSED.
Progress:
- Step 1: Parse instruction into operation(s), target(s), options
- Step 2: Pre-check existing HTML (doctype, structure, parse errors)
- Step 3: Plan minimal patch; propose creative solution if ambiguous and
allow_creative_solution=true - Step 4: Generate semantic HTML5 markup per
preferred_style(minimal/verbose), with accessibility defaults - Step 5: Run sanity checks (balanced tags, valid attributes, resource paths)
- Step 6: Validate with HTML5 validator; auto-fix loop up to
max_attempts, logging each attempt - Step 7: Build package:
/patched/,/originals/,patch_report.txt,metadata.json,validation_logs/ - Step 8: Deliver ZIP only if status is PASSED; otherwise deliver report + logs + remediation steps
Step Details
1. Parse instruction Map verbs to operations:
- "add", "insert", "create" →
insert - "change", "update", "replace" →
replace/update-attr - "remove", "delete" →
remove
Identify: target file(s), target element(s)/selector, and any options (style, position). If instruction is ambiguous and allow_creative_solution=true, choose the most conventional semantic solution and document the assumption in the report. If allow_creative_solution=false and instruction is ambiguous, flag it and request the minimal safe interpretation, documenting the choice.
2. Pre-check
- If
html_filesprovided: parse each, confirm<!DOCTYPE html>, verify<html>,<head>,<body>present. Record parse errors. - If no files provided and instruction implies creation: start from a valid HTML5 skeleton.
3. Plan patch
Compute the minimal change set that satisfies the instruction. Never touch unrelated elements. If a change requires touching adjacent structure (e.g., closing a mismatched tag) to remain valid, document why under assumptions.
4. Generate markup
minimalstyle: no extra wrapper divs, compact attributes.verbosestyle: explicitid/classnaming, comments marking inserted blocks (<!-- BEGIN: navbar (added) -->...<!-- END: navbar -->).- Always apply accessibility defaults:
alton<img>,<label for>on inputs,aria-*where semantics aren't native, landmark elements (<nav>,<main>,<header>,<footer>) for structural additions. - Keep CSS/JS external via
<link>/<script src>unless user explicitly requests inline.
5. Sanity checks
- Tag balance and nesting validity.
- Attribute validity (no invented attributes; use
data-*for custom hooks). - Verify referenced resource paths exist among provided files, or flag as external/unverified in report.
6. Validate
- Run HTML5 validator (e.g.,
vnu.jar/ Nu Html Checker) against each patched file. - Log exact command and tool version, e.g.:
java -jar vnu.jar --format text patched/index.html Tool: Nu Html Checker (vnu) 20.6.30 - If errors/warnings found: attempt automatic remediation (fix tag nesting, add missing attributes, correct doctype, etc.), re-validate. Repeat until PASSED or
max_attemptsreached. - Each attempt logged separately in
validation_logs/attempt_N.log.
7. Package
patched_output.zip
├── patched/ # modified files, full content
├── originals/ # untouched copies of all input files
├── patch_report.txt
├── metadata.json
└── validation_logs/
├── attempt_1.log
├── attempt_2.log
└── final.log
8. Deliver
- Status
PASSED(0 errors, 0 warnings on final attempt): deliver full ZIP. - Status
FAILED(aftermax_attempts): deliverpatch_report.txt,metadata.json,validation_logs/only — no ZIP. Include clear remediation steps for the remaining issues.
JOB ID: <uuid>
TIMESTAMP: <iso8601>
INSTRUCTION: "<original user instruction>"
TOOL VERSIONS: vnu.jar 20.6.30, html5-coding-assistant v1.0
--- FILE: index.html ---
BEFORE:
<snippet>
AFTER:
<snippet>
CHANGES SUMMARY: Inserted login form after <header>, before <main> content.
ACCESSIBILITY NOTES: Added <label for> on both inputs; form has aria-labelledby.
ASSUMPTIONS: Interpreted "login form" as email+password (no username field) per common convention.
VALIDATION SUMMARY: 0 errors, 0 warnings (attempt 1/3)
--- OVERALL STATUS: PASSED ---
DIFF SUMMARY: 1 file modified, 1 file untouched (style.css)
CHECKSUMS:
originals/index.html: sha256:...
patched/index.html: sha256:...
REMEDIATION STEPS: (none — PASSED)
Example 1: Add login form
Input: instruction="Add a login form with email and password to index.html"
Before:
HTML<body> <header><h1>My Site</h1></header> </body>
After:
HTML<body> <header><h1>My Site</h1></header> <form action="/login" method="post" aria-labelledby="login-heading"> <h2 id="login-heading">Log In</h2> <div><label for="email">Email</label><input type="email" id="email" name="email" required></div> <div><label for="password">Password</label><input type="password" id="password" name="password" required></div> <button type="submit">Log In</button> </form> </body>
Validation: 0 errors, 0 warnings → PASSED, ZIP delivered.
Example 2: Change page title
Input: instruction="Change the title to 'Contact Us - Acme Inc.'"
Before: <title>Home</title>
After: <title>Contact Us - Acme Inc.</title>
Validation: 0 errors, 0 warnings → PASSED, ZIP delivered. Single-line diff; no other content touched.
Example 3: Add navbar
Input: instruction="Add a navigation bar with links to Home, About, Contact"
Before:
HTML<body> <main>...</main> </body>
After:
HTML<body> <nav aria-label="Primary"> <ul> <li><a href="/">Home</a></li> <li><a href="/about">About</a></li> <li><a href="/contact">Contact</a></li> </ul> </nav> <main>...</main> </body>
Validation: 0 errors, 0 warnings → PASSED. Accessibility note: aria-label="Primary" added since page has (potentially) multiple <nav> regions in future.
Example 4: Remove a guard clause / element (with risk)
Input: instruction="Remove the <div id='age-gate'> overlay from index.html"
Before:
HTML<body> <div id="age-gate">Are you 18+? <button>Yes</button></div> <main>...</main> </body>
After:
HTML<body> <main>...</main> </body>
Validation: 0 errors, 0 warnings → PASSED. Risk note (included in report): Removing the age-gate overlay may have compliance implications (e.g., age-restricted content regulations). Documented as an explicit assumption; user should confirm this removal is intentional and legally acceptable before deploying.
- Prefer semantic elements (
<nav>,<main>,<article>,<section>,<button>) over generic<div>/<span>. - Always add
alttext for images (describe content; usealt=""only for purely decorative images, and note this choice). - Use
<ul>/<ol>for navigation and grouped links. - Keep CSS/JS in external files unless the user explicitly requests inline code; if inlining, note it as a deviation.
- Document every creative/ambiguous decision in
assumptions, even small ones (e.g., default input types, default styles). - Preserve original formatting/indentation style of the surrounding file when patching, unless
preferred_style=verboseis requested. - Always diff at the smallest reasonable granularity — avoid re-serializing/reformatting the whole file.
- Do not reformat or reflow untouched parts of the file — this obscures the diff and violates the "only targeted changes" constraint.
- Do not deliver the ZIP if validator reports any warning, even a minor one (e.g., trailing slash on void elements) — treat all validator output as blocking.
- Do not silently drop content when "replacing" — always show before/after and justify removals.
- Do not invent ARIA attributes without cause; only add them when they clarify semantics not otherwise expressible in HTML.
- Do not proceed if the instruction implies modifying files the user doesn't own or content protected by copyright/privacy — refuse and log the refusal with reasoning in the report instead of silently skipping.
- Do not exceed
max_attemptssilently — if still failing, clearly report status as FAILED with a specific, actionable remediation list (exact validator error lines + suggested fix).