skills/codex-image/SKILL.md
Tạo/sửa ảnh bằng Codex CLI gpt-image-2. Trigger: generate image, icon, logo, banner, illustration, transparent, batch.
npx skillsauth add hoangvantuan/claude-plugin codex-imageInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Tạo và chỉnh sửa ảnh bằng OpenAI Codex CLI với model gpt-image-2.
npm install -g @openai/codexOPENAI_API_KEYimage_generation bật (mặc định từ v0.124.0)Kiểm tra nhanh:
codex --version
Nếu chưa cài, hướng dẫn user cài trước khi tiếp tục.
User mô tả ảnh → Craft prompt tối ưu → codex exec → Lưu file → Post-process (nếu cần)
codex exec --skip-git-repo-check --enable image_generation \
'$imagegen <PROMPT_MÔ_TẢ_ẢNH>. Save the final PNG as <TÊN_FILE>.png in <THƯ_MỤC_OUTPUT>.'
# Icon đơn giản
codex exec --skip-git-repo-check --enable image_generation \
'$imagegen A minimal flat-design coffee cup icon, white background, 1024x1024. Save as coffee-icon.png in current directory.'
# Banner phong cảnh
codex exec --skip-git-repo-check --enable image_generation \
'$imagegen A panoramic watercolor landscape of Mount Fuji at sunset, wide format 1792x1024. Save as fuji-banner.png in current directory.'
# Logo chữ
codex exec --skip-git-repo-check --enable image_generation \
'$imagegen A modern minimalist logo with the text "HELLO" in bold geometric sans-serif, dark navy on white, 1024x1024. Save as hello-logo.png in current directory.'
Built-in image_gen tool chỉ nhận tham số prompt. Mọi yêu cầu về kích thước, phong cách, chất lượng phải mô tả trong prompt.
Kích thước: Ghi rõ trong prompt. Ví dụ: "1024x1024 square format", "wide 1792x1024 landscape", "tall 1024x1792 portrait". Xem references/size-guide.md để chọn kích thước phù hợp.
Phong cách: Mô tả cụ thể style mong muốn. Ví dụ: "flat design", "watercolor", "photorealistic", "minimalist line art", "3D render".
Chất lượng text: gpt-image-2 render text tốt. Ghi rõ nội dung text và font style trong prompt.
Built-in tool không hỗ trợ transparent trực tiếp. Dùng quy trình chroma-key:
codex exec --skip-git-repo-check --enable image_generation \
'$imagegen <MÔ_TẢ_SUBJECT> on a solid bright green (#00FF00) background, no shadows on background, crisp edges. Save as raw-<TÊN>.png in current directory.'
Nếu subject có màu xanh lá, dùng nền magenta #FF00FF thay thế.
~/.venv/claude/bin/python skills/codex-image/scripts/remove-chroma-key.py \
raw-<TÊN>.png \
-o <TÊN>.png \
--color green
Script hỗ trợ --color green (mặc định) hoặc --color magenta. Kết quả là PNG với alpha channel.
Với subject có cạnh mờ (tóc, lông, khói, thủy tinh): chroma-key có thể để lại viền xanh. Trong trường hợp này:
--tolerance (mặc định 30, thử 40-50)Dùng script batch để tạo nhiều ảnh từ danh sách prompt:
~/.venv/claude/bin/python skills/codex-image/scripts/batch-generate.py \
--prompts "prompt 1" "prompt 2" "prompt 3" \
--output-dir ./output-images/ \
--prefix "batch"
~/.venv/claude/bin/python skills/codex-image/scripts/batch-generate.py \
--prompt-file prompts.txt \
--output-dir ./output-images/ \
--prefix "series"
Script gọi codex exec cho từng prompt, đặt tên file tự động: batch-001.png, batch-002.png, ...
Codex CLI hỗ trợ đưa ảnh tham chiếu vào context:
codex -i <ảnh_gốc.png> \
'$imagegen Modify this image: <MÔ_TẢ_THAY_ĐỔI>. Save as edited-output.png in current directory.'
Nhiều ảnh tham chiếu:
codex -i style-ref.png,content-ref.png \
'$imagegen Combine the style of the first image with the content of the second. Save as combined.png in current directory.'
-i đưa ảnh vào context để model "nhìn", nhưng built-in image_gen tool KHÔNG nhận ảnh input trực tiếpXem chi tiết tại references/prompt-guide.md. Tóm tắt:
[Subject chính] + [Style/Medium] + [Composition] + [Lighting] + [Color palette] + [Kích thước] + [Chi tiết bổ sung]
Kém: "a cat"
Tốt: "A fluffy orange tabby cat sitting on a windowsill, soft watercolor illustration style, warm afternoon sunlight streaming in, pastel color palette, 1024x1024 square format, detailed fur texture"
gpt-image-2 render chữ chính xác. Ghi rõ:
| Lỗi | Nguyên nhân | Giải pháp |
| --------------------------------- | ------------------------- | -------------------------------------------------------- |
| codex: command not found | Chưa cài Codex CLI | npm install -g @openai/codex |
| image_generation is not enabled | Feature chưa bật | Thêm flag --enable image_generation |
| Authentication required | Chưa đăng nhập | Chạy codex và đăng nhập ChatGPT |
| Ảnh không đúng kích thước | Model tự quyết kích thước | Ghi rõ kích thước trong prompt, ví dụ "1024x1024 square" |
| Text sai chính tả trong ảnh | Prompt chưa rõ | Đặt text trong ngoặc kép, ghi rõ spelling |
| Timeout | Prompt phức tạp | Chia nhỏ prompt, giảm chi tiết |
~/.codex/generated_images/tools
Bộ nhớ tri thức cấp dự án tự cải tiến: capture bài học, consolidate đúc kết, recall tra cứu + thực thi. Dữ liệu ghi vào memory/ ở gốc repo.
development
Phán quyết go/no-go + ưu tiên cho một hạng mục kỹ thuật, xác minh bằng chứng read-only trước khi kết luận.
tools
Viết/rà soát/tách user story, acceptance criteria, INVEST, epic, backlog từ requirement/PRD/bug/feature.
tools
Phân tích quyết định/vấn đề bằng Thu Giang Nguyễn Duy Cần: Thuật Tư Tưởng, Dịch Lý, Lão Trang, quân bình.