gh-pr-comment
npx machina-cli add skill dceoy/github-cli-agent-skills/gh-pr-comment --openclawFiles (1)
SKILL.md
2.3 KB
GitHub PR Comment
When to use
- The user asks to comment on a PR.
- Posting status updates or feedback on a PR.
- Editing or deleting previous comments.
Inputs to confirm
- PR number, URL, or branch name (or current branch PR).
- Comment body text or file.
- Whether to edit or delete last comment.
Workflow
- Verify auth:
gh --version gh auth status - Post a comment:
gh pr comment 123 --body "LGTM! Ready for merge." gh pr comment 123 --body-file review-notes.md - Edit or delete your last comment:
gh pr comment 123 --edit-last --body "Updated: addressed concerns" gh pr comment 123 --delete-last --yes - Open editor or browser:
gh pr comment 123 --editor gh pr comment 123 --web
Examples
# Quick comment
gh pr comment 123 --body "Testing this now."
# Comment from file
gh pr comment 123 --body-file feedback.md
# Edit last comment
gh pr comment 123 --edit-last --body "Actually, found one more issue."
# Delete last comment
gh pr comment 123 --delete-last --yes
# Comment on current branch's PR
gh pr comment --body "Addressed review feedback."
Flags reference
| Flag | Description |
|---|---|
-b, --body | Comment body text |
-F, --body-file | Read body from file (use "-" for stdin) |
--edit-last | Edit your last comment |
--delete-last | Delete your last comment |
--create-if-none | Create comment if none exists (with --edit-last) |
--yes | Skip delete confirmation |
-e, --editor | Open editor to write comment |
-w, --web | Open browser to write comment |
Notes
- Without
--bodyor--body-file, opens interactive prompt. - Only your own comments can be edited/deleted.
- Use
--create-if-nonewith--edit-lastfor idempotent updates.
References
- GitHub CLI manual: https://cli.github.com/manual/
gh pr comment --help
Source
git clone https://github.com/dceoy/github-cli-agent-skills/blob/main/skills/gh-pr-comment/SKILL.mdView on GitHub Overview
gh-pr-comment lets you add, edit, or delete comments on a GitHub pull request using the gh CLI. It supports posting new comments, updating existing ones, and removing your own comments, with options to target the last comment or create a comment when none exists.
How This Skill Works
You post comments with gh pr comment <PR> --body 'Text' or --body-file <file>. You can edit or delete your last comment using --edit-last or --delete-last, and you can open an editor or browser with --editor or --web. If no body is provided, an interactive prompt is used to craft the comment.
When to Use It
- The user asks to comment on a PR.
- Posting status updates or feedback on a PR.
- Editing or deleting previous comments.
- Commenting on the PR from the current branch.
- Preparing a comment in an editor or browser before posting.
Quick Start
- Step 1: Verify authentication with gh --version and gh auth status.
- Step 2: Post a comment using gh pr comment <PR> --body 'LGTM! Ready for merge.' or --body-file <file>.
- Step 3: Edit or delete your last comment with --edit-last or --delete-last, or open an editor/browser with --editor or --web.
Best Practices
- Confirm the target PR by number, URL, or branch (or use the current branch PR).
- Always provide --body or --body-file to avoid interactive prompts in automation.
- Edit or delete only your own comments; use --edit-last or --delete-last accordingly.
- Use --create-if-none with --edit-last for idempotent updates.
- For interactive drafting, use --editor or --web to open an editor or browser.
Example Use Cases
- gh pr comment 123 --body 'Testing this now.'
- gh pr comment 123 --body-file feedback.md
- gh pr comment 123 --edit-last --body 'Actually, found one more issue.'
- gh pr comment 123 --delete-last --yes
- gh pr comment --body 'Addressed review feedback.'
Frequently Asked Questions
Add this skill to your agents