Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .agents/skills/add-post-skill/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: add-post-skill
description: Create a new Jekyll blog post in _posts/ using the site's filename convention, required front matter, and a starter content shell.
---

# Add Post Skill

## When to use
Use this skill when asked to create, initialize, scaffold, or draft a new blog post for this site.

## Goal
Create a new Markdown file in `_posts/` that matches this repository's Jekyll conventions.

## Inputs
- title (required)
- description (optional)
- date (optional, YYYY-MM-DD)
- draft flag (optional)

## Implementation
Use the helper script:

```
scripts/new-post.sh "<title>" "<description>" "<date>"
```

## Behavior
- Slugify title (lowercase, hyphenated)
- Use provided date or default to current date
- If draft flag is set, create file in `_drafts/slug.md`
- Otherwise create `_posts/YYYY-MM-DD-slug.md`
- Validate slug is non-empty
- Quote YAML values safely
- Do not overwrite existing files

## Template

---
layout: post
title: "<TITLE>"
date: <YYYY-MM-DD>
description: "<OPTIONAL>"
---

Write your introduction here.

## Key points

-
-
-

## Details

## Closing

## Notes
- Permalinks handled by `_config.yml`
- Script available: `scripts/new-post.sh`
87 changes: 87 additions & 0 deletions scripts/new-post.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
set -euo pipefail

usage() {
echo 'Usage: scripts/new-post.sh [--draft] "Post Title" [description] [date]'
}

yaml_escape() {
local value="${1:-}"
value=${value//\\/\\\\}
value=${value//\"/\\\"}
printf '%s' "$value"
}

DRAFT=false

if [[ ${1:-} == "--draft" ]]; then
DRAFT=true
shift
fi

if [[ $# -lt 1 || $# -gt 3 ]]; then
usage
exit 1
fi

TITLE="$1"
DESCRIPTION="${2:-}"
DATE="${3:-$(date +%F)}"

if [[ ! "$DATE" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
echo "Invalid date: $DATE (expected YYYY-MM-DD)"
exit 1
fi

SLUG="$(printf '%s' "$TITLE" \
| tr '[:upper:]' '[:lower:]' \
| sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//; s/-+/-/g')"

if [[ -z "$SLUG" ]]; then
echo "Unable to generate slug from title: $TITLE"
exit 1
fi

if [[ "$DRAFT" == "true" ]]; then
DIR="_drafts"
FILE="${DIR}/${SLUG}.md"
else
DIR="_posts"
FILE="${DIR}/${DATE}-${SLUG}.md"
fi

mkdir -p "$DIR"

if [[ -e "$FILE" ]]; then
echo "Refusing to overwrite existing file: $FILE"
exit 1
fi

{
echo "---"
echo "layout: post"
printf 'title: "%s"\n' "$(yaml_escape "$TITLE")"
printf 'date: %s\n' "$DATE"
if [[ -n "$DESCRIPTION" ]]; then
printf 'description: "%s"\n' "$(yaml_escape "$DESCRIPTION")"
fi
echo "---"
echo
echo "Write your introduction here."
echo
echo "## Key points"
echo
echo "- Add your first point"
echo "- Add your second point"
echo "- Add your third point"
echo
echo "## Details"
echo
echo "Add the main body of the post here."
echo
echo "## Closing"
echo
echo "Wrap up with the takeaway or next step."
} > "$FILE"

echo "Created $FILE"