Skip to content

fix(bugfix): improve PR skill reliability and reduce redundancy#79

Merged
jwm4 merged 3 commits intoambient-code:mainfrom
jwm4:feature/improve-pr-skill
Mar 23, 2026
Merged

fix(bugfix): improve PR skill reliability and reduce redundancy#79
jwm4 merged 3 commits intoambient-code:mainfrom
jwm4:feature/improve-pr-skill

Conversation

@jwm4
Copy link
Copy Markdown
Contributor

@jwm4 jwm4 commented Mar 21, 2026

Summary

Addresses four open issues with the bugfix workflow's PR skill:

Net result: 54 insertions, 77 deletions — the skill is shorter despite the new functionality.

Note: This PR builds on #78 (commands-to-skills migration). The diff against main includes both sets of changes; once #78 merges, this PR's diff will show only the PR skill improvements.

Fixes #47, fixes #54, fixes #72, fixes #73

Test plan

  • Run /pr in an environment where git credentials aren't pre-configured — verify gh auth setup-git prevents "could not read Username" errors
  • Run /pr as a GitHub App bot — verify the compare URL includes title and body query params and opens with the PR form pre-populated
  • Verify the commit message includes the PR description body for single-commit PRs
  • Verify clone-and-checkout commands are included in the fallback output
  • Confirm the skill is coherent end-to-end with no broken step references

Made with Cursor

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 21, 2026

Walkthrough

Reworked the bugfix PR skill control flow to determine authentication context up-front, added a pre-flight gate, moved and renumbered fork/branch/PR steps, added gh auth setup-git before push, improved PR-creation fallbacks (URL-encoded params, commit-body coupling, clone/check-out commands), and added ACP custom workflow fields docs in AGENTS.md.

Changes

Cohort / File(s) Summary
Documentation & Testing
AGENTS.md
Added "Custom Workflow Fields" subsection listing required inputs (URL, Branch, Path) for ACP custom workflow testing and instructed reporters to provide these fields after opening a PR.
PR Workflow Skill
workflows/bugfix/.claude/skills/pr/SKILL.md
Reordered workflow to compute AUTH_TYPE first (Step 0), added a Pre-flight Gate, renumbered steps, moved fork/sync/branch boundaries, added gh auth setup-git before git push, mandated including PR description in commit body, enhanced fallback compare-URL with URL-encoded title/body and ~8KB guidance, added clone-and-checkout commands for local testing, and expanded error-recovery messaging and skip rules.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LocalGit as Local Git/Workspace
    participant GHCLI as gh CLI
    participant GitHub as GitHub (remote)
    participant Fork as Fork repo

    User->>GHCLI: run /pr skill
    GHCLI->>GHCLI: Step 0: auth checks (gh auth status, gh api user, installation checks)\ncompute AUTH_TYPE
    GHCLI->>User: print Pre-flight Gate table (Step 2e)
    alt AUTH_TYPE = none
        GHCLI->>User: instruct auth setup steps
    end
    GHCLI->>GitHub: ensure fork exists / maybe create fork
    GHCLI->>LocalGit: create branch, stage selective changes, commit (include PR description in body)
    GHCLI->>GHCLI: run gh auth setup-git
    LocalGit->>Fork: git push branch
    GHCLI->>GitHub: attempt gh pr create --head FORK_OWNER:BRANCH_NAME
    alt gh pr create succeeds
        GitHub->>User: PR URL
    else gh pr create fails
        GHCLI->>User: provide compare-URL with URL-encoded title/body (Rung 2)
        GHCLI->>User: provide clone-and-checkout commands for testing locally
    end
    GHCLI->>User: final confirm/report (include required fields when reporting PR for ACP)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(bugfix): improve PR skill reliability and reduce redundancy' clearly summarizes the main changes—adding reliability improvements and removing redundant content from the PR skill.
Description check ✅ Passed The description is directly related to the changeset, providing context for each of the four linked issues being addressed and a clear test plan.
Linked Issues check ✅ Passed All code requirements from linked issues are met: #47 (gh auth setup-git + error recovery), #54 (removed redundancies), #72 (PR description auto-population via commit body and URL params), and #73 (clone-and-checkout commands in fallback output).
Out of Scope Changes check ✅ Passed All changes are scoped to the PR skill and address the four linked issues; no unrelated modifications were introduced beyond stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jwm4 jwm4 marked this pull request as ready for review March 22, 2026 22:00
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@workflows/bugfix/.claude/skills/pr/SKILL.md`:
- Around line 59-60: The BRANCH_NAME example and its usages are inconsistent and
can produce refs like bugfix/bugfix/..., so normalize branch handling: decide
whether BRANCH_NAME should contain the full ref or only the short name and make
all consumers consistent (either remove the example's "bugfix/" prefix or change
the consumers that prepend "bugfix/" to first strip any leading "bugfix/").
Update all places that build push/head/compare URLs (the code that concatenates
the branch prefix and BRANCH_NAME) to check startsWith("bugfix/") and only
prepend the prefix when missing, or canonicalize BRANCH_NAME by removing any
leading "bugfix/" once at input, so comparisons and pushes never double-prefix.
- Around line 177-187: The fenced pre-flight block in SKILL.md (the "Pre-flight
summary" table) is missing a language identifier causing markdownlint MD040;
update the opening fence for that block (the triple backticks before "Pre-flight
summary") to include a language label such as text (e.g., change ``` to ```text)
so the block is recognized as a fenced code block with a language and the MD040
warning is resolved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 31d297ea-05fc-4c2b-ae3b-1d2981688327

📥 Commits

Reviewing files that changed from the base of the PR and between 40ca47f and d5428d7.

📒 Files selected for processing (23)
  • AGENTS.md
  • WORKFLOW_DEVELOPMENT_GUIDE.md
  • workflows/bugfix/.ambient/ambient.json
  • workflows/bugfix/.claude/commands/assess.md
  • workflows/bugfix/.claude/commands/diagnose.md
  • workflows/bugfix/.claude/commands/document.md
  • workflows/bugfix/.claude/commands/fix.md
  • workflows/bugfix/.claude/commands/pr.md
  • workflows/bugfix/.claude/commands/reproduce.md
  • workflows/bugfix/.claude/commands/review.md
  • workflows/bugfix/.claude/commands/test.md
  • workflows/bugfix/.claude/skills/assess/SKILL.md
  • workflows/bugfix/.claude/skills/controller/SKILL.md
  • workflows/bugfix/.claude/skills/diagnose/SKILL.md
  • workflows/bugfix/.claude/skills/document/SKILL.md
  • workflows/bugfix/.claude/skills/fix/SKILL.md
  • workflows/bugfix/.claude/skills/pr/SKILL.md
  • workflows/bugfix/.claude/skills/reproduce/SKILL.md
  • workflows/bugfix/.claude/skills/review/SKILL.md
  • workflows/bugfix/.claude/skills/speedrun/SKILL.md
  • workflows/bugfix/.claude/skills/test/SKILL.md
  • workflows/bugfix/CLAUDE.md
  • workflows/bugfix/README.md
💤 Files with no reviewable changes (8)
  • workflows/bugfix/.claude/commands/pr.md
  • workflows/bugfix/.claude/commands/assess.md
  • workflows/bugfix/.claude/commands/review.md
  • workflows/bugfix/.claude/commands/diagnose.md
  • workflows/bugfix/.claude/commands/reproduce.md
  • workflows/bugfix/.claude/commands/document.md
  • workflows/bugfix/.claude/commands/test.md
  • workflows/bugfix/.claude/commands/fix.md

jwm4 added 2 commits March 23, 2026 13:13
Address four open issues with the PR skill:

- ambient-code#47: Add gh auth setup-git before git push to configure credential
  helper in fresh environments; add error recovery table entry
- ambient-code#54: Trim redundant git basics from Step 5 and flag explanations /
  inline PR body template from Step 7 (platform system instructions
  already cover basic git workflow)
- ambient-code#72: Auto-populate PR description via two complementary approaches:
  include PR body in commit message (GitHub auto-fills from single
  commits) and encode title+body as URL query params in compare URL
- ambient-code#73: Add clone-and-checkout commands to Rung 2 fallback so users
  can test the branch locally before creating the PR manually

Net effect: 54 insertions, 77 deletions — skill is shorter despite
new functionality.

Fixes ambient-code#47, fixes ambient-code#54, fixes ambient-code#72, fixes ambient-code#73

Made-with: Cursor
The agent was skipping pre-flight checks entirely. Add structural
guardrails to prevent this:

- Add Step 0 (Determine Auth Context) as a standalone first step so
  auth type is resolved before anything else
- Add Step 2e (Pre-flight Gate) requiring the agent to print a
  filled-in summary table before proceeding — makes it structurally
  hard to skip checks
- Add "Expected Flow by Auth Type" section so the agent knows what
  failures to expect downstream instead of improvising
- Fix step numbering: Option 3 (no auth) references Steps 5–6, not
  3–6, since fork steps require gh
- Soften bot-failure language from "will almost certainly fail" to
  "may fail" — some repos grant bots sufficient permissions
- Document Custom Workflow fields in AGENTS.md so agents always
  report them after creating a PR

Made-with: Cursor
@jwm4 jwm4 force-pushed the feature/improve-pr-skill branch from d5428d7 to be60dd2 Compare March 23, 2026 17:13
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
workflows/bugfix/.claude/skills/pr/SKILL.md (1)

59-59: ⚠️ Potential issue | 🔴 Critical

Critical: Branch placeholder semantics create invalid refs.

The BRANCH_NAME example includes the bugfix/ prefix, but Lines 395, 438, 467, 489, and 516 all prepend bugfix/ again. This produces malformed refs like bugfix/bugfix/issue-42-null-check, causing push/PR creation failures.

🔧 Proposed fix

Either remove the prefix from the example:

-| `BRANCH_NAME` | Step 5: the branch you create | `bugfix/issue-42-null-check` |
+| `BRANCH_NAME` | Step 5: the branch you create | `issue-42-null-check` |

Or remove it from all consumer sites (Lines 395, 438, 467, 489, 516):

-git checkout -b bugfix/BRANCH_NAME
+git checkout -b BRANCH_NAME

Also applies to: 395-395, 438-438, 467-467, 489-489, 516-516

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workflows/bugfix/.claude/skills/pr/SKILL.md` at line 59, The BRANCH_NAME
example currently includes the "bugfix/" prefix, which combined with consumer
code that prepends "bugfix/" produces malformed refs like
"bugfix/bugfix/issue-42-null-check"; fix by either removing the "bugfix/" prefix
from the BRANCH_NAME example in the table row that shows `BRANCH_NAME` or by
removing the extra "bugfix/" prefix in all consumers that prepend it (those
places that currently construct refs resulting in "bugfix/bugfix/..."); ensure
the final branch placeholder is a single canonical value so refs are formed as
"bugfix/issue-42-null-check" (or consumers create the full name, not both).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@workflows/bugfix/.claude/skills/pr/SKILL.md`:
- Line 59: The BRANCH_NAME example currently includes the "bugfix/" prefix,
which combined with consumer code that prepends "bugfix/" produces malformed
refs like "bugfix/bugfix/issue-42-null-check"; fix by either removing the
"bugfix/" prefix from the BRANCH_NAME example in the table row that shows
`BRANCH_NAME` or by removing the extra "bugfix/" prefix in all consumers that
prepend it (those places that currently construct refs resulting in
"bugfix/bugfix/..."); ensure the final branch placeholder is a single canonical
value so refs are formed as "bugfix/issue-42-null-check" (or consumers create
the full name, not both).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 01140ac5-843e-4150-8539-799354a2ac08

📥 Commits

Reviewing files that changed from the base of the PR and between d5428d7 and be60dd2.

📒 Files selected for processing (2)
  • AGENTS.md
  • workflows/bugfix/.claude/skills/pr/SKILL.md

Address CodeRabbit review feedback on PR ambient-code#79:

- Make BRANCH_NAME the full branch name (e.g. bugfix/issue-42-null-check)
  and remove redundant bugfix/ prefix from all consumers to prevent
  double-prefixing like bugfix/bugfix/...
- Add language label to pre-flight gate fenced code block (MD040)

Made-with: Cursor
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@workflows/bugfix/.claude/skills/pr/SKILL.md`:
- Around line 431-439: Replace the hardcoded push remote in the Step 7
instruction ("git push -u fork BRANCH_NAME") with a dynamic remote that uses
whatever remote was configured earlier in Step 4 (the fork remote may be named
"origin" or "fork"); update the text to reference a variable remote (e.g., "git
push -u <FORK_REMOTE> BRANCH_NAME" or "git push -u <remote> BRANCH_NAME") and/or
instruct the user to use the remote name they set in Step 4, ensuring the push
command uses the same remote name as configured previously.
- Around line 81-83: Update the documentation and any code examples that derive
GH_USER from the first entry of the /installation/repositories response
(referenced in the text around lines 81–83) to instead fetch the installation
details via GET /app/installations/{installation_id} and use the account.login
field as the installation owner; change all mentions of “repository owner” or
deriving GH_USER from /installation/repositories to “installation account
(account.login)” and show using the installation endpoint for accurate user vs
organization ownership and downstream fork/auth checks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c9009be8-bcf0-4855-b336-d1263394a9b1

📥 Commits

Reviewing files that changed from the base of the PR and between be60dd2 and 3084835.

📒 Files selected for processing (1)
  • workflows/bugfix/.claude/skills/pr/SKILL.md

Comment on lines +81 to +83
The `/installation/repositories` endpoint works because GitHub Apps are
installed on user accounts — the repo owner is the actual user.

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.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

For GitHub Apps, can installations be owned by organizations as well as users, and what is the recommended way to determine the correct account/login to use for repository operations?

💡 Result:

Yes, GitHub App installations can be owned by both individual users and organizations. Official documentation confirms that installations occur on user or organization accounts, with the installation object including an account field containing the login of the owning user or organization, and a target_type field indicating "User" or "Organization". The recommended way to determine the correct account/login for repository operations is to fetch the installation details using the GitHub REST API (e.g., GET /app/installations/{installation_id}) and use the account.login from the response. This provides the owner (user or org login) associated with the installation, which is used in repository owner fields for API calls (e.g., /repos/{owner}/{repo}). For authentication, generate an installation access token for that installation and use it with "Authorization: Bearer TOKEN" for repository API operations or Git operations.

Citations:


🏁 Script executed:

find . -name "SKILL.md" -path "*/pr/*" | head -20

Repository: ambient-code/workflows

Length of output: 111


🏁 Script executed:

cat -n ./workflows/bugfix/.claude/skills/pr/SKILL.md | sed -n '70,95p'

Repository: ambient-code/workflows

Length of output: 1157


Update documentation: GitHub App installations can be org-owned; use installation account instead of repository owner.

Lines 81–83 incorrectly assume GitHub App installations are always user-owned. GitHub allows apps to be installed on both user accounts and organizations. Deriving GH_USER from /installation/repositories endpoint's first result returns the owner of that repository—which could be an organization—not necessarily the correct account for authentication or downstream fork checks.

Use the installation's account details instead: fetch /app/installations/{installation_id} and use the account.login field, which correctly indicates the owner (user or organization) of the installation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workflows/bugfix/.claude/skills/pr/SKILL.md` around lines 81 - 83, Update the
documentation and any code examples that derive GH_USER from the first entry of
the /installation/repositories response (referenced in the text around lines
81–83) to instead fetch the installation details via GET
/app/installations/{installation_id} and use the account.login field as the
installation owner; change all mentions of “repository owner” or deriving
GH_USER from /installation/repositories to “installation account
(account.login)” and show using the installation endpoint for accurate user vs
organization ownership and downstream fork/auth checks.

Comment on lines +431 to 439
### Step 7: Push to Fork

```bash
git push -u fork bugfix/BRANCH_NAME
# Ensure git uses gh for authentication
gh auth setup-git

# Push the branch
git push -u fork BRANCH_NAME
```
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.

⚠️ Potential issue | 🟠 Major

Use a dynamic push remote instead of hardcoding fork.

Line 438 can fail when Step 4 kept origin as the fork remote (Line 316–318 guidance). This creates a self-contradictory path in the happy flow.

Suggested fix
 ### Step 4: Configure the Fork Remote
@@
-Use `fork` as the remote name. If `origin` already points to the fork, that's
-fine — just use `origin` in subsequent commands instead of `fork`.
+Use `fork` as the remote name. If `origin` already points to the fork, that's
+fine — set `PUSH_REMOTE=origin`; otherwise set `PUSH_REMOTE=fork`.
@@
 ### Step 7: Push to Fork
@@
-# Push the branch
-git push -u fork BRANCH_NAME
+# Push the branch
+git push -u PUSH_REMOTE BRANCH_NAME
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workflows/bugfix/.claude/skills/pr/SKILL.md` around lines 431 - 439, Replace
the hardcoded push remote in the Step 7 instruction ("git push -u fork
BRANCH_NAME") with a dynamic remote that uses whatever remote was configured
earlier in Step 4 (the fork remote may be named "origin" or "fork"); update the
text to reference a variable remote (e.g., "git push -u <FORK_REMOTE>
BRANCH_NAME" or "git push -u <remote> BRANCH_NAME") and/or instruct the user to
use the remote name they set in Step 4, ensuring the push command uses the same
remote name as configured previously.

@jwm4 jwm4 merged commit f10b053 into ambient-code:main Mar 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant