9thlevelsoftware/legion/github-sync

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

GitHub integration — issue tracking, PR creation, milestone sync, and status readback via gh CLI

Install

npx vskill@latest install 9thlevelsoftware/legion/github-sync

SKILL.md

GitHub Sync

GitHub operations engine for Legion. Provides issue creation linked to phases, PR creation after phase execution, milestone synchronization with ROADMAP.md, and live status readback for the dashboard. All operations require the gh CLI and a GitHub remote, and all operations degrade gracefully when unavailable.

References:

  • State File Locations from workflow-common.md (state paths, degradation pattern)
  • Commit Conventions from execution-tracker.md (commit format, phase lifecycle)
  • Milestone format from milestone-tracker.md (milestone naming, phase ranges)
  • .planning/STATE.md — stores GitHub linking metadata (issue/PR numbers per phase)

Section 1: Prerequisites & Detection

How to check if GitHub operations are available. This check MUST be run before ANY GitHub operation in a session.

GitHub Availability Check (run before ANY GitHub operation):
Step 1: Check gh CLI authentication
Command: gh auth status 2>&1
- If exit code 0: gh is authenticated, proceed
- If non-zero: GitHub unavailable, skip all operations silently
Step 2: Check for GitHub remote
Command: git remote get-url origin 2>/dev/null
- If exit code 0: remote exists, proceed
- If non-zero: no remote, skip all operations silently
Step 3: Get repo metadata (cache for session)
Command: gh repo view --json nameWithOwner,defaultBranch -q '.nameWithOwner + " " + .defaultBranch'
- Parse: REPO_SLUG = first token, DEFAULT_BRANCH = second token
- Cache these values — do not re-query within the same command run
The result of this check is a boolean: github_available = true/false
All subsequent sections assume this check has been performed.
If github_available is false, the calling workflow skips the GitHub section entirely.
Constants

These values are used throughout all GitHub operations:

LEGION_LABEL = "legion"
LEGION_LABEL_COLOR = "7B68EE"
LEGION_LABEL_DESCRIPTION = "Created by Legion"
BRANCH_PREFIX = "legion/phase-"

The label color 7B68EE (medium slate blue) provides a distinct visual marker in the GitHub issue tracker, making Legion-created issues easy to identify at a glance.

Session Caching

Once the prerequisites check passes, cache the following values for the duration of the command run:

Cached ValueSourceExample
github_availableSteps 1-2 resulttrue
REPO_SLUGStep 3 first tokenuser/legion
DEFAULT_BRANCHStep 3 second tokenmain

Do NOT re-run the prerequisites check within the same command invocation. The cached values are valid for the entire session.


Section 2: Issue Management (GH-01)

Creating and managing GitHub issues linked to Legion phases. Each phase gets one tracking issue with a checklist of its plans.

2.1: Ensure Label Exists

Before the first issue creation in a session, ensure the "legion" label exists on the repository:

Command: gh label create legion --description "Created by Legion" --color 7B68EE 2>/dev/null

This command is idempotent — if the label already exists, gh returns a non-zero exit code but creates nothing. The 2>/dev/null suppresses the "already exists" error message. Do not check for the label's existence first; the create command handles both cases.

Run this once per session, before the first gh issue create call. Track with a session flag to avoid re-running on subsequent issue creations within the same command.

2.2: Create Phase Issue

Creates a GitHub issue that tracks all plans within a phase.

Input: phase_number, phase_name, phase_goal, plans_list, requirements, success_criteria
Output: issue_number (integer)
Command:
gh issue create \
--title "Phase {phase_number}: {phase_name}" \
--body "{ISSUE_BODY}" \
--label "legion" \
{--milestone "MILESTONE_TITLE" if a GitHub milestone exists for the current ROADMAP milestone}
ISSUE_BODY format:
## Goal
{phase_goal}
## Plans
- [ ] Plan {NN}-01: {plan_1_name}
- [ ] Plan {NN}-02: {plan_2_name}
- [ ] Plan {NN}-03: {plan_3_name}
## Requirements
{requirement_ids, comma-separated}
## Success Criteria
{success_criteria as bullet list}
---
*Created by Legion*
Capture issue number:
Parse the URL returned by gh issue create — the last path segment is the issue number.
Example: https://github.com/user/repo/issues/42 → issue_number = 42
Fallback: gh issue list --label legion --state open --json number,title -q '.[0].number'

The --milestone flag is only included if a GitHub milestone has already been created for the corresponding ROADMAP milestone (see Section 4). If no milestone exists on GitHub, omit the flag entirely — do not create the milestone as a side effect of issue creation.

2.3: Close Phase Issue

Closes a phase issue after the phase passes review.

Input: issue_number, comment_text
Command:
gh issue close {issue_number} --comment "{comment_text}"

The comment should summarize the phase outcome. Typical format:

Phase completed successfully.
- Plans executed: {count}
- Requirements satisfied: {req_ids}
- Review result: {pass/escalated}

If the issue is already closed (e.g., closed manually by the user), gh issue close is a no-op. Do not treat this as an error.

2.4: Update Issue Checklist

After a plan completes during /legion:build, update the phase issue's checklist to reflect progress.

Step 1: Read current issue body
Command: gh issue view {issue_number} --json body -q .body
Step 2: Find and update the plan checkbox
- Locate the line: "- [ ] Plan {NN}-{PP}: {plan_name}"
- Replace with: "- [x] Plan {NN}-{PP}: {plan_name}"
- If the line is not found (already checked or not present): skip silently
Step 3: Write updated body
Command: gh issue edit {issue_number} --body "{updated_body}"
Step 4: Verify (optional)
- If the edit command succeeds (exit code 0): proceed
- If it fails: log the error, continue the build — checklist update is cosmetic

The checklist update is a progress indicator, not a critical operation. Build execution must never block or fail because a checklist update did not succeed.


Section 3: PR Creation (GH-02)

Creating pull requests after phase execution completes. PRs are created against the default branch and reference the phase issue if one exists.

3.1: Branch Management

Ensure the current work is on an appropriate branch before creating a PR.

Step 1: Check current branch
Command: git branch --show-current
- If result equals DEFAULT_BRANCH (from Section 1):
Create feature branch: git checkout -b {BRANCH_PREFIX}{NN}-{slug}
Example: git checkout -b legion/phase-03-phase-planning
The slug is the phase name in kebab-case, truncated to 40 characters.
- If result is NOT the default branch:
Use the current branch as-is (the user or a previous workflow created it)
Step 2: Check for unpushed commits
Command: git log origin/{current_branch}..HEAD --oneline 2>/dev/null
- If the remote tracking branch doesn't exist: all local commits are unpushed
- Count unpushed commits for the PR description
- If zero unpushed commits: abort PR creation — nothing to submit
Step 3: Push to remote
Command: git push -u origin {current_branch}
- The -u flag sets upstream tracking for future pushes
- If push fails: report error, do NOT create PR
- Common push failures: permission denied, remote rejected, network error
3.2: Create Phase PR

Creates the pull request with a structured body that summarizes the phase.

Input: phase_number, phase_name, phase_goal, plan_summaries[], files_modified[],
requirements[], issue_number (optional)
Output: pr_number, pr_url
Command:
gh pr create \
--title "Phase {phase_number}: {phase_name}" \
--body "{PR_BODY}" \
--base {DEFAULT_BRANCH}
PR_BODY format:
## Summary
{phase_goal}
## Changes
### New Files
- {new_file_1}
- {new_file_2}
### Modified Files
- {modified_file_1}
- {modified_file_2}
## Plans Executed
| Plan | Wave | Status | Summary |
|------|------|--------|---------|
| {NN}-01 | 1 | Pass | {one-line from SUMMARY.md} |
| {NN}-02 | 1 | Pass | {one-line from SUMMARY.md} |
| {NN}-03 | 2 | Pass | {one-line from SUMMARY.md} |
## Requirements Satisfied
- {REQ-01}: {description}
- {REQ-02}: {description}
{If issue_number exists: "Closes #{issue_number}"}
---
*Created by Legion*
Capture PR number:
Parse from the gh pr create output URL.
Example: https://github.com/user/repo/pull/15 → pr_number = 15

The Closes #{issue_number} line uses GitHub's automatic issue closing — when the PR is merged, the referenced issue is closed automatically. Only include this line if a phase issue exists.

3.3: PR Creation Timing

PRs are created at specific points in the Legion workflow:

TriggerWhenCondition
After /legion:buildAll plans in phase executedAt least one plan succeeded
After /legion:reviewReview cycle passesPR not already created for this phase
Manual via /legion:quickUser requests PRCurrent branch has unpushed commits

Do NOT create a PR if all plans in the phase failed. A PR with only failed work is not useful. Instead, log a note and let the user decide.


Section 4: Milestone Sync (GH-03)

Mapping ROADMAP.md milestones to GitHub milestones. This provides a high-level view of project progress directly in the GitHub interface.

4.1: Create GitHub Milestone

Creates a GitHub milestone corresponding to a ROADMAP milestone.

Input: milestone_name, milestone_description, phase_range (start-end)
Output: github_milestone_number
Step 1: Check if milestone already exists
Command: gh api "repos/{REPO_SLUG}/milestones" --jq '.[].title'
- If milestone_name is in the list: return its number, do not create a duplicate
- To get the number of an existing milestone:
gh api "repos/{REPO_SLUG}/milestones" --jq '.[] | select(.title == "{milestone_name}") | .number'
Step 2: Create milestone
Command:
gh api "repos/{REPO_SLUG}/milestones" \
--method POST \
-f title="{milestone_name}" \
-f description="Phases {start}-{end}: {milestone_description}"
Parse number from JSON response: .number
Step 3: Record in STATE.md
- Add a row to the ## GitHub > ### Milestones table (see Section 6)
- Store the GitHub milestone number for future reference

Milestone names should match ROADMAP.md milestone names exactly. This enables lookup by name when assigning issues to milestones.

4.2: Close GitHub Milestone

Closes a GitHub milestone when all its phases are complete.

Input: github_milestone_number
Step 1: Verify all issues in milestone are closed
Command: gh api "repos/{REPO_SLUG}/milestones/{github_milestone_number}" --jq '.open_issues'
- If open_issues > 0: log warning "Milestone has {N} open issues" but proceed with close
(The user may have added non-Legion issues to the milestone)
Step 2: Close the milestone
Command:
gh api "repos/{REPO_SLUG}/milestones/{github_milestone_number}" \
--method PATCH \
-f state=closed
Step 3: Update STATE.md
- The milestone row status is NOT updated in STATE.md (status is fetched live)
- See Section 6 for state linking rules
4.3: Milestone-Issue Association

When creating a phase issue (Section 2.2), associate it with the correct milestone:

Step 1: Determine which ROADMAP milestone covers the current phase
- Read ROADMAP.md milestone definitions
- Find the milestone whose phase range includes the current phase number
Step 2: Check if that milestone exists on GitHub
- Look up in STATE.md ## GitHub > ### Milestones table
- If the milestone has a GitHub number: use it
- If not: create the milestone first (Section 4.1), then use the new number

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 93 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
62
Repository forks
7
7-day trend score
21

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/9thlevelsoftware/legion/github-sync/badge)](https://verified-skill.com/skills/9thlevelsoftware/legion/github-sync)

Something wrong with this skill or its page? Tell us.