ads-generate

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Ads Generate — AI Ad Image Generator

Ads Generate — AI广告图片生成器

Generates platform-sized ad creative images from your campaign brief and brand profile. Uses Gemini by default (
gemini-2.5-flash-image
, stable GA).
根据您的营销活动简报和品牌资料生成适配平台尺寸的广告创意图片。默认使用Gemini(
gemini-2.5-flash-image
,稳定版已正式发布)。

Quick Reference

快速参考

CommandWhat it does
/ads generate
Generate all images from campaign-brief.md
/ads generate --platform meta
Generate Meta assets only
/ads generate --prompt "text" --ratio 9:16
Standalone generation without brief
/ads generate --batch
Use Gemini Batch API (50% cost, 24h turnaround)
命令功能
/ads generate
从campaign-brief.md生成所有图片
/ads generate --platform meta
仅生成Meta平台素材
/ads generate --prompt "text" --ratio 9:16
无需简报的独立生成模式
/ads generate --batch
使用Gemini批量API(成本降低50%,24小时周转)

Environment Setup

环境配置

Required before running:
bash
undefined
运行前必须配置:
bash
undefined

Gemini (default — recommended)

Gemini(默认推荐)

export GOOGLE_API_KEY="your-key"
export GOOGLE_API_KEY="your-key"

Get a key: console.cloud.google.com/apis/credentials

获取密钥:console.cloud.google.com/apis/credentials

Switch to a different provider (optional)

切换到其他服务商(可选)

export ADS_IMAGE_PROVIDER="openai" export OPENAI_API_KEY="your-key"
export ADS_IMAGE_PROVIDER="stability" export STABILITY_API_KEY="your-key"
export ADS_IMAGE_PROVIDER="replicate" export REPLICATE_API_TOKEN="your-token"

If the API key is not set, this skill will display the setup instructions above
and stop. It will never fail silently.
export ADS_IMAGE_PROVIDER="openai" export OPENAI_API_KEY="your-key"
export ADS_IMAGE_PROVIDER="stability" export STABILITY_API_KEY="your-key"
export ADS_IMAGE_PROVIDER="replicate" export REPLICATE_API_TOKEN="your-token"

如果未设置API密钥,该工具将显示上述配置说明并停止运行,不会静默失败。

Process

执行流程

Step 1: Check API Key

步骤1:检查API密钥

Verify the required environment variable is set before proceeding:
bash
python3 -c "
import os, sys
provider = os.environ.get('ADS_IMAGE_PROVIDER', 'gemini')
keys = {'gemini': 'GOOGLE_API_KEY', 'openai': 'OPENAI_API_KEY',
        'stability': 'STABILITY_API_KEY', 'replicate': 'REPLICATE_API_TOKEN'}
env_var = keys.get(provider, 'GOOGLE_API_KEY')
if not os.environ.get(env_var):
    print(f'Error: {env_var} not set (provider: {provider})', file=sys.stderr)
    sys.exit(1)
print(f'OK: {env_var} is set')
"
If this exits with code 1, display the Environment Setup section above and stop.
继续执行前验证所需环境变量是否已设置:
bash
python3 -c "
import os, sys
provider = os.environ.get('ADS_IMAGE_PROVIDER', 'gemini')
keys = {'gemini': 'GOOGLE_API_KEY', 'openai': 'OPENAI_API_KEY',
        'stability': 'STABILITY_API_KEY', 'replicate': 'REPLICATE_API_TOKEN'}
env_var = keys.get(provider, 'GOOGLE_API_KEY')
if not os.environ.get(env_var):
    print(f'Error: {env_var} not set (provider: {provider})', file=sys.stderr)
    sys.exit(1)
print(f'OK: {env_var} is set')
"
如果该脚本退出码为1,将显示上述环境配置部分并停止运行。

Step 2: Locate Source Files

步骤2:定位源文件

Check for:
  • campaign-brief.md
    → primary source for prompts and dimensions
  • brand-profile.json
    → brand color/style injection (optional but recommended)
If campaign-brief.md is found: Use
## Image Generation Briefs
section as the generation job list.
If no campaign-brief.md: Enter standalone mode (Step 2b).
检查以下文件:
  • campaign-brief.md
    → 提示词和尺寸的主要来源
  • brand-profile.json
    → 品牌颜色/风格注入(可选但推荐)
如果找到campaign-brief.md:使用
## Image Generation Briefs
部分作为生成任务列表。
如果未找到campaign-brief.md:进入独立模式(步骤2b)。

Step 2b: Standalone Mode

步骤2b:独立模式

Ask the user:
  1. Generation prompt (what should the image show?)
  2. Target platform (to set correct dimensions)
  3. Output filename (optional)
Then skip to Step 5.
询问用户:
  1. 生成提示词(图片应展示什么内容?)
  2. 目标平台(用于设置正确尺寸)
  3. 输出文件名(可选)
然后跳至步骤5。

Step 3: Read Provider Config

步骤3:读取服务商配置

Load
~/.claude/skills/ads/references/image-providers.md
to confirm:
  • Active provider pricing (show user the cost estimate)
  • Rate limits for current tier
  • Batch API availability
加载
~/.claude/skills/ads/references/image-providers.md
以确认:
  • 当前服务商的定价(向用户展示成本估算)
  • 当前层级的速率限制
  • 批量API的可用性

Step 4: Read Platform Specs

步骤4:读取平台规格

For each platform in the campaign brief, load the relevant spec reference:
  • ~/.claude/skills/ads/references/meta-creative-specs.md
  • ~/.claude/skills/ads/references/google-creative-specs.md
  • ~/.claude/skills/ads/references/tiktok-creative-specs.md
  • ~/.claude/skills/ads/references/linkedin-creative-specs.md
  • ~/.claude/skills/ads/references/youtube-creative-specs.md
  • ~/.claude/skills/ads/references/microsoft-creative-specs.md
针对营销活动简报中的每个平台,加载对应的规格参考文件:
  • ~/.claude/skills/ads/references/meta-creative-specs.md
  • ~/.claude/skills/ads/references/google-creative-specs.md
  • ~/.claude/skills/ads/references/tiktok-creative-specs.md
  • ~/.claude/skills/ads/references/linkedin-creative-specs.md
  • ~/.claude/skills/ads/references/youtube-creative-specs.md
  • ~/.claude/skills/ads/references/microsoft-creative-specs.md

Step 5: Spawn Visual Designer Agent

步骤5:启动视觉设计Agent

Spawn the
visual-designer
agent using the Task tool with
context: fork
.
The agent will:
  • Parse the image generation briefs from campaign-brief.md
  • Inject brand colors and mood from brand-profile.json
  • Call generate_image.py for each asset
  • Save to
    ./ad-assets/[platform]/[concept]/
    directory structure
  • Write
    generation-manifest.json
使用Task工具并设置
context: fork
来启动
visual-designer
Agent。
该Agent将:
  • 解析campaign-brief.md中的图片生成简报
  • 从brand-profile.json注入品牌颜色和风格
  • 为每个素材调用generate_image.py
  • 保存到
    ./ad-assets/[platform]/[concept]/
    目录结构
  • 生成
    generation-manifest.json
    文件

Step 6: Validate with Format Adapter

步骤6:通过格式适配器验证

After the visual-designer completes, spawn the
format-adapter
agent with
context: fork
to validate dimensions and report missing formats.
视觉设计Agent完成后,使用
context: fork
启动
format-adapter
Agent以验证尺寸并报告缺失的格式。

Step 7: Report Results

步骤7:报告结果

Present a summary:
Generation complete:

  Generated assets:
    ✓ ./ad-assets/meta/concept-1/feed-1080x1350.png
    ✓ ./ad-assets/tiktok/concept-1/vertical-1080x1920.png
    ✗ ./ad-assets/google/concept-1/landscape-1200x628.png [error reason]

  Format validation: See format-report.md

  Cost estimate: ~$[N] at $0.067/image (Gemini 1K)

  Next steps:
    1. Review assets in ./ad-assets/
    2. Check format-report.md for any missing formats
    3. Upload to your ad platform managers
展示汇总信息:
生成完成:

  已生成素材:
    ✓ ./ad-assets/meta/concept-1/feed-1080x1350.png
    ✓ ./ad-assets/tiktok/concept-1/vertical-1080x1920.png
    ✗ ./ad-assets/google/concept-1/landscape-1200x628.png [错误原因]

  格式验证:查看format-report.md

  成本估算:约$[N](Gemini 1K,单价$0.067/张)

  后续步骤:
    1. 查看./ad-assets/目录下的素材
    2. 检查format-report.md中的缺失格式
    3. 上传至您的广告平台管理后台

Cost Transparency

成本透明度

Before generating, estimate and show the cost:
  • Count the number of image briefs in campaign-brief.md
  • Multiply by $0.067 (Gemini default 1K)
  • Show: "Estimated cost: [N] images × $0.067 = ~$[total]"
  • If >$1.00, ask for confirmation before proceeding
生成前会估算并展示成本:
  • 统计campaign-brief.md中的图片简报数量
  • 乘以$0.067(Gemini默认1K分辨率单价)
  • 展示:"估算成本:[N] 张 × $0.067 = 约$[总价]"
  • 如果总成本超过$1.00,生成前会请求用户确认

Standalone Mode (No campaign-brief.md)

独立模式(无campaign-brief.md)

When running without a campaign brief:
Platform target → dimensions used:
  meta-feed     → 1080×1350 (4:5)
  meta-reels    → 1080×1920 (9:16)
  tiktok        → 1080×1920 (9:16)
  google-pmax   → 1200×628 (1.91:1)
  linkedin      → 1080×1080 (1:1)
  youtube       → 1280×720 (16:9)
  youtube-short → 1080×1920 (9:16)
Calls generate_image.py directly:
bash
python ~/.claude/skills/ads/scripts/generate_image.py \
  "[user prompt]" \
  --size [WxH] \
  --output [filename] \
  --json
无营销活动简报时运行:
目标平台 → 使用的尺寸:
  meta-feed     → 1080×1350(4:5)
  meta-reels    → 1080×1920(9:16)
  tiktok        → 1080×1920(9:16)
  google-pmax   → 1200×628(1.91:1)
  linkedin      → 1080×1080(1:1)
  youtube       → 1280×720(16:9)
  youtube-short → 1080×1920(9:16)
直接调用generate_image.py:
bash
python ~/.claude/skills/ads/scripts/generate_image.py \
  "[用户提示词]" \
  --size [宽×高] \
  --output [文件名] \
  --json

Reference Files

参考文件

  • ~/.claude/skills/ads/references/image-providers.md
    — provider config, pricing, limits
  • ~/.claude/skills/ads/references/[platform]-creative-specs.md
    — per-platform specs
  • ~/.claude/skills/ads/references/brand-dna-template.md
    — brand injection schema
  • ~/.claude/skills/ads/references/image-providers.md
    — 服务商配置、定价、限制
  • ~/.claude/skills/ads/references/[platform]-creative-specs.md
    — 各平台规格
  • ~/.claude/skills/ads/references/brand-dna-template.md
    — 品牌注入模板