Home / All Skills / Design & Motion / image-prompt-generator
Design & Motion · huangserva/skill-prompt-generator

image-prompt-generator

Smart Prompt Generator v2.0 - Supports portrait, cross-domain, and design modes with semantic understanding, commonsense reasoning, and consistency verification.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandWrite FileDual-pass Audit
Author huangservaGitHub huangserva/skill-prompt-generator ↗Stars 1486License 仅 README 末尾声明 "MIT License",仓库内无 LICENSE 文件(受版本控制的 98 个文件中无 LICENSE/LICENSE.md),gh api license=null,授权声明停留在文档层面Commit e951249840
Control levels describe skill capabilities and suggested control measures; they do not represent quality or safety certifications, nor do they dictate usability. Usage decisions rest entirely with users and administrators. Different agent hosts apply varying constraints; do not assume hosts provide automatic protection. Third-party skill copyrights belong to their original authors. Use at your own risk.

1How It Works & Mechanism

Uses a standalone SQLite database, elements.db, as its sole asset source: A pool of 1,246 reusable prompt elements is used for generation; the generator performs retrieval and concatenation rather than unconstrained open-ended writing.

README.md
- **总元素数**: 1246
Verified elements.db (2,637,824 bytes, 12 business tables + sqlite_sequence): 1,246 element rows, 12 domain_ids, 70 category_ids, 2,324 tags, 5,127 element_tags, 675 source_prompts, 5 design_templates, 4 design_variables, 5 element_variables, 17 generated_prompts, 42 prompt_elements, and 27 element_usage_stats. Distribution of elements: portrait 502 / common 208 / design 166 / interior 79 / product 78 / art 70 / video 49 / creative 37 / scenario 34 / utility 10 / prompt_writing 9 / lifestyle 4 (total 1,246).

The portrait pipeline is framework-driven: prompt_framework.yaml defines portrait structures across 7 major categories (subject/facial/styling/expression/lighting/scene/technical) and maps each field to database categories; framework_loader.py handles loading, dependency inference, and intent validation before querying the database to select elements.

prompt_framework.yaml
# 人像提示词生成框架 - 7大类模板
framework_loader.py exposes FrameworkLoader.load/get_all_fields/get_required_fields/apply_dependencies/validate_intent, as well as FrameworkDrivenGenerator.generate_by_framework/query_all_candidates_by_framework. ElementSelector.select_best_element/select_from_candidates_dict at the end performs scoring and selection. prompt_framework.yaml is 389 lines long, with fields mapped to elements.category_id via db_category (e.g., eyes -> eye_types).

The skill itself is not a standalone runtime process, but an 'operating guide for the agent': SKILL.md directs the agent to execute Python code invoking the core/ engine, leveraging the LLM for semantic completion and candidate filtering.

.claude/skills/intelligent-prompt-generator/SKILL.md
os.chdir('/Users/serva/.claude/skills/skill-prompt-generator')
The 'Usage' section of SKILL.md provides copyable Python snippets (from core.cross_domain_generator import CrossDomainGenerator -> generator.generate(user_input)), requiring the agent to execute Python in its host environment. It hardcodes an author local path via os.chdir (/Users/serva/...), which must be modified on other machines for the engine to locate elements.db. SKILL.md spans 1,345 lines with no shell command requirements.

v2.0 features a unified entry point that routes inputs into three categories: portrait (pure character), cross_domain (character + action/VFX), and design (posters/cards), which CrossDomainGenerator.generate dispatches to three sub-generators.

core/cross_domain_generator.py
generation_type = self.classify_generation_type(intent)
parse_user_input uses Chinese and English keyword maps to identify gender, ethnicity, age, actions ('龟派气功'/'kamehameha' -> action=kamehameha), art styles ('3d'/'蜡像'/'wax' -> art_style=wax_figure_3d), design styles ('温馨可爱'/'现代简约'), and design formats ('海报'/'卡片'). classify_generation_type flags cross_domain if action/energy or 3d/wax is detected; otherwise, character inputs default to portrait.

Cross-domain composition: analyze_required_domains aggregates domains based on intent (character -> portrait, action/energy -> video, 3D/wax -> art, design terms -> design, and always includes common), then queries the database per domain category, increasing element utilization from 40.3% to 79.9%.

core/cross_domain_query.py
required_domains = self.analyze_required_domains(intent)
In the same file, domains.add('common') ensures general lighting and photographic technical elements are included in every run. query_plan lists 11 categories for portrait (gender/age_range/ethnicity/eye_types/face_shapes/skin_tones/makeup_styles/hair_styles/hair_colors/expressions/poses), scene_types/motion_effects/camera_movements for video, and art_styles/special_effects for art.

The design mode blends SQLite elements with YAML variables: design_bridge retrieves subject and technical elements from the database while sampling palettes, borders, and decorations from YAML files, which build_final_prompt compiles into a cohesive design specification.

core/design_bridge.py
yaml_variables = self.yaml_sampler.sample_variables(style=design_style)
Merged outputs are grouped into content, design, and technical buckets, mapping fields and joining with ', '. YAMLVariableSampler parses variables/{colors,borders,decorations}.yaml, selects palettes and values based on style ('温馨可爱' / '现代简约'), and invokes _get_recent_values to avoid recently used schemes (history cap of 100). Verified colors.yaml contains 2 styles, 10 palettes, and 37 values (23+14); borders features corner_radius (5 values) x box_shadow (3) x border (2) per style; decorations contains 5 cute and 4 minimalist variants.

Variable sampling avoids repetition: SQLiteVariableSampler tracks a history of the last 100 samplings, working with the element_variables table to parameterize elements and substitute templates upon matching variables.

core/variable_sampler.py
self.max_history = 100 # 保留最近100次采样历史
element_variables is created via core/schema_migration_v1.sql (parameter_type restricted to enum/range/boolean, possible_values stored as JSON). However, the table contains only 5 rows. When sample_element_with_variables fails or lacks variables during cross-domain queries, the except branch falls back to the raw element—variable parameterization currently covers only a tiny subset of elements.

Commonsense reasoning relies on a hardcoded knowledge base: Mappings like ethnicity -> typical eye/hair color, director style -> lighting keywords, and subject attribute category locks are defined in IntelligentGenerator.load_knowledge() to infer omitted attributes and prevent style terms from bleeding into subject attributes.

intelligent_generator.py
'ethnicity_typical_eyes': {
East_Asian -> ['black','dark brown','brown'], European -> ['blue','green','brown','hazel','grey']. It also includes ethnicity_typical_hair, style_types, director_lighting_styles (zhang_yimou/cinematic/film_noir, each with lighting_keywords and required_elements), and subject_attribute_categories. Consistency checks (check_consistency / resolve_conflicts) are built on top of these mappings.

Self-learning closed loop: prompt-extractor cleans, clusters, and extracts modular components from corpus, while universal-learner writes elements back to elements.db through a 6-step pipeline (type identification -> domain classification -> element extraction -> tagging -> reusability scoring -> DB write), structured as a semi-automated workflow requiring human review.

.claude/skills/universal-learner/SKILL.md
**学习方式**: 半自动(生成报告 + 人工审核)
The database insertion path is defined in modules/library_updater.md via db.add_element(...) calls (deduplication applied: exact name matching + keyword Jaccard similarity > 0.8). Distribution in elements.learned_from confirms the loop has run in practice: universal_learner_v2 861, migrated_from_v2 104, migrated_from_v4 81, manual_learning 39, VoxcatAI Twitter 18, universal_learner 14, universal_learner_skill_test 11, batch_learner_v2_enhanced 10, plus miscellaneous entries (39 NULLs).

2Core Capabilities

01Unified generation entry point across three modes (automatic classification for portrait / cross_domain / design)
02Intelligent portrait element selection: Candidate scoring + globally optimal (non-greedy) selection
03Consistency checks and automated conflict resolution (resolving logical conflicts across ethnicity, style, and era)
04Cross-domain element composition, raising asset library utilization (40.3% -> 79.9%)
05Design variable sampling: Stylized combinations of color palettes, borders, and decorations
06Corpus-based library expansion: Extracting reusable elements from community prompts and writing them back to elements.db
07Prompt reverse engineering: Distilling 'how to control X' knowledge cards from high-performing prompts
08Generation history logging and analytical recommendations (writes generated_prompts on every run for prompt-analyzer reuse)

3External Dependencies

KindDependency / Endpoint
packagepyyaml>=6.0
packageanthropic>=0.7.0(声明依赖但全仓 Python 代码零 import,仅 learner.md 伪代码示例引用)
clipython3(运行 core/ 引擎、preprocessor.py、xray_helper.py)
clibash(skill 自带测试脚本 shell)
clipython3 prompt_tool.py(prompt-master 旧架构声明的 CLI,脚本在 pin commit 的仓库内不存在)

4Recommended Governance & Evidence

Suggested Controls for Safe Operation
For Agent Runtime
Graded/per-use authorization, sandbox recommended
For Administrators
Approval workflow, rollback support, full audit
Evidence & Triggers (File Paths & Excerpts)
  • scripts/: Executes local scripts or commands: core/cross_domain_generator.py (SKILL.md instructs the agent to execute in the host: from core.cross_doma
  • 本地工作目录: File I/O and artifact output: extracted_results/elements.db — save_generated_prompt writes to generated_prompts
Audit Notes: Blue tier; suitable for standard local use. Rationale: All 15 py/sh scripts across the repository exhibit zero network capabilities—scans for requests, urllib, http(s):// endpoints, sockets, curl, and wget yielded zero matches, and requirements.txt includes no networking libraries (requests appears solely in comments as an option 'If you add web fetching'). Zero credential access—no instances of os.environ, getenv, API_KEY, token, or secret reading. The anthropic package listed in requirements is never imported in code (its sole mention is pseudo-code in learner.md noting that AI extraction currently returns an empty list pending real LLM API integration). All operations are purely local: reading elements.db / YAML / md files, writing to elements.db along with select json/md outputs, and running python3 and bash. It is classified as Blue rather than Green because it executes local Python scripts, mutates an SQLite database directly, and contains destructive routines such as _clear_all_data() in element_db (triggered by import_from_json(clear_existing=True)), representing a local tool/CLI with read-write capabilities rather than pure instructions. It is not Yellow/Orange because it lacks external destinations, credential access, and runtime dependencies on third-party remote services (pyyaml is standard; anthropic is unused).

5Second-Pass Verification

  • [ok] 主入口判定(skill.path 该写哪一个) — .claude/skills/ 下确为 12 个 skill 目录(art-master / design-master / domain-classifier / intelligent-prompt-generator / product-master / prompt-analyzer / prompt-extractor / prompt-generator / prompt-master / prompt-xray / universal-learner / video-master)+ learner.md。定位依据两条:claude.md 项目架构段「**入口**:`.claude/skills/intelligent-prompt-generator/skill.md`」(实测文件名为大写 SKILL.md,属大小写笔误);路由指南把 portrait domain 与人像请求固定指向 intelligent-prompt-generator。另注 prompt-master 自己标注「⚠️ 旧架构」,故不选它作入口。本条目录已写入 skill.path。
  • [ok] .codex/skills 与 .claude/skills 是否内容相同 — diff -rq .claude/skills .codex/skills 无任何输出(完全一致);两侧各 35 文件、320,220 字节;md5 抽查 intelligent-prompt-generator/SKILL.md 均为 39dc6f78ad6b580eae2dbdedfcd64bfc、prompt-extractor/preprocessor.py 均为 c8d488bdb22a29334eb15b8025bce14d、SKILL_ROUTING_GUIDE.md 均为 d59be53db785d50d68f6962ab2bacb14。平台差异只在 claude.md vs codex.md:5 处(标题、入口路径 .claude→.codex、两处平台名、一处 「Claude Code 有多强」→「Codex Code 有多强」)。
  • [discrepancy] README/claude.md 宣传的 12 个 skill 是否都存在 — claude.md 与路由指南反复推荐设计类请求调用 `prompt-crafter`(⭐,20万+组合),但 .claude/skills 与 .codex/skills 下都没有 prompt-crafter 目录(grep 命中仅在 README.md/claude.md/codex.md/core/yaml_sampler.py/schema_migration_v1.sql/README_v2.0.md/UPGRADE_GUIDE_v2.0.md 的文本里)。其声称的能力实际由 core/yaml_sampler.py + core/design_bridge.py 实现,并挂在 intelligent-prompt-generator 的 Design 模式下。README 第 33 行另列了 `prompt-writer`,同样不存在,且该行自相矛盾地写「12个专业领域Skills」却列出 13 个名字。
  • [discrepancy] 文档引用的脚本/数据文件是否真实存在 — 实测 MISSING:prompt_tool.py(prompt-master/skill.md 的 20+ 条 python3 prompt_tool.py ... 命令全部指向它)、prompt_analyzer.py(prompt-analyzer/SKILL.md 的 from prompt_analyzer import analyze_prompt_detail)、learner.py、facial_features_library.json(prompt-master 的旧数据源)、module_library.json、extracted_modules.json(universal-learner 声明的输入)、universal_elements_library.json(element_db.export_library 的输出名)。.gitignore 显示这些被当作「临时开发脚本/大 JSON」排除,即用写作期本机文件而非仓库可交付资产。
  • [discrepancy] 元素数量声明三处互相矛盾 — README.md 声明 1246 且分领域明细(portrait 502/common 208/design 166/...)与 sqlite 实测 elements 表逐项吻合;但 claude.md 架构表写「1103元素,12领域」「intelligent-prompt-generator | portrait | 491」,路由指南同样写 491/51/59/77/49;而数据库 domains.total_elements 汇总只有 967(portrait 491/common 203/interior 79/product 77/design 59/art 51/video 49/prompt_writing 9),是早期快照未随 elements 表刷新。结论:README 的 1246 可信,claude.md 与路由指南的 491/1103 属过期数字。
  • [discrepancy] 「20万+ 组合」能否复算 — YAML 里可枚举的离散选项:37 个色值 × 每风格边框 (corner_radius 5 × box_shadow 3 × border 2 = 30) × 装饰 9 种 ≈ 9,990,量级差 20 倍。要把数字推到 20 万级需要把装饰的 count_range/rotation_range/size_range/opacity_range 这些连续区间按整数粒度展开计数(如星星 count 3-8 = 6 档 × rotation ±15 = 31 档 × size 16-32 = 17 档…),代码里并无这种展开逻辑(sample_variables 只是 random.choice 抽一组)。故「20万+」是营销口径的上界估计,非可复现统计。
  • [ok] 是否存在网络调用(含间接依赖) — 字符串扫描 requests/urllib/http://|https:///socket/curl/wget 在 15 个脚本中零命中;全部 import 清单实测为 os/json/sqlite3/re/yaml/sys/csv/random/time/re/Path/typing/collections/datetime 以及本项目内部模块(core.*、intelligent_generator、framework_loader)。requirements.txt 的 requests/pandas 被注释为可选,未安装也未使用。结论:零网络外发,security.network_calls 填空数组是准确而非漏查。
  • [ok] 是否存在凭证/环境变量读取 — os.environ/getenv/keychain 零命中;.env 仅出现在 .gitignore 的忽略规则里(仓库内无 .env 文件)。requirements 声明 anthropic>=0.7.0 但全仓 grep anthropic 只命中 requirements.txt 与两份 learner.md,且 learner.md 自述「当前实现中,AI辅助提取功能返回空列表,需要集成真实的LLM API」——即不上传任何 key,也不调用任何模型 API。

6Verdict & Scenarios

  • Authentic and verifiable asset base: 1,246 elements across 12 domains, 70 categories, 675 community prompt corpuses, and 5 complete design templates, all stored in a single queryable SQLite file distributed with the repository (2.5MB).
  • Complete end-to-end engineering architecture from generation to learning: Unified three-mode routing + framework-driven selection + consistency validation + generation history logging + learner updates back to the DB, with dedicated scripts and documentation for each stage.
  • Clean, self-contained security profile: Purely local execution with zero network access, zero credentials, and zero subprocesses; uses parameterized queries for database writes and safe_load for YAML, leaving user keys untouched.
  • Portable design (dual-platform mirroring + single-file data source): Identical skill assets run byte-for-byte under both Claude Code and OpenAI Codex CLI, requiring only an entry path adjustment to migrate.
  • Best for: Ideal for users building a local asset library and standardized workflow for AI image and design prompt generation: (1) Creators seeking structured portrait, poster, product, or video prompt templates without writing prompts from scratch every time; (2) Skill authors looking to adopt the 'skill orchestration + SQLite asset library + Python engine + continuous learning loop' engineering pattern for their own domain by swapping in custom elements.db and framework YAML files; (3) Users of Claude Code or Codex CLI who accept an agent running local Python and reading/writing a local SQLite database. Better suited as a reference architecture than an out-of-the-box consumer tool.
    Not for: Not suitable for: (1) Users expecting a zero-configuration, plug-and-play setup—requires Python 3.8+, pip install pyyaml, updating hardcoded absolute paths in SKILL.md, and providing a host LLM environment (the skill does not invoke model APIs directly); (2) Teams requiring cloud-hosted/SaaS infrastructure or multi-user collaboration—lacks network endpoints, authentication, and operates on a single local file; (3) Users requiring immediate production-grade outputs out of the box—IP characters, complex actions, and specialized styles depend on host LLM completion, while the library primarily contains general lighting and camera mechanics, leaving final quality dependent on model generation and manual curation; (4) Environments without Chinese language context—trigger phrases, intent keyword mappings, and template names are primarily in Chinese; (5) Commercial deployments requiring clear licensing guarantees—the repository lacks a formal LICENSE file.
    Install Agent-Ready
    ① Verified Mirror 2026-09-15
    Option A · Direct DownloadDownload image-prompt-generator.tar.gz
    sha256: c4376bb8c7682856…
    Option B · Copy Guide for Agent
    install.json
    Agents automatically download and verify mirrors from this JSON guide.
    ② Upstream GitHub
    GitHub Repo ↗
    Pinned to commit e951249840.