start-3-1-2

GitHub

教授图像生成API基础,解释Gemini模型原理及参数控制。通过实际生成图片演示迭代优化流程,涵盖提示词、比例与分辨率设置,并展示如何调用脚本进行创作。

course-materials/.claude/skills/start-3-1-2/SKILL.md carlvellotti/free-ai-courses

Trigger Scenarios

用户输入 /start-3-1-2 需要理解图像生成底层逻辑时

Install

npx skills add carlvellotti/free-ai-courses --skill start-3-1-2 -g -y
More Options

Non-standard path

npx skills add https://github.com/carlvellotti/free-ai-courses/tree/main/course-materials/.claude/skills/start-3-1-2 -g -y

Use without installing

npx skills use carlvellotti/free-ai-courses@start-3-1-2

指定 Agent (Claude Code)

npx skills add carlvellotti/free-ai-courses --skill start-3-1-2 -a claude-code -g -y

安装 repo 全部 skill

npx skills add carlvellotti/free-ai-courses --all -g -y

预览 repo 内 skill

npx skills add carlvellotti/free-ai-courses --list

SKILL.md

Frontmatter
{
    "name": "start-3-1-2",
    "description": "3.1.2 Understanding the Basics. Use when the student types \/start-3-1-2.\n",
    "allowed-tools": [
        "Read",
        "Write",
        "Bash",
        "AskUserQuestion"
    ],
    "disable-model-invocation": true
}

Setup

Read .claude/rules/teaching-rules.md and follow it for everything below.

ACTION: Silently stage the shared image runtime and this lesson's bundled assets without overwriting student work:

cp -rn ".claude/skills/start-3-1-1/assets/." .

Teach this lesson from the bundled script. Follow every Say block verbatim, stop at every Check gate, and have the agent perform every Action. Do not expose instructor metadata.

Module 3.1.2: Understanding the Basics

Teaching Script for Claude Code


Teaching Flow

Welcome back! In 3.1.1 you generated your first image - pretty magical, right?

Now let's understand what's actually happening under the hood.

STOP: Ready to peek behind the curtain?

USER: Yes / Ready


When you asked me to generate that image, I was calling Google's Gemini API on your behalf.

Gemini 3 Pro - codenamed "Nano Banana Pro" - is one of the most powerful image generation models available today.

The cool thing about using the API directly (versus Google's own apps) is that it's slightly more permissive. For example, you can use real celebrities as reference images - something the consumer apps block.

And you get me as your creative partner. I handle all the technical stuff - API calls, session management, file saving - while you focus on the creative vision.

STOP: Make sense so far?

USER: Yes


All the API magic lives in a pre-built script called image_gen.py.

ACTION: Read image_gen.py and show the key function signature for generate()

Here's what you can control:

  • prompt - Your description of what to create
  • reference_images - Photos to use as visual input (we'll cover this in 3.1.3)
  • aspect_ratio - Shape of the image (1:1 square, 16:9 landscape, 9:16 portrait, etc.)
  • resolution - Size/quality (1K, 2K, or 4K)

You don't need to worry about any of that though. Just work with me naturally, and I'll handle the API calls, parameters, and file saving automatically.

Let's try it. Describe any image you'd like to create.

Be descriptive - include subject, setting, lighting, mood. This model is unbelievably good, so really stretch your imagination.

STOP: What would you like to generate?

USER: [Describes an image they want]

ACTION: First call new_session() to clear any previous session (in case user is continuing from 3.1.1). Then generate the image using their description. Use aspect_ratio="1:1" unless user asks for something different, resolution="1K"

[Make a fun/enthusiastic comment about the generated image]

ACTION: Read the exact saved path reported by the generation, state that path in prose, and provide a Markdown link to that exact file.

STOP: Open the linked image from the Desktop project tree. What do you think?

USER: [Responds with their reaction]


Here's something powerful: you don't have to start over if it's not perfect.

I remember our conversation, so you can just ask for changes. This is called "iterating" - refining an image step by step.

Even better: I continue the session with Nano Banana, which means it has all its thoughts from before. This leads to much better results when editing - the model understands the full context of what you're trying to achieve.

STOP: Tell me one thing you'd change about your image. Suggest some ideas.

USER: [Describes a change they want]

ACTION: Generate a refined version based on their feedback (this continues the existing session)

ACTION: Read the refined generation's exact saved path, state that path in prose, and provide a Markdown link to that exact file. Ask the student to open the linked image from the Desktop project tree.

STOP: Better? Want to tweak something else? Or shall we continue?

USER: [Responds]


Nice! Let's talk about aspect ratios - the shape of your image.

Here are the common options:

  • 1:1 - Square (Instagram posts, profile pics)
  • 16:9 - Landscape (presentations, YouTube thumbnails, desktop wallpapers)
  • 9:16 - Portrait (Instagram/TikTok stories, phone wallpapers)
  • 4:5 - Tall rectangle (Instagram feed posts - fits better than square)
  • 3:2 - Classic photo ratio (similar to 35mm film)

STOP: Quick quiz - which ratio would you use for a presentation slide?

USER: [Answers]

[Respond based on their answer. If they say 16:9 or landscape: "Exactly! The shape should match where you'll use the image." If wrong, gently correct and explain why 16:9 works for presentations.]


Now let's talk resolution - how big and detailed the image is.

Three options:

  • 1K (1024px): Fastest generation, about 20 seconds. Great for iterating and drafts.
  • 2K (2048px): Slower, about 30 seconds. Same cost as 1K. Good for final outputs.
  • 4K (4096px): Slowest, about 45 seconds. Costs more. Only needed for print-quality work.

For this course, we default to 1K so you can iterate quickly. There's no difference in the quality of the creative output - just the resolution.

When you're happy with a result, you can regenerate at 2K for a polished final version. 4K is only necessary if you need something physically printed at large scale.

STOP: Makes sense?

USER: Yes


Quick recap of what you learned:

  • The Gemini API powers image generation (via image_gen.py)
  • You can control aspect ratio and resolution
  • Iteration is key - refine images step by step instead of starting over
  • Use 1K for drafts, 2K for finals

In the next lesson, we'll cover the Golden Rules of Prompting - how to write prompts that get amazing results - and how to use reference images for consistent style.

STOP: Ready to continue to 3.1.3?

USER: Yes / Ready

Great! Run /start-3-1-3 when you're ready to continue.

ACTION: End module


Important Notes for Claude

For the image generation:

  • Use the generate() function from image_gen.py
  • Default to aspect_ratio="1:1" and resolution="1K" unless user specifies otherwise
  • The output will be saved automatically to outputs/
  • When iterating, the session continues automatically - don't call new_session()

For showing the function signature:

  • Show the generate() function definition from image_gen.py
  • Focus on the parameters: prompt, reference_images, aspect_ratio, resolution
  • Don't show the entire file - just the relevant function

If something goes wrong:

  • API key errors: Have them check .env file from 3.1.1
  • Generation fails: Check error message, troubleshoot accordingly
  • Session issues: Can call new_session() to start fresh if needed

Desktop file viewing:

  • State every saved output path in prose and provide a Markdown link.

Opening images: State the exact path and link it. Optionally run open <path> for the student.


Success Criteria

Module 3.1.2 is successful if the student:

  • ✅ Understands that Gemini API powers the image generation
  • ✅ Generated at least one new image of their choice
  • ✅ Successfully iterated on their image (made at least one edit)
  • ✅ Understands aspect ratios and when to use each
  • ✅ Understands resolution options (1K for drafts, 2K for finals)
  • ✅ Knows how to continue to the next lesson

Sendoff

ACTION: Silently run the following progress update. Do not mention it to the student.

mkdir -p .fspm
[ -f .fspm/progress.json ] || printf '{"name":null,"completed_lessons":[],"current_lesson":"","last_updated":""}' > .fspm/progress.json
L="cc-pms-3-1-2"; C="cc-pms-3-1-3"; T="$(date -u +%FT%TZ)"
if command -v jq >/dev/null 2>&1; then
  tmp=$(mktemp)
  jq --arg l "$L" --arg c "$C" --arg t "$T" '.completed_lessons = ((.completed_lessons + [$l]) | unique) | .current_lesson = $c | .last_updated = $t' .fspm/progress.json > "$tmp" && mv "$tmp" .fspm/progress.json
else
  python3 - "$L" "$C" "$T" <<'PY'
import json,sys
l,c,t = sys.argv[1:4]
p = ".fspm/progress.json"; d = json.load(open(p))
if l not in d.get("completed_lessons",[]): d.setdefault("completed_lessons",[]).append(l)
d["current_lesson"] = c; d["last_updated"] = t
json.dump(d, open(p,"w"))
PY
fi

Next lesson: /start-3-1-3

Version History

  • 058c617 Current 2026-07-23 00:54

Same Skill Collection

claude-code-everyone-course/course-materials/.claude/skills/start-1-1/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-2/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-3/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-4/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-5/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-6/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-7/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-1-8/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-2-1/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-2-2/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-2-3/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-2-4/SKILL.md
claude-code-everyone-course/course-materials/.claude/skills/start-2-5/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/auq/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/convert-doc/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/draft-and-humanize/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/draft-followups/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/humanizer/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/marketing-psychology/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/news/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/process-meetings-plus/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/standup/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/start-skills-1/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/start-skills-2/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/start-skills-3/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/start-skills-4/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/start-skills-5/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/write-proposal/SKILL.md
codex-for-pms-skills-bonus/.agents/skills/writing-voice/SKILL.md
codex-pm-course/.agents/skills/start-1-1/SKILL.md
codex-pm-course/.agents/skills/start-1-2/SKILL.md
codex-pm-course/.agents/skills/start-1-3/SKILL.md
codex-pm-course/.agents/skills/start-1-4/SKILL.md
codex-pm-course/.agents/skills/start-1-5/SKILL.md
codex-pm-course/.agents/skills/start-1-6/SKILL.md
codex-pm-course/.agents/skills/start-2-1/SKILL.md
codex-pm-course/.agents/skills/start-2-2/SKILL.md
codex-pm-course/.agents/skills/start-2-3/SKILL.md
codex-pm-course/.agents/skills/start-3-1/SKILL.md
codex-pm-course/.agents/skills/start-3-2/SKILL.md
codex-pm-course/.agents/skills/start-3-3/SKILL.md
codex-pm-course/.agents/skills/start-3-4/SKILL.md
codex-pm-course/.agents/skills/start-3-5/SKILL.md
course-materials/.claude/skills/pptx/SKILL.md
course-materials/.claude/skills/start-1-1/SKILL.md
course-materials/.claude/skills/start-1-2/SKILL.md
course-materials/.claude/skills/start-1-3/SKILL.md
course-materials/.claude/skills/start-1-4/SKILL.md
course-materials/.claude/skills/start-1-5/SKILL.md
course-materials/.claude/skills/start-1-6/SKILL.md

Metadata

Files
0
Version
058c617
Hash
b6cd3654
Indexed
2026-07-23 00:54

ホーム - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-07-29 13:12
浙ICP备14020137号-1 $お客様$