Skip to content

chore(skills): add create-pr skill#1803

Open
mirooon wants to merge 14 commits into
mainfrom
chore/add-create-pr-skill
Open

chore(skills): add create-pr skill#1803
mirooon wants to merge 14 commits into
mainfrom
chore/add-create-pr-skill

Conversation

@mirooon
Copy link
Copy Markdown
Contributor

@mirooon mirooon commented May 14, 2026

Which Linear task belongs to this PR?

Why did I implement it this way?

Adds a create-pr Claude Code skill that automates branch → commit → push → PR. The skill:

  • reads .github/pull_request_template.md verbatim and fills only specific named fields (Linear link, rationale, ticked checkboxes);
  • resolves a Linear link from conversation context, falling back to the Linear MCP, and asks the user in chat (with a skip option) if neither finds a match — never fabricates;
  • verifies before ticking the author checklist: walks git diff main...HEAD for the self-review tick; inspects git log main..HEAD --oneline for the single-concern tick;
  • runs the test suite (forge test / bun test:ts) — the gap .husky/pre-commit deliberately leaves (the hook uses forge build --skip test and doesn't invoke bun test:ts). Lint / typecheck / build / solhint / secret scan are already enforced by pre-commit + .agents/hooks/post-edit-validate.sh, so the skill does not duplicate them;
  • delegates to the /pr-ready sibling skill for local CodeRabbit pre-flight (mandatory per .agents/rules/099-finish.md once chore(skills): add /pr-ready local CodeRabbit pre-flight #1792 lands), and appends a ## /pr-ready deferred findings section to the body when items are deferred/rejected;
  • handles edge cases at step 1: no changes / detached HEAD / on main with local changes / branch already has an open PR;
  • shows a pre-flight summary (self-review findings, check statuses, full filled-in body, /pr-ready commits added) and waits for explicit y/n before pushing;
  • leaves the reviewer checklist unchecked and offers to post the PR to #dev-sc-review via /post-pr-for-review.

Aikido findings reviewed: two findings on the skill file (template-read at line 72; Linear MCP at line 76) — both reviewed as false positives. The PR template is a checked-in public file with no secrets; .husky/pre-commit scans for secrets + private keys before any commit lands (step 4); the step 9 pre-flight summary requires explicit y/n before push. Linear is the team's own authenticated ticket tracker via MCP — not a third-party data sink — and branch/commit text becomes publicly visible at git push to this public repo seconds later anyway.

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

Review Change Stack

Walkthrough

Adds a detailed .agents/commands/create-pr.md specification for a 12-step create-pr workflow, reorders one global-rules bullet, adds MCP tool naming guidance, and replaces embedded skill docs with redirects to the new command spec.

Changes

Create PR Skill Workflow

Layer / File(s) Summary
Global rules activation and MCP naming
.agents/rules/000-global-standards.md, .agents/commands/add-new-rule.md
Repositions the “Uncertainty” guidance and adds a “Referencing MCP Tools” section requiring client-agnostic MCP tool names instead of fully-qualified runtime IDs.
Skill metadata, triggers, and redirects
.agents/commands/create-pr.md, .claude/skills/create-pr/SKILL.md, .cursor/commands/create-pr.md
Introduces create-pr metadata and triggers; replaces embedded skill files with single-line forwards to the canonical .agents/commands/create-pr.md.
Repository state assessment & branch naming
.agents/commands/create-pr.md
Defines git-state checks (clean tree, detached HEAD, existing PRs, protected main/master) and branch-name derivation rules prioritizing Linear IDs and avoiding protected branches.
Branch creation, staging, and commit conventions
.agents/commands/create-pr.md
Create/switch branch when needed, stage only task-relevant files, and derive a concise, imperative commit subject.
PR body construction and Linear resolution
.agents/commands/create-pr.md
Build PR body from the local template, resolve or create Linear tasks with explicit consent, populate rationale and author checklist, and handle ambiguity prompting and branch-rename behavior.
PR title, /pr-ready integration, and test execution
.agents/commands/create-pr.md
Derive PR title, require running /pr-ready (stop on errors), append deferred findings, select and run appropriate tests for the change type, and stop on failing checks.
Pre-flight confirmation, push, and PR creation
.agents/commands/create-pr.md
Render a pre-flight summary (commits, files, checks, self-review), require explicit user confirmation, push the branch, run gh pr create using main as base, print the PR URL, and offer /post-pr-for-review.
Failure modes and operational notes
.agents/commands/create-pr.md
Enumerates failure modes (secrets, existing PRs, push rejections, missing template, unknown Linear task, test or /pr-ready failures) and adds final notes about unrelated files and not amending published commits.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • lifinance/contracts#1780: Adds post-pr-for-review skill/docs which the create-pr skill references as a post-creation action.
  • lifinance/contracts#1792: Introduces the /pr-ready command/docs that create-pr uses as a mandatory pre-flight gate.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore(skills): add create-pr skill' accurately summarizes the main change: adding a new create-pr skill to the codebase.
Description check ✅ Passed The PR description covers the required template sections: Linear task status, implementation rationale with detailed technical decisions, and a mostly-completed author checklist. One required checkbox is missing but the core required sections are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-create-pr-skill

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.

@lifi-action-bot lifi-action-bot marked this pull request as draft May 14, 2026 13:08
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@mirooon mirooon marked this pull request as ready for review May 14, 2026 13:16
mirooon and others added 2 commits May 15, 2026 22:52
- Integrate /pr-ready as step 8 (mandatory CodeRabbit pre-flight)
- Trim step 7 to tests only — pre-commit hook already covers lint/typecheck/build
- Require actual diff walk + commit inspection before ticking self-review and
  single-concern boxes (no default ticks)
- Add edge cases for clean tree, detached HEAD, on-main, existing-PR branches
- Replace "wait for terminal input" Linear lookup with chat/AskUserQuestion
- Drop hardcoded model in commit example
- Reference CLAUDE.md for PR-edit conventions (avoid drift)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…pe, top-3 ask)

- Add explicit 4-step strategy: conversation context → branch-name ID
  prefix → scoped keyword search → user prompt / blank
- Drop assignee filter; tickets are often created by PMs/others
- Auto-accept only if top hit shares ≥3 tokens AND has active status
- For ambiguous matches, show top 3 (ID/title/status) and ask
- Document that Linear's GitHub integration handles bidirectional
  cross-linking automatically when the issue ID is in the PR body —
  no extra MCP call required

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread .claude/skills/create-pr/SKILL.md Outdated
Comment thread .claude/skills/create-pr/SKILL.md Outdated
Comment thread .claude/skills/create-pr/SKILL.md Outdated
Comment thread .claude/skills/create-pr/SKILL.md Outdated
• <file2>
...

Commit: "<commit message>"
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.

which commit message is that? Of the last commit?

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.

good catch. The summary now shows a commits since main list straight from git log main..HEAD --oneline, with the step-4 commit and any pr-ready: commits visible in order. I also folded the separate "/pr-ready commits added" sub-section into that unified list so there's only one source of truth.

expanded in: a87fb8ae

Comment thread .claude/skills/create-pr/SKILL.md Outdated
- **Branch already has open PR**: surface URL, offer to push new commits instead.
- **Push rejected (non-fast-forward)**: report error; do not force-push without explicit user instruction.
- **No template found**: use minimal body with title + rationale only.
- **Linear task unknown**: leave the section blank with an HTML comment (`<!-- No Linear task -->`) rather than fabricating a link.
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.

I think we should switch to having a linear task for everything since it's nice and easy to create those now. So if there is no linear task, then maybe we should create one automatically?
wdyt?

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.

agree! added in: 5b629293

To make sure that we still have human readable titles rather than title dirived from diffs I didn't go with fully automatic approach. The skill now offers to create one when none is found, with three options: e (default — show the proposed title and let you edit before creating), y (accept the proposed title as-is), s (skip). On accept it creates the ticket in EXSC to make sure that we still have human readable titles rather than title dirived from diffs

mirooon and others added 5 commits May 18, 2026 18:32
Branch-name ID prefix is the most reliable trigger for Linear's GitHub
auto-link. Update step 2 to prefer `<type>/<lowercase-id>-<short-slug>`
when an ID is known from context, and fall back to slug-only when not.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Linear's GitHub integration triggers the bidirectional auto-link only
via branch-name ID prefix OR a magic keyword (`Fixes`/`Closes`/
`Resolves`/`Ref`) + ID in the title/body — a bare ID mention is not
enough. Update step 5 to require `Fixes <ID>` (or `Ref <ID>`) in the
body and call out the branch-name path as primary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
/pr-ready can land auto-fix commits on the branch, so tests should run
against the post-/pr-ready HEAD. Swap steps 7 and 8, and tweak both
step bodies to explain the ordering (and keep the checkbox reference
in step 5 pointing at the right step number).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
By step 9 HEAD may carry several commits — the step-4 commit plus any
auto-fix commits from /pr-ready — so a single "Commit:" line is stale.
Replace with a "Commits (N) since main" list (from
`git log main..HEAD --oneline`), fold in the separate /pr-ready
sub-section, and put the check list in the new step order
(/pr-ready before tests).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
When no Linear ticket matches, propose creating one (default action
`edit` — always shows the user the proposed title before creating;
`y` accepts as-is; `s` skips). On accept, insert `Fixes <ID>` in the
body and rename the branch to include the ID before push so
auto-linking works via both routes. On skip, fall back to the existing
`<!-- No Linear task -->` placeholder. Update Failure modes to match.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread .claude/skills/create-pr/SKILL.md Outdated
- `e` (default) — show the proposed title (`<derived from branch + commit subject>`) and let the user adjust before creating.
- `y` — create immediately with the proposed title as-is.
- `s` — skip; proceed without a ticket.
- On `y` / `e` (after the user confirms the edited title): call `mcp__claude_ai_Linear__save_issue` with `team: "SmartContract"`, the (edited) title, and a short body summarizing the change + a placeholder for the PR URL. Use the returned ID:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Skill will call mcp__claude_ai_Linear__save_issue and rename the branch (git branch -m) to include the new ID; these are mutating external/local actions. Ensure explicit, unambiguous user authorization is obtained before creating tickets or renaming branches.

Details

✨ AI Reasoning
​The skill's workflow includes creating a Linear issue via mcp__claude_ai_Linear__save_issue and renaming the local branch (git branch -m <new-name>) as part of its automated flow. These are external side-effects (networked creation of tickets and local branch mutation) introduced by this new skill. Automated creation/renaming operations that affect repository state or external trackers should require explicit, clearly visible confirmation; they can be surprising if performed without clear user consent.

🔧 How do I fix it?
Ensure skill actions match the description. Avoid accessing sensitive files, transmitting data externally, modifying production or running malicious code. Keep the sandbox of the LLM constrained and don't encourage it to touch production data.

Reply @AikidoSec feedback: [FEEDBACK] to get better review comments in the future.
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info

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.

good point

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.

The fair part of the flag was the git branch -m: the original prompt only asked about the ticket, and the rename was described in a sub-bullet underneath, so a y arguably consented to ticket creation alone rather than both side-effects. Fixed in d369d75 — the prompt now lists both actions side-by-side with their concrete inputs (team + proposed title; current branch → proposed new branch), so a single y/e covers both unambiguously, and s explicitly leaves the branch as-is.

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: 1

🧹 Nitpick comments (1)
.claude/skills/create-pr/SKILL.md (1)

149-181: 💤 Low value

Consider adding language specifier to code block.

The fenced code block at line 149 lacks a language specifier. While not critical, adding text or markdown would improve rendering consistency and satisfy the markdownlint MD040 rule.

📝 Proposed fix
-```
+```text
 About to create PR on branch `<branch-name>`:
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.claude/skills/create-pr/SKILL.md around lines 149 - 181, The fenced code
block that begins with "About to create PR on branch `<branch-name>`" is missing
a language specifier; update that block delimiter from ``` to ```text (or
```markdown) so the block starts with ```text and the rest of the content
remains unchanged, which will satisfy MD040 and improve rendering consistency.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.claude/skills/create-pr/SKILL.md:
- Line 29: The step number in the sentence referencing "/pr-ready" is incorrect:
it says "/pr-ready is integrated as step 8" but the workflow lists "/pr-ready"
as step 7 and the test suite as step 8; update the text in SKILL.md to refer to
"/pr-ready" as step 7 (or reword to avoid a hardcoded step number) so it matches
the actual workflow ordering and prevents confusion (search for the phrase
"/pr-ready is integrated as step 8" and change "step 8" to "step 7" or use a
non-numbered description).

---

Nitpick comments:
In @.claude/skills/create-pr/SKILL.md:
- Around line 149-181: The fenced code block that begins with "About to create
PR on branch `<branch-name>`" is missing a language specifier; update that block
delimiter from ``` to ```text (or ```markdown) so the block starts with ```text
and the rest of the content remains unchanged, which will satisfy MD040 and
improve rendering consistency.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 875bc1f8-2c17-46a2-9b4b-d14b8128252c

📥 Commits

Reviewing files that changed from the base of the PR and between 3ced1b8 and 5b62929.

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

Comment thread .claude/skills/create-pr/SKILL.md Outdated
mirooon and others added 5 commits May 18, 2026 18:52
…r fallback

The previous prompt asked "Create one in EXSC?" but the subsequent
`git branch -m` happened implicitly, so a `y` could feel like consent
to ticket creation alone. Update the prompt to show both side-effects
(ticket creation + branch rename with the new name preview) so a
single keystroke covers both actions unambiguously.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After the step 7/8 swap (commit e50050a), the "Related conventions"
section still pointed to /pr-ready as "step 8 below"; it's now step 7.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Added a guideline to refer to MCP tools by client-agnostic names in documentation, ensuring consistency across different client integrations. This change aims to prevent confusion caused by varying namespace prefixes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…nostic names

Introduced a new section in the add-new-rule command documentation to clarify the use of client-agnostic names when referencing MCP tools. This aims to enhance consistency and prevent confusion across different client integrations.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Introduced a new command documentation for creating pull requests, detailing the workflow, inputs, and related conventions. This aims to streamline the process of opening PRs by providing clear guidelines for users.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/commands/create-pr.md:
- Line 210: Replace the hardcoded temporary file usage in the gh pr create
invocation by generating a unique temp file with mktemp, write the PR body into
that temp file, call gh pr create using --body-file to point to the temp file
(instead of command substitution with cat /tmp/pr-body.md), and ensure the temp
file is removed after the command (trap or explicit rm); update the command
referenced (gh pr create --body "$(cat /tmp/pr-body.md)") to use the
mktemp-created path and --body-file to avoid race conditions and ensure cleanup.

In @.cursor/commands/create-pr.md:
- Line 1: The file .cursor/commands/create-pr.md is a plain text file containing
a path instead of being a symlink to the canonical command in
.agents/commands/create-pr.md; remove the plain file and replace it with a
symbolic link pointing to ../../.agents/commands/create-pr.md so that
.cursor/commands/create-pr.md is a symlink to .agents/commands/create-pr.md
(verify via ls -l to confirm the -> arrow), matching the DRY convention
described in .agents/commands/add-new-rule.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b9eb5383-d8cf-427d-8871-85149202e0d2

📥 Commits

Reviewing files that changed from the base of the PR and between ecd75e2 and 1e554fe.

📒 Files selected for processing (5)
  • .agents/commands/add-new-rule.md
  • .agents/commands/create-pr.md
  • .agents/rules/000-global-standards.md
  • .claude/skills/create-pr/SKILL.md
  • .cursor/commands/create-pr.md
✅ Files skipped from review due to trivial changes (1)
  • .claude/skills/create-pr/SKILL.md

Write body to a temp file and create via `gh`:

```bash
gh pr create --title "<title>" --body "$(cat /tmp/pr-body.md)" --base main --head <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 | 🟡 Minor | ⚡ Quick win

Use mktemp for the temporary PR body file.

The hardcoded path /tmp/pr-body.md could cause race conditions if multiple instances run concurrently, and the file isn't explicitly cleaned up in the spec.

🔒 Proposed fix
-gh pr create --title "<title>" --body "$(cat /tmp/pr-body.md)" --base main --head <branch-name>
+body_file=$(mktemp)
+cat > "$body_file" <<'EOF'
+<body content>
+EOF
+gh pr create --title "<title>" --body-file "$body_file" --base main --head <branch-name>
+rm "$body_file"

Note: gh pr create also accepts --body-file directly, which is cleaner than command substitution with cat.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/commands/create-pr.md at line 210, Replace the hardcoded temporary
file usage in the gh pr create invocation by generating a unique temp file with
mktemp, write the PR body into that temp file, call gh pr create using
--body-file to point to the temp file (instead of command substitution with cat
/tmp/pr-body.md), and ensure the temp file is removed after the command (trap or
explicit rm); update the command referenced (gh pr create --body "$(cat
/tmp/pr-body.md)") to use the mktemp-created path and --body-file to avoid race
conditions and ensure cleanup.

@@ -0,0 +1 @@
../../.agents/commands/create-pr.md No newline at end of file
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 | 🟡 Minor | ⚡ Quick win

Inconsistency: should be a symlink per documented conventions.

According to .agents/commands/add-new-rule.md lines 145–151 (added in this same PR), Cursor commands should be symlinks, not text files containing paths:

ln -sf "../../.agents/commands/<name>.md" ".cursor/commands/<name>.md"

Line 151 explicitly states: "Verify: ls -l .cursor/commands/<name>.md ... should both show symlink arrows".

This file contains the text ../../.agents/commands/create-pr.md when it should be created as a symlink instead.

🔗 Create as symlink instead

Remove this file and create a symlink:

rm .cursor/commands/create-pr.md
ln -sf ../../.agents/commands/create-pr.md .cursor/commands/create-pr.md

Then verify: ls -l .cursor/commands/create-pr.md should show -> pointing to .agents/commands/create-pr.md.

As per coding guidelines, agent commands should follow the DRY symlink structure documented in .agents/commands/add-new-rule.md.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.cursor/commands/create-pr.md at line 1, The file
.cursor/commands/create-pr.md is a plain text file containing a path instead of
being a symlink to the canonical command in .agents/commands/create-pr.md;
remove the plain file and replace it with a symbolic link pointing to
../../.agents/commands/create-pr.md so that .cursor/commands/create-pr.md is a
symlink to .agents/commands/create-pr.md (verify via ls -l to confirm the ->
arrow), matching the DRY convention described in
.agents/commands/add-new-rule.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants