Skip to content

hancrafted/markdown-harness / .agents/skills/commit

Author a commit message and commit it — Conventional Commits header, Keep a Changelog body, Source trailer, enforced by a commit-time husky gate if setup (--setup-husky). Use before every `git commit`, whether a human or an agent initiates it, including a run split across commits.

FileKindSize
SKILL.mdskill md9.2 KB
assets/research.mdmarkdown13.1 KB
assets/setup-husky.mdmarkdown6.7 KB
scripts/commit-msgexecutablescript3.9 KB
scripts/lib/git.shscript2.3 KB
scripts/lib/hook.shscript1.9 KB
scripts/lib/report.shscript2.6 KB
scripts/lib/rules.shscript6.0 KB
scripts/setup-huskyexecutablescript5.0 KB

scripts/setup-husky

View on GitHub
#!/bin/sh
# Wires this repository's `commit-msg` git hook to the gate that ships with the
# `commit` skill. Backs `/commit --setup-husky`.
#
# Idempotent: running it twice leaves the same result and says so. Every change
# is reported, so the result can be reviewed before it is committed.
#
# Reads no arguments. Run it from anywhere inside the target repository.

set -u

script_dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
. "$script_dir/lib/rules.sh"
. "$script_dir/lib/git.sh"
. "$script_dir/lib/report.sh"
. "$script_dir/lib/hook.sh"

changes=''
note_change() {
  changes="$changes  • $1
"
}

root=$(git rev-parse --show-toplevel 2>/dev/null) || root=''
if [ -z "$root" ]; then
  gate_abort 'not inside a git repository' 'Run this from the repository you want to gate.'
fi
cd "$root" || gate_abort "cannot enter $root"

# The gate has to be reachable from the committed tree, or the hook is a dead
# link for every other clone and for CI.
gate=''
for candidate in $(gate_candidate_paths); do
  if [ -f "$candidate" ]; then
    gate=$candidate
    break
  fi
done
if [ -z "$gate" ]; then
  gate_abort 'cannot find the commit gate — refusing to write a hook that would not run' \
    "looked for: $GATE_INSTALLED_PATH" \
    "       and: $GATE_REPO_PATH" \
    'Install the skill at project scope:  npx skills add hancrafted/skills' \
    'The likeliest cause is an install performed with --copy, which gives each agent its' \
    'own copy and destroys the single canonical path this hook depends on.'
fi

# husky is a Node dev dependency; without a package.json there is nothing to
# hang it off.
if [ ! -f package.json ]; then
  gate_abort 'no package.json — husky cannot be installed here' \
    'The gate itself needs only POSIX shell and git, so a non-Node repository can still use it:' \
    "  git config core.hooksPath .githooks   &&   mkdir -p .githooks" \
    "  then create .githooks/commit-msg containing:  exec sh $gate \"\$1\"" \
    'See assets/setup-husky.md for the full manual wiring.'
fi

# 1. husky itself.
if [ ! -d .husky/_ ]; then
  if [ ! -d node_modules/husky ]; then
    printf 'Installing husky…\n'
    npm install --save-dev husky >/dev/null || gate_abort 'npm install --save-dev husky failed'
    note_change 'installed husky as a dev dependency'
  fi
  npx husky >/dev/null 2>&1 || gate_abort 'npx husky failed to initialise .husky/'
  note_change 'initialised .husky/'
fi

# `prepare` is what re-wires hooks on a fresh clone, so it is checked even when
# .husky/ already exists — otherwise the gate silently stops running for everyone
# who clones next. An existing `prepare` is never clobbered.
#
# Read through npm rather than grepping the file: `"prepare"` appears in plenty of
# nested tool config, and a false match here means the hooks quietly stop wiring.
# An existing `prepare` that skips husky gets a warning for the same reason: left
# silent, the gate dies on the next fresh clone.
_setup_prepare=$(npm pkg get scripts.prepare 2>/dev/null)
if [ "$_setup_prepare" = '{}' ]; then
  npm pkg set scripts.prepare=husky >/dev/null || gate_abort 'npm pkg set scripts.prepare=husky failed'
  note_change 'set the package.json `prepare` script to `husky`'
elif ! printf '%s' "$_setup_prepare" | grep -q husky; then
  gate_warn \
    "the existing package.json \`prepare\` script ($_setup_prepare) never runs husky, so the hook will not wire on a fresh clone." \
    'Keep it, and put husky in front:  npm pkg set "scripts.prepare=husky && <existing>"'
fi

# 2. The hook, whose body is shared with the TypeScript AI harness so both paths
#    judge commits identically.
mkdir -p .husky || gate_abort 'could not create .husky/'
desired=$(gate_hook_body)
existing=''
if [ -f .husky/commit-msg ]; then
  existing=$(cat .husky/commit-msg)
fi
if [ "$desired" != "$existing" ]; then
  printf '%s\n' "$desired" >.husky/commit-msg || gate_abort 'could not write .husky/commit-msg'
  chmod +x .husky/commit-msg || gate_abort 'could not make .husky/commit-msg executable'
  if [ -n "$existing" ]; then
    note_change "rewrote .husky/commit-msg to delegate to $gate"
  else
    note_change "wrote .husky/commit-msg, delegating to $gate"
  fi
fi

# 3. The comment character. Without this the gate passes a compliant message and
#    git's own cleanup then deletes the body's `### <category>` headings, because
#    they begin with the default comment character. The commit would look right
#    at commit time and be stored unmineable.
comment_string=$(git_comment_string)
if rules_comment_string_eats_headings "$comment_string"; then
  git config core.commentChar ';' || gate_abort 'could not set core.commentChar'
  note_change "set core.commentChar to ';' (was '$comment_string') so '### ' headings survive git cleanup"
fi

if [ -z "$changes" ]; then
  printf '✔ commit gate already wired via husky — unchanged.\n'
  exit 0
fi

printf '✔ commit gate wired via husky.\n\nChanged:\n%s\n' "$changes"
printf 'Commit .husky/commit-msg so the gate runs for every clone and in CI.\n'
printf 'core.commentChar is local to this clone; it is not committed.\n'
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 464kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 196kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 196kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 196kUpdated Claude CodeCodexVerifiedInstall