Set up the daily dotfiles branch from the current daily branch, clean up previous daily branches, and ensure a draft PR exists. Use when invoked as `$pr-daily` or when the user asks to start the daily dotfiles workflow.
89%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Set up today's daily branch from the current daily branch, clean up old daily branches, and ensure a draft PR exists.
Detect context:
remote=$(git remote | head -1)
dow=$(date +%A | tr '[:upper:]' '[:lower:]')
if [ "$dow" = "saturday" ] || [ "$dow" = "sunday" ]; then today="weekend"; else today="$dow"; fi
today_date=$(date +%Y-%m-%d)
default_branch=$(git symbolic-ref refs/remotes/${remote}/HEAD 2>/dev/null | sed "s|refs/remotes/${remote}/||" || echo "main")
current_branch=$(git branch --show-current)
source_branch=${current_branch}
echo "remote=${remote} dow=${dow} today=${today} date=${today_date} default=${default_branch} current=${current_branch} source=${source_branch}"Prune stale remote-tracking refs:
git fetch "${remote}" --pruneCheck for uncommitted changes. If dirty, show files and ask whether to commit, stash, or abort. Do not silently stash or discard.
Clean up previous daily branches named monday, tuesday, wednesday, thursday, friday, and weekend, skipping today's name and ${source_branch} so the source remains available until today's branch is created:
Keep ${source_branch} checked out as the base for today's branch. Do not switch to the default branch.
When the source differs from today, check whether that exact source branch exists on the remote. Treat the lookup status as a safety boundary:
0: Fetch and fast-forward the remote source before branching.2: The remote source is absent; intentionally continue with the local source branch.if test "${source_branch}" != "${today}"; then
source_remote_status=0
git ls-remote --exit-code --heads "${remote}" "${source_branch}" >/dev/null 2>&1 || source_remote_status=$?
case "${source_remote_status}" in
0)
git fetch "${remote}" "${source_branch}"
git merge --ff-only "${remote}/${source_branch}"
;;
2)
echo "Source branch '${source_branch}' is absent from '${remote}'; continuing with the local source branch."
;;
*)
echo "Failed to inspect source branch '${source_branch}' on '${remote}' (git ls-remote status ${source_remote_status}); stopping before branching." >&2
exit "${source_remote_status}"
;;
esac
fiIf the fast-forward fails because the local and remote source branches diverged, ask how to proceed rather than merging, rebasing, or force-pushing automatically.
Create or switch to today's branch:
git checkout "${today}"git checkout -b "${today}" "${remote}/${today}"git checkout -b "${today}" "${source_branch}"Establish or verify tracking. For new branches, push with:
git push -u "${remote}" "${today}:${today}"Ensure a draft PR exists:
gh pr list --head "${today}" --state open --json number,url --jq '.[0] | "\(.number)|\(.url)"'If no PR exists, compare a newly layered branch with its source. On a same-day rerun, compare with the default branch instead because ${source_branch} and ${today} are identical:
comparison_branch=${default_branch}
if [ "${source_branch}" != "${today}" ]; then
comparison_branch=${source_branch}
fi
git rev-list --count "${comparison_branch}..${today}"If the count is 0, create an empty marker commit so today's branch remains distinct after the source PR merges:
git commit --allow-empty -m "chore: start ${today} ${today_date}"
git push "${remote}" "${today}:${today}"Then create:
gh pr create --draft --base "${default_branch}" --assignee @me --title "chore: ${today} ${today_date}" --body "Daily dotfiles branch for ${today}, ${today_date}."The branch inherits ${source_branch}, while the PR continues to target ${default_branch}. The PR is cumulative until the source PR merges, then its diff shrinks to the newer changes.
Report branch, source branch, PR, pruned refs, cleaned branches, and branches intentionally left alone.
phatblat/dotfiles
4d65cab
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.