claude-seo 图像生成提示词工程实战:基于 Claude Banana 的六组件推理简报与领域模式提示词体系
claude-seo 图像生成提示词工程实战:基于 Claude Banana 的六组件推理简报与领域模式提示词体系
【免费下载链接】claude-seoUniversal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.项目地址: https://gitcode.com/GitHub_Trending/cl/claude-seo
本文面向在 claude-seo 项目中使用
seo-image-gen技能(基于 Gemini 图像生成模型、经 nanobanana MCP 驱动的 Claude Banana 流水线)的开发者与 SEO 从业者。全文围绕 prompt-engineering.md 这套提示词工程参考展开,系统讲解"六组件推理简报"(6-Component Reasoning Brief)、九大领域模式修饰库、高级技巧、跨模型提示词迁移规则、经 2500+ 条提示词验证的成熟模板,以及安全过滤器改写策略;读完你能够为 OG 图、博客头图、产品图、信息图等 SEO 资产编写出可稳定复现的高质量生成提示词,并理解这些提示词在仓库中的真实执行链路。
文档在技能体系中的定位
在 claude-seo 仓库中,SKILL.md 将这套提示词方法定义为生成流水线的核心步骤之一:构造 Reasoning Brief 时"加载references/prompt-engineering.md使用六组件系统",并按领域模式分配权重(Subject 30%、Style 25%、Context 15% 等)。因此这份参考文档不是孤立的写作技巧,而是seo-image-gen每次调用gemini_generate_image之前的必经环节。本文按原文档骨架逐节展开,并在关键处补充 generate.py、presets.py、batch.py 等源码证据,帮助你理解"提示词→API 请求→图片产出"的完整链路。
六组件推理简报(6-Component Reasoning Brief)
文档明确了一条硬性规则:每个图像提示词都应包含以下六个组件,并以自然叙事段落书写,绝不使用逗号分隔的关键词列表。关键词列表丢掉了组件之间的逻辑关系,模型只能"堆砌"元素而非"理解"场景。
1. Subject(主体)
主体的核心是物理细节的具体性——年龄、肤质、皱纹、手部状态等可被"看见"的特征,而不是类别标签。
- Good:"A weathered Japanese ceramicist in his 70s, deep sun-etched wrinkles mapping decades of kiln work, calloused hands cradling a freshly thrown tea bowl with an irregular, organic rim"
- Bad:"old man, ceramic, bowl"
2. Action(动作)
描述正在发生的事情:运动、姿态、手势、存在状态。用动词让画面"活"起来。
- Good:"leaning forward with intense concentration, gently smoothing the rim with a wet thumb, a thin trail of slip running down his wrist"
- Bad:"making pottery"
3. Context(环境)
环境、场所、时间与空间细节,负责建立可信的世界观。
- Good:"inside a traditional wood-fired anagama kiln workshop, stacked shelves of drying pots visible in the soft background, late afternoon light filtering through rice paper screens"
- Bad:"workshop, afternoon"
4. Composition(构图)
镜头角度、景别、取景方式、空间关系。没有构图指令的默认结果是居中构图。
- Good:"intimate close-up shot from slightly below eye level, shallow depth of field isolating the hands and bowl against the soft bokeh of the workshop behind"
- Bad:"close up"
5. Lighting(灯光)
光源、光线质量、方向、色温、阴影。这是文档反复强调的最大质量分水岭(见"常见错误"第 3 条)。
- Good:"warm directional light from a single high window camera-left, creating gentle Rembrandt lighting on the face with a soft triangle of light on the shadow-side cheek, deep warm shadows in the workshop"
- Bad:"natural lighting"
6. Style(风格)
艺术媒介、美学参照、摄影技术细节。命名真实设备与经典美学参照,比空洞的"写实、8K、杰作"有效得多。
- Good:"captured with a Sony A7R IV, 85mm f/1.4 GM lens, Kodak Portra 400 color grading with lifted shadows and muted earth tones, reminiscent of Dorothea Lange's documentary portraiture"
- Bad:"photorealistic, 8K, masterpiece"
与源码的印证:在 generate.py 中,提示词作为contents[0].parts[0].text原样传给 Gemini 的generateContent接口,模型只拿到一段纯文本。这解释了为什么"叙事段落"而非"标签堆砌"如此重要——API 层没有任何额外的关键词解析或权重修饰,全部语义负担都落在自然语言本身。
领域模式修饰库(Domain Mode Modifier Libraries)
针对不同图像类型,文档提供九套可直接引用的修饰词库。它们的作用是把六组件中的 Style/Composition/Lighting 等组件填充到该领域可被模型识别的"行话"粒度。
Cinema Mode(电影模式)
- 相机规格:RED V-Raptor、ARRI Alexa 65、Sony Venice 2、Blackmagic URSA
- 镜头:Cooke S7/i、Zeiss Supreme Prime、Atlas Orion anamorphic
- 胶片:Kodak Vision3 500T(钨丝灯)、Kodak Vision3 250D(日光)、Fuji Eterna Vivid
- 布光方案:三点布光、明暗对照(chiaroscuro)、伦勃朗光、分割光、蝴蝶光、轮廓/逆光
- 景别:建立性远景、中近景、极限特写、荷兰角、俯拍摇臂、斯坦尼康跟拍
- 调色:青橙、去饱和冷调、温暖复古、高对比黑色电影
Product Mode(产品模式)
- 表面:抛光大理石、拉丝混凝土、原色亚麻、亚克力台座、渐变背景
- 灯光:柔光箱漫射、硬光主光+补光板、轮廓分离、帐篷光(tent lighting)、光绘
- 角度:45 度主视觉、俯拍平铺、四分之三、正对、虫眼视角
- 风格参照:Apple 产品摄影、Aesop 极简、Bang & Olufsen 简洁、奢侈美妆
Portrait Mode(人像模式)
- 焦段:85mm(经典)、105mm(压缩感)、135mm(长焦)、50mm(环境人像)
- 光圈:f/1.4(梦幻虚化)、f/2.8(主体锐利)、f/5.6(环境交代)
- 姿态语言:抓拍中途手势、直面镜头的对抗性、剪影侧面、过肩回望
- 肤质/纹理:可见雀斑、微距下的毛孔、眼中的眼神光、次表面散射
Editorial/Fashion Mode(编辑/时尚模式)
- 出版物参照:Vogue Italia、Harper's Bazaar、GQ、National Geographic、Kinfolk
- 造型要点:层次质感、标志性配饰、单色配色、对比图案
- 场景:大理石楼梯、金色时刻天台、工业 loft、沙漠沙丘、霓虹小巷
- 姿态:力量站姿、放松编辑式斜倚、运动模糊、风中织物
UI/Web Mode(界面/网页模式)
- 风格:扁平矢量、等距 3D、线条艺术、玻璃拟态、新拟态、Material Design
- 颜色:指定精确 hex 或描述性色板(如 "cool blues #2563EB to #1E40AF")
- 尺寸:按 2x 为 retina 设计,指明需要的精确像素尺寸
- 背景:透明(先要纯白背景再后期处理)、渐变、纯色
Logo Mode(标志模式)
- 构造:几何原语、黄金比例、网格制图、负空间
- 字体:粗体无衬线、优雅衬线、定制字标、字母组合
- 颜色:最多 2-3 色、可单色化、高对比
- 输出:要求纯白背景生成,后期处理为透明
Landscape Mode(风景模式)
- 景深分层:前景兴趣点、中景主体、背景氛围
- 大气效果:雾、薄雾、霾、体积光柱、尘埃粒子
- 时段:蓝调时刻(黎明前)、金色时刻、魔法时刻(日落后)、午夜蓝
- 天气:戏剧性暴风云、雨后转晴、积雪、阳光斑驳
Infographic Mode(信息图模式)
- 布局:模块化分区、清晰视觉层级、bento 网格、自上而下流向
- 文字:用引号包裹精确文本、描述性字体风格、指明字号层级
- 数据可视化:柱状图、饼图、流程图、时间线、对比表格
- 颜色:高对比、无障碍配色、一致的品牌色
Abstract Mode(抽象模式)
- 几何:分形、沃罗诺伊镶嵌、螺旋、斐波那契、有机流动、晶体
- 纹理:大理石纹路、流体动力学、烟雾卷须、墨水扩散、水彩晕染
- 色板:类比和谐、互补冲突、单色渐变、霓虹衬黑
- 风格:生成艺术、数据可视化艺术、故障艺术、程序化、材料微距摄影
实战建议(结合 SEO 用例表):原文档在 SKILL.md 的用例映射中为每种 SEO 资产指定了领域模式——OG/Social 预览用 Product 或 UI/Web,博客头图用 Cinema 或 Editorial,产品图用 Product,信息图用 Infographic,Favicon 用 Logo。选择领域模式时应先查用例表确定模式,再用上方修饰库填充细节。
高级技巧(Advanced Techniques)
多轮角色一致性(Character Consistency)
使用gemini_chat保持会话上下文,并通过"描述锚点"维持角色稳定:
- 第一轮:用详尽的物理描述生成角色
- 后续轮:引用"同一个角色"+ 重复 2-3 个关键标识
- 关键标识:发色/发型、标志性服装、面部特征
多图参考技术(3.1 Flash):
- 在对话中提供最多 4-5 张角色参考图
- 为每个角色分配名字("Character A: the red-haired knight")
- 模型在不同角度、动作、环境中保持角色特征
- 参考图若覆盖多个角度,效果最佳
源码支撑:gemini_chat是 nanobanana MCP 提供的能力(见 mcp-tools.md),其核心卖点正是"会话一致性"——跨轮次保持风格、角色与上下文。这也解释了文档错误清单第 10 条"不要试图一次生成就做到完美"的原因:迭代式精修依赖的就是会话上下文。
无参考图的风格迁移(Style Transfer Without Reference Images)
详尽描述目标风格,替代引用图片:
Render this scene in the style of a 1950s travel poster: flat areas of color in a limited palette of teal, coral, and cream. Bold geometric shapes with visible paper texture. Hand-lettered title text with a mid-century modern typeface feel.文本渲染技巧(Text Rendering Tips)
- 精确引用文本:
with the text "OPEN DAILY" in bold condensed sans-serif - 25 个字符以内是可靠渲染的实际上限
- 最多 2-3 个独立短语:更多文本片段会显著降低质量
- 描述字体特征而非字体名称
- 指明位置:"centered at the top third"、"along the bottom edge"
- 高对比:深底浅字或反之
- 文本优先 hack:先在对话中以对话方式确立文本概念("I need a sign that says FRESH BREAD"),再生成——模型会锚定早期提到的文本
- 预期字体会被创造性诠释,而非精确复刻
与模型文档的交叉印证:文本渲染上限在 gemini-models.md 中被再次确认("Text rendering supported - best under 25 characters"),并在常见错误第 8 条中作为独立失分项列出。
正面表述(Positive Framing,不使用否定提示词)
Gemini 不支持 negative prompt。将排除性表述改写为正面表述:
| 不要写 | 改写为 |
|---|---|
| "no blur" | "sharp, in-focus, tack-sharp detail" |
| "no people" | "empty, deserted, uninhabited" |
| "no text" | "clean, uncluttered, text-free" |
| "not dark" | "brightly lit, high-key lighting" |
搜索增强生成(Search-Grounded Generation)
基于真实世界数据(天气、事件、统计)的图像,可借助 Google Search grounding 引入实时信息,特别适合含当前数据的信息图。三段式公式:
[Search/source request]:要查什么[Analytical task]:要分析/提取什么[Visual translation]:如何渲染成图像
示例:"Search for the current top 5 programming languages by GitHub usage in 2026, analyze their relative popularity percentages, then generate a clean infographic bar chart with the language logos and percentages in a modern dark theme."
该能力在 API 层由"tools": [{"googleSearch": {}}]启用(见 gemini-models.md),是否可用取决于 MCP 包版本对 search grounding 的支持(见 mcp-tools.md 的功能可用性表)。
从 Midjourney/DALL-E 到 Gemini 的提示词迁移规则
当从 claude-prompts 数据库(Midjourney/DALL-E 等)迁移提示词到 Gemini 自然语言格式时,按下表逐项映射:
| 源语法 | Gemini 等价写法 |
|---|---|
--ar 16:9 | 单独调用set_aspect_ratio("16:9") |
--v 6、--style raw | 移除——Gemini 没有版本/风格参数 |
--chaos 50 | 描述多样性:"unexpected, surreal composition" |
--no trees | 正面表述:"open clearing with no vegetation" |
(word:1.5)权重 | 描述性强调:"prominently featuring [word]" |
8K, masterpiece, ultra-detailed | 只保留 "ultra-realistic, high resolution",其余删除 |
| 逗号分隔标签 | 扩展为描述性叙事段落 |
shot on Hasselblad | 保留——相机规格在 Gemini 中有效 |
关键洞察:这张表背后是两种完全不同的提示词哲学——Midjourney 用参数化标志(flag)控制生成,Gemini 用自然语言承载全部语义。第 5 行"权重语法→描述性强调"的映射说明:(word:1.5)这类权重控制没有直接等价物,只能通过位置和措辞("prominently featuring")来传递重要性。
十大常见提示词错误
- 关键词堆砌:堆叠通用质量词("8K, masterpiece, best quality")毫无增益,只在结尾使用 "ultra-realistic, high resolution"
- 标签列表:Gemini 要散文,不要 "red car, sunset, mountain, cinematic"
- 缺少灯光描述:这是最大的质量分水岭
- 没有构图指令:结果就是千篇一律的居中构图
- 风格含糊:"make it look cool" 对比具体的艺术方向
- 忽略宽高比:始终在生成前设置
- 提示词过长:超过约 200 词后收益递减;要精准而非冗长
- 文本超过约 25 字符:超出后渲染质量急剧下降
- 关键细节埋在末尾:长提示词中靠后的细节可能被降权;把关键信息(精确文本、关键约束)放在提示词前三分之一
- 不通过后续提示词迭代:用
gemini_chat渐进精修,而不是试图一次生成搞定一切
源码验证(第 6 条):generate.py 定义了 14 种合法宽高比集合VALID_RATIOS(1:1、16:9、9:16、4:3、3:4、2:3、3:2、4:5、5:4、1:4、4:1、1:8、8:1、21:9),并在 L148-L154 做运行时校验——传入非法比值会直接报错退出。在 MCP 路径下则通过set_aspect_ratio在生成前设置(mcp-tools.md 列出全部 14 种)。因此"忽略宽高比"不仅损失构图质量,还可能触发参数校验失败。
经过验证的提示词模板库(Proven Prompt Templates)
以下模式从 2500+ 条测试过的提示词中提取,持续产出高质量结果。以它们为起点,按需求调整。
获胜公式(Winning Formula,权重分配)
| 组件 | 权重 | 包含内容 |
|---|---|---|
| Subject(主体) | 40% | 年龄、肤色、发色/发型、瞳色、体型、表情 |
| Styling(造型) | 25% | 品牌名、纹理、版型、配饰、颜色 |
| Environment(环境) | 15% | 地点 + 时段 + 情境细节 |
| Camera(相机) | 10% | 相机型号 + 镜头 + 焦段 + 景别 |
| Lighting(灯光) | 10% | 质量、方向、色温、阴影 |
注意:此权重表是提示词内的组件分布建议;seo-image-gen流水线在 SKILL.md 中另有领域模式强调权重(Subject 30%、Style 25%、Context 15% 等),二者角度不同——前者教"怎么写",后者教"按领域怎么侧重",使用时互为补充。
Instagram 广告 / 社交媒体
模式:[带年龄/外貌的主体] + [带品牌/质感的服装] + [动作动词] + [场景] + [相机规格] + [灯光] + [平台美学]
示例(产品植入):
Hyper-realistic gym selfie of athletic 24yo influencer with glowing olive skin, wearing crinkle-textured athleisure set in mauve. iPhone 16 Pro Max front-facing portrait mode capturing sweat droplets on collarbones, hazel eyes enhanced by gym LED lighting. Mirror reflection shows perfect form, golden morning light through floor-to-ceiling windows. Frayed chestnut ponytail with baby hairs, ultra-detailed skin texture, trending aesthetic.示例(生活方式广告):
A 24-year-old blonde fitness model in a high-energy sports drink advertisement. Mid-run on a beach, wearing a vibrant orange sports bra and black shorts, playful smile and sparkling blue eyes exuding vitality. Bottle of the drink held in hand, waves crashing in background. Shot on Nikon D850 with 70-200mm f/2.8 lens, natural light, fast shutter speed capturing motion. Ultra-realistic skin texture, water droplets, product label clearly visible.示例(奢华生活方式):
Gorgeous Instagram model wearing a designer silk gown, luxury rooftop restaurant, golden hour lighting, champagne in hand, luxurious aspirational lifestyle. Captured with Sony A7R IV, 85mm f/1.4 lens, shallow depth of field, warm color grading.产品 / 商业摄影
模式:[带品牌/细节的产品] + [动态元素] + [表面/场景] + "commercial photography for advertising campaign" + [灯光] + "high resolution"
示例(饮品):
Gatorade bottle with condensation dripping down the sides, surrounded by lightning bolts and a burst of vibrant blue and orange light rays. The Gatorade logo is prominently displayed on the bottle, with splashes of water frozen in mid-air. Commercial food photography for an advertising campaign, high resolution, high level of detail, vibrant complementary colors.示例(食品):
In and Out burger with layers of fresh lettuce, melted cheese, and pretzel bun, placed on a white surface with the In and Out logo subtly glowing in the background. Falling french fries and golden light, warm scene. Commercial food photography for an advertising campaign, high resolution, high level of detail, vibrant complementary colors.时尚 / 编辑
模式:[带族裔/年龄/特征的模特] + [带质感/品牌/剪裁的服装] + [地点] + [姿态/动作] + [相机 + 镜头] + [灯光质量]
示例(街拍):
A 24-year-old female AI influencer posing confidently in an urban cityscape during golden hour. Flawless sun-kissed skin, long wavy brown hair, deep green eyes. Wearing a chic streetwear outfit: oversized beige blazer, white top, high-waisted jeans. Captured with Sony A7R IV at 85mm f/1.4, shallow depth of field with warm golden bokeh.示例(高级时装):
Stunning 24-year-old woman, long platinum blonde hair, radiant skin, piercing blue eyes, dressed in a chic pastel blazer with a modern minimalist aesthetic, soft sunlight glow, high-end fashion appeal. Shot on Canon EOS R5, 85mm f/1.2 lens.示例(先锋):
A blonde fitness model transformed into a runway-ready fashion icon, wearing a bold avant-garde outfit: cropped leather jacket with neon pink accents, paired with high-waisted athletic shorts and knee-high boots. Captured mid-stride on a minimalist white runway, playful twinkle in her eye, dramatic studio lighting from above.SaaS / 科技营销
模式:[UI 稿或抽象视觉] + "on [深/浅] background" + [带 hex 的具体颜色] + [字体描述] + "clean, premium SaaS aesthetic" + [玻璃拟态/渐变/辉光效果]
示例(仪表盘主视觉):
A floating glassmorphism UI card on a deep charcoal background showing a content analytics dashboard with a rising line graph in teal (#14B8A6), bar charts in coral (#F97316), and a circular progress indicator at 94%. Subtle grid lines, frosted glass effect with 20% opacity, teal glow bleeding from the card edges. Clean premium SaaS aesthetic, no text smaller than headline size.示例(功能亮点):
An isometric 3D illustration of interconnected data nodes on a dark navy background. Each node is a glowing teal sphere connected by thin luminous lines, forming a constellation pattern. One central node pulses brighter with radiating rings. Modern tech illustration style with subtle depth of field, volumetric lighting from below.示例(对比/前后对照):
Split-screen image: left side shows a cluttered, dim workspace with scattered papers, red error indicators, and a frustrated expression conveyed through a cracked coffee mug and tangled cables. Right side shows a clean, organized dashboard interface glowing in teal and white on a dark background, with smooth flowing lines and checkmarks. A sharp vertical dividing line separates chaos from clarity.Logo / 品牌
模式:[产品/瓶装/物品] + "with [品牌元素] prominently displayed" + [动态视觉元素] + "commercial photography" + [灯光风格] + "high resolution, vibrant complementary colors"
示例:
A sleek matte black bottle with a minimal white logo mark centered on the label, surrounded by swirling gradient ribbons of teal and coral light. The bottle sits on a reflective dark surface, sharp studio rim lighting separating it from the background. Product photography for luxury branding, high resolution, dramatic contrast.让提示词真正起效的关键战术(Key Tactics)
- 点名真实相机:"Sony A7R IV"、"Canon EOS R5"、"iPhone 16 Pro Max" 锚定真实感
- 指定精确镜头:"85mm f/1.4" 给模型精确的景深信息
- 使用年龄 + 族裔 + 特征:"24yo with olive skin, hazel eyes" 远胜 "a person"
- 品牌锚定造型:"Lululemon mat"、"Tom Ford suit" 触发特定视觉联想
- 包含微细节:"sweat droplets on collarbones"、"baby hairs stuck to neck"
- 添加平台语境:"Instagram aesthetic"、"commercial photography for advertising"
- 描述质感:"crinkle-textured"、"metallic silver"、"frosted glass"
- 使用动作动词:"mid-run"、"posing confidently"、"captured mid-stride"
- 结尾用 "ultra-realistic, high resolution":这两个锚点在 Gemini 上有效;避免 "8K, masterpiece, best quality" 这类无价值的通用堆叠
- 产品图要写 "prominently displayed":确保产品/logo 不被隐藏
反模式(不要这样做)
- "A dark-themed Instagram ad showing...":过于元层面,描述的是概念而非画面
- "A sleek SaaS dashboard visualization...":抽象,没有视觉锚点
- "Modern, clean, professional...":对模型毫无意义的模糊形容词
- "A bold call to action with...":描述营销意图而非视觉内容
- 描述观者应该有什么感受:改为描述"什么创造了那种感受"
安全过滤器改写策略(Safety Filter Rephrase Strategies)
Gemini 的安全过滤器(Layer 2:服务端输出过滤器)无法关闭。提示词被拦截时唯一出路是改写。
常见触发类别
| 类别 | 触发内容 | 改写思路 |
|---|---|---|
| 暴力/武器 | 战斗、血腥、受伤、枪械 | 使用隐喻或后果描述:"battle-worn" → "weathered veteran" |
| 医疗/血腥 | 手术、伤口、解剖细节 | 抽象化或临床化:"open wound" → "medical illustration" |
| 真实公众人物 | 指名道姓的名人、政客 | 使用原型:"Elon Musk" → "a tech entrepreneur in a minimalist office" |
| 儿童+风险 | 未成年人处于任何模糊情境 | 添加安全语境:说明教育、家庭或玩乐式框架 |
| 色情/暗示 | 暴露服装、亲密姿态 | 艺术化框架:"fashion editorial, fully clothed, editorial pose" |
五种改写模式
- 抽象化(Abstraction):把具体危险元素替换为抽象概念
- 艺术框架(Artistic framing):把内容框定为艺术、编辑或纪录片
- 隐喻(Metaphor):用象征性语言替代字面描述
- 正面强调(Positive emphasis):描述"存在什么",而非"危险的是什么"
- 语境转移(Context shift):从威胁性语境转移到教育/专业语境
改写示例对照
| 被拦截的提示词 | 成功改写 |
|---|---|
| "a soldier in combat firing a rifle" | "a determined soldier standing guard at dawn, rifle slung over shoulder, morning mist over the outpost" |
| "a scary horror monster" | "a fantastical creature from a dark fairy tale, intricate organic textures, bioluminescent accents, concept art style" |
| "dog in a fight" | "a friendly golden retriever playing energetically in a sunny park, action shot, joyful expression" |
| "medical surgery scene" | "a clean modern operating room viewed from the observation gallery, soft blue surgical lights, professional documentary style" |
| "celebrity portrait of [name]" | "a distinguished middle-aged man in a tailored navy suit, warm studio lighting, editorial portrait style" |
关键原则
Layer 2(输出过滤器)分析的是生成的图像本身,而非仅提示词。即使提示词措辞完美,模型解读方式若触发输出过滤器仍会被拦截。此时应把视觉概念整体向远离触发点的方向移动,而不是只换措辞。
在流水线中的表现:拦截在 generate.py 中体现为promptFeedback.blockReason或候选为空,直接以错误退出;SKILL.md 的 错误处理表 明确IMAGE_SAFETY的解决方式是"改写提示词——见 prompt-engineering 的安全章节"。同时 gemini-models.md 记录了一个已知问题:过滤器"过度谨慎",良性提示词也可能被拦截,需要改写措辞迭代。建议在改写前先用 SKILL.md 的成本意识流程记录一次失败尝试,避免反复试错产生无效费用。
提示词如何进入生成流水线:源码级串联
把上述技巧落到实际执行,完整链路如下(依据 SKILL.md 的 Generation Pipeline):
- 识别用例:由命令或上下文判断(og、hero、product、infographic、custom、batch),映射到预配置参数
- 应用 SEO 默认值:用例表决定宽高比、分辨率与领域模式(如 OG 图 16:9/1K/Product,信息图 2:3/4K/Infographic)
- 检查预设:
python3 scripts/presets.py list查看品牌预设;presets.py 将预设存储为~/.banana/presets/NAME.json,create子命令支持--colors/--style/--typography/--lighting/--mood/--ratio/--resolution参数;品牌预设覆盖 SEO 默认值的颜色/情绪/字体,但宽高比与分辨率始终由 SEO 预设兜底(见 seo-image-presets.md 的选择逻辑) - 设置宽高比:MCP 路径调
set_aspect_ratio;直连 API 路径由--aspect-ratio传入并在 generate.py 校验 14 种合法值 - 构造 Reasoning Brief:加载本提示词工程参考,按六组件叙事段落编写,应用领域模式权重侧重
- 生成:MCP 调
gemini_generate_image;MCP 不可用时回退python3 scripts/generate.py --prompt "..." --aspect-ratio "16:9" --resolution 1K --model gemini-3.1-flash-image-preview(generate.py 的请求体会把responseModalities设为["TEXT","IMAGE"],可选thinkingConfig.thinkingLevel,并自动在错误输出中脱敏 Google API Key) - 批量场景:batch.py 解析 CSV(必需
prompt列,可选ratio/resolution/model/preset),输出结构化计划 JSON 并附带estimated_cost总估算——这正是文档"成本透明"原则的实现 - 成本记账:
python3 scripts/cost_tracker.py log --model MODEL --resolution RES --prompt "brief"记录每次生成,cost_tracker.py 按模型+分辨率查价(如 3.1 Flash 1K 约 $0.039、4K 约 $0.156)写入~/.banana/costs.json - 生成后 SEO 清单:alt text、SEO 文件名(
keyword-description-widthxheight.webp)、WebP 转换(magick output.png -quality 85 output.webp)、文件体积目标(头图 <200KB、缩略图 <100KB)、ImageObject结构化数据与og:image标签——后处理的具体 ImageMagick/FFmpeg 配方见 post-processing.md,其中 4K 输出建议直接以原生 4K 生成而非 1K 后放大
总结:一套可落地的提示词方法论
回到本文起点,prompt-engineering.md 的核心贡献可以归纳为三层:结构层(六组件推理简报保证提示词信息完整)、表达层(叙事段落、真实相机/品牌锚点、正面表述替代否定、具体灯光与构图指令保证模型可解析)、策略层(领域模式库与模板库降低从零编写的成本,安全改写策略处理被拦截的边界情况)。在 claude-seo 中,这套方法论通过seo-image-gen技能与 Banana 扩展落地为可重复执行的生成流水线——编写提示词时,记住开头那条贯穿全文的规则:让模型"看见"你描述的场景,而不是"读"到一组标签。
【免费下载链接】claude-seoUniversal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.项目地址: https://gitcode.com/GitHub_Trending/cl/claude-seo
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考