| name | next-issue-number |
| description | Determine the next available issue number across all change types (feature, fix, workflow) by checking both local docs and remote branches, then reserve it by pushing an empty branch. |
Skill Instructions
Purpose
Ensure unique issue numbering across all change types (feature, fix, workflow) by:
- Finding the highest number used in local docs folders (docs/features/, docs/issues/, docs/workflow/)
- Finding the highest number used in remote branches on GitHub (feature/NNN-, fix/NNN-, workflow/NNN-*)
- Finding the highest number used in recent
copilot/* remote branches (less than one week old)
- Calculating the next available number (max + 1)
- Immediately pushing the new branch to GitHub to reserve the number for other agents
This prevents duplicate issue numbers when multiple agents work concurrently or when work-in-progress exists on remote branches but not yet in main.
Session Start Hook
A sessionStart hook (.github/hooks/session-start.json) automatically runs scripts/next-issue-number.sh when a new agent session begins and writes the result to .next-issue-number. This means the next issue number is pre-calculated for you at session start.
Read the pre-calculated value first (fast, no network call required):
if [ -f .next-issue-number ]; then
NEXT_NUMBER=$(cat .next-issue-number)
else
NEXT_NUMBER=$(scripts/next-issue-number.sh)
fi
echo "Next issue number: $NEXT_NUMBER"
The .next-issue-number file is gitignored and refreshed each session. If it is missing or stale, fall back to running the script directly.
Hard Rules
Must
Must Not
Golden Example
if [ -f .next-issue-number ]; then
NEXT_NUMBER=$(cat .next-issue-number)
else
NEXT_NUMBER=$(scripts/next-issue-number.sh)
fi
echo "Next issue number: $NEXT_NUMBER"
git fetch origin && git switch main && git pull --ff-only origin main
git switch -c feature/${NEXT_NUMBER}-my-feature-name
git push -u origin HEAD
Actions
For Requirements Engineer (New Features)
- Before creating a feature branch, get the next number:
if [ -f .next-issue-number ]; then
NEXT_NUMBER=$(cat .next-issue-number)
else
NEXT_NUMBER=$(scripts/next-issue-number.sh)
fi
- Update and switch to main:
git fetch origin && git switch main && git pull --ff-only origin main
- Create the feature branch with the determined number:
git switch -c feature/${NEXT_NUMBER}-<short-description>
- IMMEDIATELY push the branch to reserve the number:
git push -u origin HEAD
- Proceed with gathering requirements and creating the specification
For Issue Analyst (Bug Fixes)
- Before creating a fix branch, get the next number:
if [ -f .next-issue-number ]; then
NEXT_NUMBER=$(cat .next-issue-number)
else
NEXT_NUMBER=$(scripts/next-issue-number.sh)
fi
- Update and switch to main:
git fetch origin && git switch main && git pull --ff-only origin main
- Create the fix branch with the determined number:
git switch -c fix/${NEXT_NUMBER}-<short-description>
- IMMEDIATELY push the branch to reserve the number:
git push -u origin HEAD
- Proceed with issue investigation and analysis
For Workflow Engineer (Workflow Improvements)
- Before creating a workflow branch, get the next number:
if [ -f .next-issue-number ]; then
NEXT_NUMBER=$(cat .next-issue-number)
else
NEXT_NUMBER=$(scripts/next-issue-number.sh)
fi
- Update and switch to main:
git fetch origin && git switch main && git pull --ff-only origin main
- Create the workflow branch with the determined number:
git switch -c workflow/${NEXT_NUMBER}-<short-description>
- IMMEDIATELY push the branch to reserve the number:
git push -u origin HEAD
- Proceed with workflow improvements
Troubleshooting
If GitHub authentication fails
The script will fall back to checking only local docs folders and warn you:
Warning: Could not fetch from GitHub. Using local data only.
Next available number based on local docs: 033
In this case, manually verify on GitHub that no higher numbers exist in remote branches.
If the calculated number already exists
The script checks local docs, named branches, and recent copilot/* branches. If it still returns a number that exists:
- Verify the script ran correctly:
scripts/next-issue-number.sh
- Check if someone pushed a new branch since you ran the script
- Delete your branch and re-run the script to get a fresh number
Verification
After running the script and pushing your branch:
- Verify the branch exists on GitHub:
git ls-remote origin | grep "refs/heads/\(feature\|fix\|workflow\)/${NEXT_NUMBER}-"
- Confirm no docs folder exists yet:
ls -d docs/{features,issues,workflow}/${NEXT_NUMBER}-* 2>/dev/null (should be empty)