How to Regenerate the Agent Reference from style-library.json
Run node scripts/generate-style-skill.mjs from the repository root to rebuild the markdown reference from data/style-library.json.
The awesome-gpt-image-2 repository maintains its GPT-Image2 style library definitions in a structured JSON file that requires periodic regeneration into a human-readable agent reference. When you modify templates, categories, styles, or scenes in the source data, you must regenerate the agent reference to keep the skill documentation synchronized with the underlying data structure.
The Generation Pipeline
The regeneration process centers on three critical file paths within the freestylefly/awesome-gpt-image-2 codebase:
data/style-library.json— The master JSON definition containing all templates, categories, styles, and scene configurationsscripts/generate-style-skill.mjs— The Node.js script that orchestrates the transformationagents/skills/gpt-image-2-style-library/references/style-library.md— The generated markdown output consumed by the skill
When executed, the script reads the JSON definition, performs structural validation, and renders a formatted markdown document that the GPT-Image2 skill uses to present available styles to users.
Prerequisites and Setup
Before regenerating the reference, ensure you are working from the repository root directory. The script relies on relative paths to locate both the source JSON and the template anchor definitions in docs/templates.md.
Verify that style-library.json exists in the data/ directory and contains your intended modifications. The script does not modify the source JSON; it only reads from it to produce the output.
Executing the Regeneration
Navigate to the repository root and invoke the generator using Node.js:
cd /path/to/awesome-gpt-image-2
node scripts/generate-style-skill.mjs
Upon successful execution, the terminal outputs a confirmation line:
Generated GPT-Image2 style skill reference at /path/to/awesome-gpt-image-2/agents/skills/gpt-image-2-style-library/references/style-library.md
This single command performs four distinct operations atomically: loading the JSON data, validating structural integrity, rendering the markdown content, and writing the file to the skill's references directory.
Validation Logic and Error Handling
The generate-style-skill.mjs script implements strict validation that will abort generation if the data is inconsistent, preventing broken references from reaching the skill.
Unique ID Constraints
The script verifies that all identifiers within style-library.json are unique. If duplicate IDs exist, the process throws an exception and terminates before writing any output, requiring you to resolve the collision in the source data.
Template Anchor Verification
Each template defined in the JSON must reference an existing anchor in docs/templates.md. The script validates that <a name="..."></a> tags exist for every template anchor specified in the library. Missing anchors trigger an immediate abort, prompting you to add the corresponding documentation anchor before regeneration can succeed.
Asset Existence Checks
The generator confirms that referenced image files (such as template covers) exist in their expected locations. If style-library.json points to missing image assets, the script raises an exception rather than generating a reference with broken image links.
Modifying the Source Data
To update the agent reference with new content, edit data/style-library.json directly. Add new templates, categories, or style definitions following the existing JSON schema. Once saved, rerun the generator script to propagate these changes into the markdown reference.
The script processes the updated JSON at build-time, ensuring the generated style-library.md always reflects the current state of the library definition.
Summary
- Execute
node scripts/generate-style-skill.mjsfrom the repository root to regenerate the reference - Source file
data/style-library.jsoncontains the master definitions that drive the generation - Validation includes unique ID checks, template anchor verification against
docs/templates.md, and image file existence confirmation - Output lands in
agents/skills/gpt-image-2-style-library/references/style-library.mdand is automatically consumed by the GPT-Image2 skill - Errors halt execution immediately, preventing the propagation of invalid data to the agent reference
Frequently Asked Questions
What happens if I forget to run the generator after editing style-library.json?
The agent reference becomes stale, displaying outdated templates, categories, or styles to users. The skill reads from the generated markdown file, not the raw JSON, so changes remain invisible until you execute the regeneration script.
Can I run the generator from a subdirectory?
No. The script uses relative path resolution to locate data/style-library.json and docs/templates.md. Running it from outside the repository root or from a subdirectory causes file-not-found errors. Always execute from the repository root.
Why does the script fail with "missing template anchor" errors?
Your style-library.json references a template anchor that does not exist in docs/templates.md. Add the corresponding <a name="your-anchor"></a> tag to the templates documentation file, or correct the anchor name in the JSON to match an existing documentation anchor.
Does the generator modify the original style-library.json file?
No. The script operates in read-only mode regarding the source JSON. It only reads from data/style-library.json and writes to agents/skills/gpt-image-2-style-library/references/style-library.md, leaving your source data intact regardless of validation failures or successful generation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →