Skip to content

fix(skills): derive repo slug dynamically in /sweep instead of hardcoding (#1966) - #2185

Merged
carlos-alm merged 2 commits into
mainfrom
fix/issue-1966
Jul 30, 2026
Merged

carlos-alm merged 2 commits into
mainfrom
fix/issue-1966

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • `/sweep` hardcoded `--repo optave/codegraph` in 23 places (the actual repo is `optave/ops-codegraph-tool`) — every invocation silently targeted the wrong repository unless manually caught.
  • `/resolve` already fixed this via dynamic `gh repo view --json nameWithOwner` detection; mirrored that pattern here.
  • Since `/sweep`'s PR-processing instructions are a prompt template copied verbatim into each per-PR subagent (not literal executable bash), the embedded `gh`/`gh api` commands now use a `` placeholder — consistent with the file's existing ``/`` placeholder idiom — and Step 2 explicitly instructs the orchestrator to substitute the detected `$REPO` into every subagent's prompt before launch.
  • Found the same bug pattern in `dogfood/SKILL.md` (3 genuine instances, distinct from its many legitimate `@optave/codegraph` npm-package-name references) — filed separately as chore: /dogfood skill hardcodes wrong GitHub repo slug (optave/codegraph instead of optave/ops-codegraph-tool) #2184, out of scope for this issue.

Verification

  • `grep -c "optave/codegraph" .claude/skills/sweep/SKILL.md` → 0 (was 23).
  • This is a markdown skill-instruction file with no executable code path covered by `npm test`/lint beyond formatting — verified the diff is a faithful mechanical substitution (no instruction content altered beyond the repo-slug references and the new Step 1 detection block).

Closes #1966

…ding (#1966)

/sweep hardcoded --repo optave/codegraph in 23 places throughout the
skill (gh pr list, every gh api repos/.../ call, gh label create, gh
issue create). The actual repo is optave/ops-codegraph-tool, so every
invocation silently targeted the wrong repository unless manually
caught.

/resolve already derives the repo slug dynamically via `gh repo view
--json nameWithOwner` -- mirror that approach: Step 1 now detects
$REPO once and uses it for the PR-discovery gh pr list call. Since
/sweep's PR-processing instructions are a prompt template copied
verbatim into each per-PR subagent (not literal executable bash), the
23 embedded gh/gh api commands now use a <repo> placeholder --
consistent with the existing <number>/<comment-id> placeholder idiom
in the same file -- and Step 2 explicitly instructs the orchestrator
to substitute the detected $REPO into every subagent's prompt before
launch.

Found the same bug pattern in dogfood/SKILL.md (3 genuine instances,
distinct from its many legitimate @optave/codegraph npm-package-name
references) -- filed separately as #2184 since it's out of scope for
this issue.

Closes #1966

docs check acknowledged: skill-file-only fix, no README/CLAUDE.md/ROADMAP surface change
Comment thread .claude/skills/sweep/SKILL.md Outdated
```bash
gh pr list --repo optave/codegraph --state open --json number,title,headRefName,baseRefName,mergeable,statusCheckRollup,reviewDecision --limit 50
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner 2>/dev/null \
|| git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fallback retains .git suffix

When gh repo view fails and origin uses a standard GitHub URL ending in .git, the greedy capture includes that suffix, causing subsequent commands to target owner/repository.git instead of the intended repository.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed — switched to a two-pass sed: the first pass only prints on a genuine github.com match (strict alternation on git@github.com:/https://github.com/, non-matching input yields empty output), and the second pass unconditionally strips a trailing .git. Confirmed via direct test against https/git@ URLs with and without .git suffix.

Comment thread .claude/skills/sweep/SKILL.md Outdated
Comment on lines +25 to +28
|| git remote get-url origin | sed -E 's|.*github\.com[:/](.+)(\.git)?$|\1|')
if [ -z "$REPO" ]; then
echo "ERROR: could not detect GitHub repo slug — ensure 'gh' is authenticated or 'origin' points to GitHub"
exit 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Unmatched remotes bypass validation

When the fallback receives a non-GitHub origin URL, sed returns the unchanged nonempty URL and the empty-value guard accepts it, so the sweep continues with an invalid repository identifier instead of reporting that detection failed.

Fix in Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by the same change — the first sed pass now requires a strict github.com prefix match and uses -n ... p, so a non-GitHub remote correctly produces empty output (caught by the existing -z guard) instead of the unchanged raw URL passing through as a false-valid repo slug.

@greptile-apps

greptile-apps Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

The sweep skill now discovers the active GitHub repository dynamically and propagates that slug through all PR-processing commands.

  • Adds authenticated gh repo view detection with a validated GitHub-origin fallback.
  • Rejects undetectable or unsupported remotes before starting the sweep.
  • Replaces hardcoded repository references with per-agent <repo> placeholders.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
.claude/skills/sweep/SKILL.md Dynamically detects and propagates the repository slug; the revised fallback fixes both previously reported remote-parsing failures.

Reviews (2): Last reviewed commit: "fix: harden /sweep's repo-detection fall..." | Re-trigger Greptile

The origin-URL fallback (only exercised when gh repo view fails)
had two bugs Greptile caught in review:

1. The greedy (.+) capture swallowed a trailing .git suffix before
   the optional (\.git)? group ever matched it, so a standard
   https://github.com/owner/repo.git or git@github.com:owner/repo.git
   remote resolved to owner/repo.git instead of owner/repo.
2. A non-GitHub origin silently passed through unchanged (sed leaves
   non-matching lines as-is), which is non-empty and so bypassed the
   -z empty-value guard instead of being treated as detection failure.

Switch to a two-pass sed: the first pass only prints on a genuine
github.com match (so a non-GitHub remote correctly yields empty
output), and the second pass unconditionally strips a trailing .git
-- sidestepping the greedy-capture problem without needing a
non-greedy quantifier (confirmed non-portable: +? errors under both
BSD and GNU sed's -E mode, since lazy quantifiers aren't POSIX ERE).

/resolve has the identical latent bug in two places but wasn't
touched by this PR's diff -- filed separately as #2186.

docs check acknowledged: skill-file-only fix, no README/CLAUDE.md/ROADMAP surface change
@carlos-alm

Copy link
Copy Markdown
Contributor Author

@greptileai

@carlos-alm
carlos-alm merged commit 92b2ddf into main Jul 30, 2026
1 check passed
@carlos-alm
carlos-alm deleted the fix/issue-1966 branch July 30, 2026 08:04
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: /resolve and /sweep skills hardcode wrong repo name (optave/codegraph instead of optave/ops-codegraph-tool)

1 participant