Home / All Skills / Workflow & Core Tools / codex-image-gallery
Workflow & Core Tools · daymade/claude-code-skills

codex-image-gallery

Start or reuse a self-contained local web gallery for browsing Codex-generated images. Use when the user asks to browse Codex generated images, open a local image gallery, inspect ~/.codex/generated_images, view a Codex image output folder, or browse image files produced by Codex.

L4 High-Privilege · Graded auth & full auditV1 Commit-PinnedExecute CommandNetwork AccessWrite FileDual-pass Audit
Author daymadeGitHub daymade/claude-code-skills ↗Stars 1385License MIT(仓库根 LICENSE;GitHub API spdx MIT)Commit d5c4678cb5
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

Self-contained local service: scripts/server.mjs is a pure Node stdlib HTTP server (zero third-party packages) bound to 127.0.0.1 on default port 8765, which automatically increments by +1 if occupied (up to +20); the UI template assets/index.html is served from the same directory.

daymade-codex/codex-image-gallery/SKILL.md
The server prints the actual URL. It starts at `http://127.0.0.1:8765/` and tries later ports if the default is occupied.
server.mjs: 'const HOST = process.env.HOST || "127.0.0.1"'; inside listen(): 'if (error.code === "EADDRINUSE" && port < DEFAULT_PORT + 20) { listen(port + 1); }'.

Only two API surfaces: GET /api/images recursively walks the image root directory and returns {rootPath, items[](path/mtime/size)} (sorted by mtime descending); GET /images/<rel> streams the image file—both enforce path traversal protection (safePath validates that the resolved path stays inside root).

daymade-codex/codex-image-gallery/scripts/server.mjs
if (fullPath !== root && !fullPath.startsWith(`${root}${path.sep}`)) { return null; }
/api/images includes 'cache-control: no-store'; /images/ rel is parsed via safePath after decodeURIComponent, returning 403 on violation. Default root is ~/.codex/generated_images, overridable via GALLERY_ROOT env.

'Reuse-first' protocol: probes the default URL via fetch /api/images first (reuses running server on success); if failed, runs pgrep to locate the process and tests subsequent ports; only launches a new server as the last resort—preventing multiple stacked instances per request.

daymade-codex/codex-image-gallery/SKILL.md
If this succeeds, reuse the running server at `http://127.0.0.1:8765/`.
SKILL workflow steps 1-4: probe → pgrep → verify & reuse by port → start server; 'Keep the process running for the user and read stdout for the URL.'

Frontend index.html renders grid/lightbox/batch tags via same-origin fetch('/api/images'), entirely powered by local data with zero third-party CDN/font/script dependencies.

daymade-codex/codex-image-gallery/assets/index.html
const response = await fetch("/api/images", { cache: "no-store" });
The page also provides local features like 'Open another folder' (directory picker in browser) + path copying; rendering escapes HTML via escapeHtml.

Verification path is automatically testable: node --check syntax + after startup check that /api/images returns items, /images/<rel> serves images, and index page comes from bundled index.html—SKILL explicitly requires running these three checks after code changes before claiming healthy.

daymade-codex/codex-image-gallery/SKILL.md
Before declaring the skill healthy after edits, run: `node --check scripts/server.mjs`
This is author's built-in 'must verify after changes' discipline, following the same philosophy as statusline-generator health checks.

2Core Capabilities

01Browse Codex-generated images (defaults to ~/.codex/generated_images, configurable via GALLERY_ROOT)
02Recursive directory listing + sorted by mtime + per-image serving (png/jpg/webp/gif)
03Probe and reuse running server instances (API check → pgrep → port increment search)
04In-browser batch browsing/filtering/lightbox/path copying (bundled single-file UI)
05Static file serving with path traversal protection

3External Dependencies

KindDependency / Endpoint
clinode(运行 server.mjs;SKILL 亦用 node -e fetch 做探测)
clipgrep(探测已有 server 进程)
cliopen(可选,打开浏览器到本地 URL)

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/: Execute local scripts or commands: node scripts/server.mjs (local HTTP service, pure stdlib)
  • 环境变量 / API Key: Read vendor service API keys: None
  • 本地工作目录: File I/O and artifact output: None (server only reads image directory and assets; does not write any files)
Audit Notes: Includes Node stdlib local scripts, listens strictly on loopback, makes no external requests, requires no credentials, and performs no disk writes; classified as blue under the guideline 'runs bundled local scripts, purely local I/O'. Caveat: Unauthenticated loopback HTTP exposes ~/.codex/generated_images to other local users/processes on the machine; modern browser PNA mitigates public web page direct connections, but local processes remain unrestricted—assess risks before running on shared machines.

5Second-Pass Verification

  • [ok] 绑定地址与端口递增 — server.mjs 'HOST = process.env.HOST || "127.0.0.1"' + 'error.code === "EADDRINUSE" && port < DEFAULT_PORT + 20'。
  • [ok] 路径穿越防护 — safePath resolve 后 prefix 校验,越界 403;decodeURIComponent 包 try/catch。
  • [ok] 无外发网络/第三方依赖 — server imports 仅 node:http/fs/os/path/url;index.html 外链扫描仅同源。
  • [ok] SKILL 探测复用协议可实现性 — fetch('/api/images')、pgrep pattern 'node .*server\.mjs' 与 server 实际进程命令行一致(node scripts/server.mjs)。
  • [ok] 鉴权缺失的暴露半径 — 代码无任何鉴权/CORS 头;暴露限于回环(本机)——已在 risk 记录;浏览器 PNA 缓解无法在源码验证,标注为宿主/浏览器行为。
  • [unlocatable] 真实浏览器端渲染验证 — index.html 视觉行为未在浏览器实测(本环境无 Codex 图片目录/浏览器),验证止于静态代码与 SKILL 自述。

6Verdict & Scenarios

  • Zero-dependency self-contained design (Node stdlib + single HTML), ready immediately upon clone
  • Reuse-first protocol saves resources and prevents multi-instance port stacking
  • Path traversal protection implemented at code level rather than relying on documentation promises
  • Built-in 3-step verification after code changes ensures grounded claims of being healthy
  • Best for: Ideal for local browsing/curation of Codex-generated images: agents can spin up a gallery during a session to let users review outputs, compare batches, and pick images; suitable for lightweight scenarios requiring zero third-party dependencies, purely local execution, and easy termination.
    Not for: Not suitable for multi-user shared machines (unauthenticated exposure is unacceptable) or setups requiring remote access (loopback bound only); not suitable for non-image assets, pipelines requiring thumbnails, or paginating huge directories (walkImages performs a full recursive scan without pagination); users with existing persistent gallery services can reuse URLs directly without launching this skill.
    Install Agent-Ready
    ① Verified Mirror 2026-09-09
    Option A · Direct DownloadDownload codex-image-gallery.tar.gz
    sha256: b2b0045b3baaf9a9…
    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 d5c4678cb5.