skills/batch-editor/SKILL.md
Bulk find/replace and frontmatter updates across Hugo posts.
npx skillsauth add notque/claude-code-toolkit batch-editorInstall 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.
Safe, reversible bulk modifications across Hugo blog posts using a Preview-Confirm-Apply pattern. Supports find/replace (literal or regex), frontmatter field operations (add/modify/remove), and content transforms (headings, links, whitespace, quotes). All operations are scoped to content/posts/*.md by default and limited to markdown files -- binary files, images, and files outside content/ are never touched.
/batch-edit [operation] [options]
Operations:
find-replace - Text replacement with optional regexfrontmatter - Add/modify/remove frontmatter fieldstransform - Content transformations (links, headings, whitespace, quotes)Common Options:
--dry-run - Validate pattern, show matches, don't apply--apply - Apply changes after preview confirmation--ignore-case - Case-insensitive matching (default is case-sensitive)--include-drafts - Also process draft posts (excluded by default)--scope <path> - Process different content directory (default: content/posts/)--regex - Enable regex mode for find-replace--force - Skip git safety checks (dangerous -- no rollback safety net)Before any batch operation, verify git status. Batch edits are irreversible without git, so this check exists to guarantee a rollback path.
cd $HOME/your-project && git status --porcelain
Analyze results:
| Status | Action | |--------|--------| | Empty (clean) | Proceed with operation | | Has changes | Warn user, suggest commit/stash first | | Not a git repo | Warn about no rollback capability |
Safety check output must include:
Gate: Git status is clean OR user provides --force. Do not proceed without passing this gate. Even when a few files are involved, uncommitted changes make rollback unreliable -- always verify.
The preview is mandatory and cannot be skipped. Users must see every individual change before any file is modified, because batch patterns frequently produce false positives that only a human can catch.
Step 1: Parse request
Extract from user request:
content/posts/*.md)Step 2: Find all matches
Use Grep to locate all matches within scope:
# For literal text
grep -rn "search-pattern" $HOME/your-project/content/posts/*.md
# For regex
grep -rn -E "regex-pattern" $HOME/your-project/content/posts/*.md
For frontmatter operations, read each file and parse the YAML frontmatter block between --- delimiters to check field presence and values.
Step 3: Generate preview
Show every match individually with context. Never summarize as "N matches in M files" without showing each one -- users cannot verify correctness from a count alone.
For each match, show:
Preview format for find-replace:
content/posts/example.md:
Line 5: "original text here"
-> "replacement text here"
Preview format for frontmatter:
content/posts/example.md:
+ author: "Author Name" (add)
- deprecated: "old" (remove)
~ tags: ["a"] -> ["a","b"] (modify)
Gate: Preview displayed with all matches visible. User must see every individual change.
Only proceed when user explicitly confirms with --apply or clear affirmative. Never auto-apply -- the user must opt in to every destructive operation.
All changes are atomic: validate that every target file is writable before modifying any of them. If any file would fail (permissions, disk space), abort the entire operation rather than leaving the repository in a partially edited state.
For find-replace:
For frontmatter add:
---For frontmatter modify:
For frontmatter remove:
Gate: All files written successfully. Show post-apply summary with per-file counts and rollback command.
After applying changes:
git checkout -- content/posts/git diff content/posts/ to review all changeshugo --quiet to verify site still buildsgit commit -am "batch edit: description" to save changesGate: Post-apply summary displayed with rollback instructions.
The transform operation supports these built-in transforms:
| Transform | Pattern | Replacement |
|-----------|---------|-------------|
| Demote headings | ^(#{1,5}) (.+)$ | #$1 $2 |
| Promote headings | ^##(#{0,4}) (.+)$ | #$1 $2 |
| Trailing whitespace | [ \t]+$ | (empty) |
| Multiple blank lines | \n{3,} | \n\n |
| Smart quotes to straight | [\u201C\u201D] | " |
| HTTP to HTTPS links | \[([^\]]+)\]\(http:// | [$1](https:// |
For custom transforms, use find-replace --regex with user-provided patterns. See references/regex-patterns.md for tested patterns.
Example 1: Simple Find/Replace User says: "Replace Hugo with Hugo SSG across all posts" Actions:
Example 2: Add Frontmatter Field User says: "Add author field to all posts that don't have one" Actions:
author field (SCAN)+ author: "Author Name" for each file, skip files that already have it (PREVIEW gate)--- in each file, preserving formatting (APPLY)Example 3: Content Transform User says: "Demote all H1 headings to H2" Actions:
^# (H1 pattern), show before/after per line (SCAN)# Introduction -> ## Introduction for each match (PREVIEW gate)^# (.+)$ -> ## $1 across matched files (APPLY)hugo --quiet to verify no build issues (VERIFY)
Result: All H1 headings demoted, H2+ unchangedExample 4: Regex with Dry Run User says: "Show me all date formats in posts but don't change anything" Actions:
(\d{4})-(\d{2})-(\d{2}) across posts (SCAN)See references/examples.md for full output format templates with banner formatting.
Cause: Pattern does not match any content in scope Solution:
Cause: Working directory has modifications that could be lost Solution:
git commit -am "backup before batch edit"git stashCause: Malformed regular expression syntax Solution:
\( \) \[ \]grep -E "pattern" content/posts/*.mdCause: Some files could not be written (permissions, disk space) Solution:
ls -la content/posts/git checkout -- content/posts/chmod 644 content/posts/*.md${CLAUDE_SKILL_DIR}/references/operation-types.md: Detailed operation syntax and options${CLAUDE_SKILL_DIR}/references/regex-patterns.md: Common regex patterns for Hugo content${CLAUDE_SKILL_DIR}/references/safety-checklist.md: Pre-edit validation steps and rollback procedures${CLAUDE_SKILL_DIR}/references/examples.md: Full output format templates and extended examplesdata-ai
Extract video transcripts: yt-dlp subtitles to clean paragraphs.
tools
Collect, filter, and freshness-qualify news items.
development
Convert PDF, Office, HTML, data, media, ZIP to Markdown.
testing
Verify factual claims against sources before publish.