Database Architecture Skill
Establishes structural rules for AI-generated databases, including JSON as the source of truth, HTML rendering, and one-way data flow.
Database Architecture
This skill defines the mandatory structure for any database the user asks you to create.
Core Architecture
- JSON is the source of truth. Store all data in a
.jsonfile. - HTML is the output. Generate a self-contained
.htmlfile that renders the JSON data for the user to view. - One-way data flow. When updating the database, NEVER edit the HTML output file directly. Always update the JSON first, then regenerate the HTML from the JSON. Editing the HTML directly causes data corruption because the HTML renderer may reorder or restructure content.
- Self-contained outputs. Output files (HTML or anything else) must be fully self-contained. Do NOT create dynamic files that pull data from the JSON via
fetch()or any other runtime import. The user may email or share the output file separately — if it depends on the JSON being present, it will be useless to the recipient.
Searching Databases
When you (the AI) need to search or check if a value exists inside a large .json database file, do NOT use grep_search or line-based text searching tools. Because JSON files are often minified or contain extremely long single lines, grep tools will silently fail or truncate the output, leading to false negatives (hallucinations).
Instead, you MUST use a native parser (like a quick python -c script with json.load()) to mechanically parse the file and search its contents.
Interactive User Input Columns
When the user needs to provide feedback or annotations directly in the HTML output (e.g., a "Your Comments" column in a triage table):
- Add
<textarea>elements with unique IDs tied to each row. - Use
localStorageto auto-save the user's input as they type (so they don't lose work if they close the tab). - Add a "Copy to Clipboard" export button that bundles all user input into a JSON object where:
- Each key is the exact text of the row's primary identifier (NOT a row number — row numbers change if the table is filtered or reordered).
- Each value is the user's typed comment.
- After the user pastes the clipboard contents back to you in chat, immediately merge those comments into the master JSON database, then regenerate the HTML with the comments rendered as static text (replacing the textareas for that round).
This pattern allows the user to provide structured feedback through the HTML interface while keeping the JSON as the permanent source of truth.