kit/plugins/social-media-tools/skills/share-selection/SKILL.md
Turns selected or pasted code into a platform-aware social card. Scrubs, picks a template, and screenshots via Playwright. Use when asked to share, post, or tweet highlighted or pasted code.
npx skillsauth add shawn-sandy/agentics share-selectionInstall 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.
Turn code the user selected, highlighted, opened, or pasted into platform-aware social
media copy and a styled dark-mode card image for any supported platform (see
$PLUGIN_DIR/references/platforms.md) — with the copy shaped by the user's stated objective.
This skill is selection-driven: it shares a specific piece of code the user points at. It
does not scan git history — that is code-share's job.
| Phase | Action |
|-------|--------|
| 0 — Locate | Locate templates/ and derive PLUGIN_DIR |
| 1 — Capture | Detect selected/open/pasted code + the post objective |
| 1c — Reuse check | Scan docs/media/social/ for existing posts; offer reuse |
| 2 — Scrub | Run security-scrub on the code before sharing |
| 3 — Draft | Write platform-aware copy that serves the objective |
| 4 — Pick template | diff-like → diff-card, otherwise snippet-card |
| 5 — Populate | Read template, substitute {{VARIABLES}} including {{COPY_PANELS}} |
| 5b — Save | Persistent save to docs/media/social/ |
| 6 — Screenshot | Serve HTML locally, Playwright screenshot |
| 7 — Deliver | Present copy + attach PNG + show saved path |
ExitPlanMode is a deferred tool. Only call it if currently in plan mode — skip this step entirely when not in plan mode. When calling: use ToolSearch with select:ExitPlanMode first, then call ExitPlanMode silently.
Run silently:
[ -n "${CLAUDE_PLUGIN_ROOT}" ] && [ -d "${CLAUDE_PLUGIN_ROOT}/templates" ] && \
echo "${CLAUDE_PLUGIN_ROOT}/templates"
find ~/.claude/plugins -path "*/social-media-tools/templates" -type d 2>/dev/null | head -1
find ~/.claude -path "*/social-media-tools/templates" -type d 2>/dev/null | head -1
Use the first non-empty result as TEMPLATES_DIR. Derive:
PLUGIN_DIR=$(dirname "$TEMPLATES_DIR")
If no directory is found: output "Templates not found. Install the plugin or load it with --plugin-dir." and STOP.
LINE_RANGE to the highlighted range (e.g. "L42–L58").FILENAME and the language from the real path/extension.```python) when present.Capture for later phases: the code text (CODE_RAW), a filename/path hint, a language hint,
and a line range when known.
package-lock.json/*.lock, minified
bundle, or anything that isn't human-readable source): do not render it. Tell the user
what was selected and ask them to pick a code file or paste a snippet instead. STOP.snippet-card caps at ~80 lines (Phase 5). (Interactive mode) If the
source exceeds 80 lines, use AskUserQuestion to ask which region to feature (a line range,
function, or section), then use only that range. Do not silently truncate or render the
whole file. (Background mode) use the first 80 lines without asking.If none of the three sources yields code, ask the user to paste or select the code to share. Do not fall back to git history.
Determine OBJECTIVE — what the user wants the post to accomplish or emphasize:
OBJECTIVE = "highlight the performance win").AskUserQuestion that collects PLATFORM
(see Platform Options in $PLUGIN_DIR/references/platforms.md) and TONE.FILE_PREFIX=<snippet or diff> # set after Phase 4's template decision; default snippet
Read $PLUGIN_DIR/references/reuse-check.md and follow its procedure.
Selected/pasted code is untrusted and about to be published. Write it to a temp file:
Write to: ~/.claude/tmp/scrub-input.txt
Content: CODE_RAW (plain text, no HTML escaping yet)
Then invoke:
Skill(skill: "social-media-tools:security-scrub", args: "Scan the file at ~/.claude/tmp/scrub-input.txt for secrets before sharing.")
Check the returned GATE RESULT line (the gate runs inside security-scrub):
GATE RESULT: BLOCKED or GATE RESULT: CANCELLED → STOP. Do not proceed to Phase 3.GATE RESULT: APPROVED → proceed to Phase 3.GATE RESULT → STOP and report an error (treat as gate failure).Read $PLUGIN_DIR/references/platforms.md for character limits, tone defaults, the
Instructional Voice doctrine, Learn-More CTA rule, Default Per-Platform Copy
Formats, and Draft Copy — Standard Procedure.
Takeaway-first: every post must surface a concrete, applicable takeaway — what the reader can learn or apply from this code (a pattern, technique, or design principle). The snippet is evidence for the lesson, not the headline.
Draft copy that serves OBJECTIVE within each platform's limit and the chosen tone:
Inspect CODE_RAW:
+ / -, it contains @@ … @@ hunk headers, or it
was pasted in a ```diff fence → use diff-card.html, FILE_PREFIX=diff.snippet-card.html, FILE_PREFIX=snippet.CARD_TYPE=<diff or snippet>
TEMPLATE_FILE=$TEMPLATES_DIR/${CARD_TYPE}-card.html
TEMP_HTML=share-selection-card.html
SLUG_INPUT=<FILENAME or a short title for the snippet>
Read TEMPLATE_FILE. For the variable reference, read $PLUGIN_DIR/references/variables.md.
For {{COPY_PANELS}} markup and escaping, read $PLUGIN_DIR/references/copy-panels.md.
Apply to the code content in this exact order, storing the result as CODE_LINES_ESCAPED:
& → & ← first, to prevent double-escaping< → <> → >" → "Derive LANGUAGE (lowercase hljs alias) and LANGUAGE_COLOR (hex) from the file
extension or fence tag via $PLUGIN_DIR/references/language-map.md.
| Template variable | Value |
|-------------------|-------|
| {{FILENAME}} | Basename of the selected file (HTML-escaped); else snippet.<ext> / snippet.txt |
| {{LANGUAGE}} | Lowercase hljs alias (e.g. typescript, python, csharp, cpp, bash) |
| {{LANGUAGE_COLOR}} | Hex from references/language-map.md only |
| {{CODE_LINES}} | CODE_LINES_ESCAPED |
| {{LINE_RANGE}} | Highlighted/selected range (e.g. "L42–L58"); else "selected lines" |
| {{REPO_SLUG}} | Local repo slug from git remote get-url origin parsed to owner/repo; fallback the repo directory name; else empty string |
| {{GITHUB_URL}} | Empty string for local selections (footer link renders blank) |
Convert CODE_RAW into hunk rows and fill the diff-card variables per the diff-card.html
section of $PLUGIN_DIR/references/variables.md (row format, {{STAT_ADD}}/{{STAT_DEL}},
{{COPY_PANELS}}). {{FILENAME}} is the selected file name or a short title.
Write the populated HTML to ~/.claude/tmp/share-selection-card.html:
mkdir -p ~/.claude/tmp
Variables already set: FILE_PREFIX, SLUG_INPUT, TEMP_HTML.
Read $PLUGIN_DIR/references/saving-and-delivery.md — Persistent Save section.
Read $PLUGIN_DIR/references/rendering-pipeline.md and follow the full pipeline.
Read $PLUGIN_DIR/references/saving-and-delivery.md — Deliver section.
development
Checks whether the branch's PR is ready and merges it when green. Runs the readiness gate, lint, and an approval prompt. Use when the user asks "merge?" or if a PR is ready to merge.
development
Implements a plan file that already exists. Walks its steps, ticks the spec, re-renders, and runs the completion gates. Use when asked to implement an existing plan.
development
Audits and optimizes CLAUDE.md project memory files. Checks adherence to Claude Code best practices and produces actionable fixes. Use when the user asks to audit, optimize, or diagnose a CLAUDE.md.
development
Converts an HTML artifact or Markdown file into a draft post for a static site. Scopes CSS to keep interactive blocks alive and escapes prose for MDX. Use when asked to turn an artifact into a post.