How Style Library Data Is Used to Generate Agent Skills in Awesome-GPT-Image-2

The style library data in data/style-library.json is parsed by automation scripts that generate JavaScript skill modules, allowing each visual style definition to be dynamically converted into an executable agent capability without manual coding.

The awesome-gpt-image-2 repository by freestylefly implements a data-driven architecture where style library data acts as the single source of truth for image generation capabilities. This design decouples style definitions from runtime logic, enabling developers to extend agent skills by simply modifying a JSON catalog rather than writing boilerplate handler code.

The Data Catalog: style-library.json

At the core of the system lies data/style-library.json, a structured catalog containing an array of style objects. Each entry defines a distinct visual aesthetic along with its generation parameters.

Key fields in each style object include:

  • name – The unique identifier used to invoke the style (e.g., "retro-pixel").
  • prompt – The prompt fragment injected to steer the image model toward the desired aesthetic.
  • cfg_scale – The classifier-free guidance scale controlling prompt adherence.
  • sampler – The diffusion sampling algorithm (e.g., "Euler").
  • tags – Metadata arrays for categorization and filtering.
{
  "name": "retro-pixel",
  "prompt": "retro pixel art, vibrant colors, low-resolution",
  "cfg_scale": 7,
  "sampler": "Euler",
  "tags": ["pixel", "retro"]
}

Automated Skill Generation Pipeline

The repository automates the conversion of static JSON entries into runtime-ready JavaScript modules through two dedicated scripts in the scripts/ directory.

The Generation Script

scripts/generate-style-skill.mjs reads data/style-library.json and iterates over every style entry. For each object in the array, the script programmatically constructs a skill module that exports a standardized interface.

The Installation Script

scripts/install-style-skill.mjs handles file system operations, emitting the generated modules into agents/skills/gpt-image-2-style-library/. This directory serves as the runtime registry where the agent discovers available capabilities.

Anatomy of a Generated Skill Module

Each file created under agents/skills/gpt-image-2-style-library/ follows a consistent pattern, exporting three named constants:

  • name – Matches the style identifier from the JSON catalog.
  • description – A human-readable summary of the style's visual characteristics.
  • handler – An async function responsible for request orchestration.

The handler function accepts userPrompt and options parameters, merges the base user input with the style-specific prompt fragment, and forwards the combined payload to the backend.

export const name = "retro-pixel";
export const description = "Generate images in retro pixel-art style";

export async function handler(userPrompt, options) {
  const stylePrompt = "retro pixel art, vibrant colors, low-resolution";
  const mergedPrompt = `${userPrompt}, ${stylePrompt}`;
  const payload = {
    prompt: mergedPrompt,
    cfg_scale: 7,
    sampler: "Euler",
    ...options,
  };
  return await fetch("/api/generate-image", {
    method: "POST",
    body: JSON.stringify(payload),
  });
}

Runtime Execution Flow

When the web application receives a request such as /image retro-pixel a cat riding a bike, the routing layer resolves the style identifier to its corresponding module in agents/skills/gpt-image-2-style-library/. The module's handler function then executes the following sequence:

  1. Retrieves the pre-defined style parameters from closure scope.
  2. Concatenates the user's descriptive prompt with the style's prompt fragment.
  3. Constructs a payload object containing cfg_scale, sampler, and the merged prompt.
  4. POSTs the payload to api/generate-image.js, which interfaces with the underlying image generation model.

This flow ensures that style-specific parameters (like cfg_scale: 7 or sampler: "Euler") are automatically applied without requiring the user to specify technical details.

Extending the Style Library

Adding new visual capabilities requires zero changes to the core codebase. Developers simply append a new entry to data/style-library.json and execute the generation scripts.

The automation pipeline then:

  • Parses the updated JSON catalog.
  • Generates a new skill module in agents/skills/gpt-image-2-style-library/.
  • Makes the style immediately available to agents through the standardized handler interface.

This data-driven approach eliminates manual boilerplate coding and reduces the risk of implementation errors when introducing new aesthetic options.

Summary

  • style-library.json serves as the centralized data source defining visual styles, parameters, and metadata.
  • generate-style-skill.mjs and install-style-skill.mjs automate the transformation of JSON entries into executable JavaScript modules.
  • Generated modules reside in agents/skills/gpt-image-2-style-library/ and export a standardized handler function.
  • The handler merges user prompts with style fragments and forwards requests to api/generate-image.js.
  • New styles are added by updating the JSON catalog and re-running the scripts, requiring no manual code changes.

Frequently Asked Questions

What file format stores the style library data?

The style library data is stored in data/style-library.json as a JSON array. Each element is an object containing fields like name, prompt, cfg_scale, sampler, and tags that define the visual characteristics and generation parameters for a specific style.

Where are the generated skill modules stored?

After running the installation script, the generated skill modules are stored in the agents/skills/gpt-image-2-style-library/ directory. Each style defined in the JSON catalog receives its own JavaScript file within this folder, making it discoverable by the agent's skill registry.

How does the handler function merge user prompts with style definitions?

The handler function defined in each generated module accepts a userPrompt string and concatenates it with the stylePrompt string defined in the original JSON entry. This merged prompt is then combined with style-specific parameters like cfg_scale and sampler before being sent to the generation API.

Can developers add custom styles without modifying the core codebase?

Yes. Developers can add new visual styles by simply appending entries to data/style-library.json and executing scripts/generate-style-skill.mjs and scripts/install-style-skill.mjs. The scripts automatically create the necessary skill modules, making the new style available to agents without requiring changes to the runtime logic or API handlers.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →