jianshuo/claude-skills / wjs-publishing-wechat
wjs-publishing-wechat
Unverified当用户想写或发布微信公众号文章时使用——他们给出零散思路、草稿或笔记,请你润色、生成题图和解释图,或准备上传到 mp.weixin.qq.com。触发词:"写一篇微信文章"、"公众号"、"润色"、"题图"、"发公众号"、"/wjs-publishing-wechat"。
| File | Kind | Size |
|---|---|---|
| .gitignore | other | 65 B |
| .publish-manifest.json | config | 13.2 KB |
| LICENSE | other | 1.0 KB |
| README.md | markdown | 4.7 KB |
| SKILL.md | skill md | 14.2 KB |
| STYLE.md | markdown | 10.8 KB |
| prompts/cover-prompt.md | markdown | 20.6 KB |
| prompts/illustration-prompt.md | markdown | 2.8 KB |
| scripts/backfill-permalinks.pyexecutable | script | 9.3 KB |
| scripts/build-recent-articles.pyexecutable | script | 5.5 KB |
| scripts/fetch-comments-by-cookie.shexecutable | script | 12.2 KB |
| scripts/fetch-comments-via-gstack.shexecutable | script | 10.8 KB |
| scripts/fetch-comments.shexecutable | script | 5.4 KB |
| scripts/gen-cover-ai.shexecutable | script | 3.8 KB |
| scripts/gen-illustration.shexecutable | script | 3.0 KB |
| scripts/mass-send.shexecutable | script | 7.2 KB |
| scripts/open-draft-edit.shexecutable | script | 5.3 KB |
| scripts/pangu.py | script | 2.9 KB |
| scripts/update-draft-via-api.pyexecutable | script | 3.9 KB |
| scripts/upload-draft.shexecutable | script | 19.4 KB |
scripts/gen-cover-ai.sh
View on GitHub#!/usr/bin/env bash
# Generate WeChat 公众号 cover via gpt-image-2-skill.
#
# Strategy:
# - Read cover-prompt.md (long design prompt with [目标字词] placeholder)
# - Pass it as --instructions (gpt-5.4 distills it into a focused image prompt)
# - Pass a short generation directive as --prompt
# - Output 1536x1024, then sips-crop to 900x383 (2.35:1 微信主封面)
#
# Provider: forced --provider codex (requires ~/.codex/auth.json). The OpenAI
# API key path is intentionally NOT supported — --instructions is codex-only,
# and direct API calls bypass Codex's prompt distillation.
#
# Usage:
# gen-cover-ai.sh <article-folder> [target-word]
set -euo pipefail
ARTICLE_DIR="${1:-}"
WORD_OVERRIDE="${2:-}"
if [[ -z "$ARTICLE_DIR" || ! -d "$ARTICLE_DIR" ]]; then
echo "usage: gen-cover-ai.sh <article-folder> [target-word]" >&2
exit 2
fi
ARTICLE_DIR="$(cd "$ARTICLE_DIR" && pwd)"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" # scripts/ → skill root
TEMPLATE="$SKILL_DIR/prompts/cover-prompt.md"
WRAPPER="$HOME/.claude/skills/gpt-image-2-skill/scripts/gpt_image_2_skill.cjs"
if [[ ! -f "$TEMPLATE" ]]; then
echo "error: prompt template missing: $TEMPLATE" >&2
exit 1
fi
if [[ ! -f "$WRAPPER" ]]; then
echo "error: gpt-image-2-skill wrapper not found at $WRAPPER" >&2
echo " install: git clone https://github.com/Wangnov/gpt-image-2-skill /tmp/g && \\" >&2
echo " cp -r /tmp/g/skills/gpt-image-2-skill ~/.claude/skills/" >&2
exit 1
fi
# Determine target word
WORD="$WORD_OVERRIDE"
if [[ -z "$WORD" && -f "$ARTICLE_DIR/meta.json" ]]; then
WORD=$(python3 -c "import json,sys; print((json.load(open(sys.argv[1])).get('title') or '').strip())" "$ARTICLE_DIR/meta.json")
fi
if [[ -z "$WORD" ]]; then
echo "error: no target word (pass as 2nd arg or have meta.json with title)" >&2
exit 1
fi
# Build instructions from template
INSTRUCTIONS=$(python3 -c "
import sys
template = open(sys.argv[1]).read()
print(template.replace('[目标字词]', sys.argv[2]))
" "$TEMPLATE" "$WORD")
# Short generation directive (the model will use instructions as design philosophy)
GEN_PROMPT="为「${WORD}」生成一张顶级字体美学概念图像。严格遵守 instructions 中的所有原则——文字必须绝对突出、字形准确、隐喻系统围绕文字、画幅比例适合 2.35:1 微信公众号主封面横版裁切。"
RAW_OUT="$ARTICLE_DIR/cover-raw.png"
COVER_OUT="$ARTICLE_DIR/cover.png"
SIZE="${WECHAT_PUBLISH_IMAGE_SIZE:-1536x1024}"
QUALITY="${WECHAT_PUBLISH_IMAGE_QUALITY:-high}"
echo "calling gpt-image-2-skill (target: '$WORD', size: $SIZE, quality: $QUALITY)" >&2
# Codex-only: --instructions is supported solely by the codex provider, and we
# do not allow OPENAI_API_KEY fallback. ~/.codex/auth.json must exist.
cd "$HOME/.claude/skills/gpt-image-2-skill"
RESULT=$(node "$WRAPPER" --json --provider codex images generate \
--instructions "$INSTRUCTIONS" \
--prompt "$GEN_PROMPT" \
--out "$RAW_OUT" \
--size "$SIZE" \
--format png \
--quality "$QUALITY" 2>&1) || {
echo "image generation failed:" >&2
echo "$RESULT" | tail -20 >&2
exit 1
}
if [[ ! -s "$RAW_OUT" ]]; then
echo "error: no image written to $RAW_OUT" >&2
echo "$RESULT" | tail -20 >&2
exit 1
fi
echo "raw image: $RAW_OUT" >&2
# Crop to 900x383 (sips on macOS): scale width to 900, then center-crop height to 383
TMP_SCALED="$ARTICLE_DIR/.cover-scaled.tmp.png"
sips --resampleWidth 900 "$RAW_OUT" --out "$TMP_SCALED" >/dev/null
sips -c 383 900 "$TMP_SCALED" --out "$COVER_OUT" >/dev/null
rm -f "$TMP_SCALED"
# Record what was used
{
echo "target_word: $WORD"
echo "size: $SIZE"
echo "quality: $QUALITY"
echo "via: gpt-image-2-skill (codex provider only)"
echo "generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
} > "$ARTICLE_DIR/cover-prompt-used.txt"
echo "cover ready: $COVER_OUT (900x383)" >&2
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |