CodePanel
Foreign-repo prompt & rules

Foreign-repo prompt & rules

A copy-paste setup prompt and drop-in rules block so any AI agent in any repository can use CodePanel for reviews, decisions, and permission diagnostics.

On this page›

Paste the setup prompt below into any coding agent inside any repository to connect it to CodePanel, diagnose permission or branch-protection quirks, and install a drop-in rules block so every agent working in that repo interacts with CodePanel cleanly, including asking CodePanel for technical decisions instead of stalling on a human.

If the repository is already connected and you only want the rules block, skip straight to Drop-in rules file for any repository.

1. Foreign-repo setup and configuration prompt

Paste this into Claude Code, Codex, Cursor, Antigravity, or any MCP-capable coding agent inside the target repository:

Prompt47 lines
Configure this repository to work well with CodePanel (reviews, merge gate,
and technical decisions). Work on one branch and open one pull request. Do not
guess around permission errors: diagnose them and report exact owner steps
only when a human action is required.

1. Verify CodePanel access and permissions first:
   - Call `whoami`. Confirm `subscription.active` is true (or billing is off)
     and check token scopes. You need `read` and `reviews:write` for daily
     work, plus `repos:write` to connect or tune repo settings. If any scope
     is missing, stop and tell the owner the exact missing scope.
   - Call `list_repos` to see if this repository (`owner/name`) is connected.
     If not, check `list_connectable_repos` and call `connect_repo`.
   - Inspect repository health and settings:
     - Check whether commit statuses are refused (`missing_permission` /
       `no_status`). If so, note that the owner must accept the "Commit
       statuses" permission on the CodePanel GitHub App installation.
     - Check `gate` level (recommended: `warning`), `maxAutoRounds` (3),
       `autoReview` (true), and whether bots open PRs here (if so, list them
       in `trustedBotAuthors`).
     - Check GitHub branch protection / rulesets (`gh api` if available):
       note whether auto-merge is enabled and whether `CodePanel` is a
       required status check. Never bypass rulesets with `--admin`.

2. Audit the repository's existing agent setup:
   - Find all instruction files (`AGENTS.md`, `CLAUDE.md`, `.cursor/rules`,
     `.github/copilot-instructions.md`), hooks, CI checks, and other review
     bots. Note which file each agent in this repo actually reads.

3. Create or update `.codepanel/rules.md` (under 6,000 chars):
   - One line per diff-checkable rule, naming the doc or file it comes from.
   - Cover invariants (auth, money/billing, schema/migrations, security),
     deliberate conventions reviewers shouldn't flag, and what linters
     already enforce.

4. Install the CodePanel Agent Rules block:
   - Append (never overwrite) the `<!-- codepanel:start -->` ...
     `<!-- codepanel:end -->` rules block below into the repository's main
     agent instructions file (`AGENTS.md` / `CLAUDE.md`, or `.cursor/rules/`).
   - If the repo has conflicting instructions (e.g. "always merge main on
     every push" or "push for every suggestion"), list those conflicts in
     the PR description rather than silently deleting them.

5. Verify before opening the PR:
   - Run the repository's own test, lint, and typecheck commands.
   - Open one pull request, wait for CodePanel with `wait_for_review`,
     answer any findings with `rate_finding`, and summarize any owner-only
     permission or ruleset steps in the PR description.

2. Drop-in rules file for any repository

Copy this block directly into AGENTS.md, CLAUDE.md, .cursor/rules/codepanel.mdc, or .github/copilot-instructions.md in any repository:

<!-- codepanel:start -->
## Working with CodePanel

CodePanel reviews pull requests with a multi-model panel and answers technical
and design questions so you do not block waiting on a human. Where this block
disagrees with the repository's own rules, the repository's rules win.

### 1. Ask CodePanel before blocking on a human
- When you hit a convention, architecture, or tradeoff question (before or
  during a PR), call `ask_decision` (or `codepanel decide <owner/name> ...`)
  with `repo`, `question`, candidate `options`, relevant `files`, and
  `reversibility` (`easy`, `moderate`, or `hard`).
- CodePanel checks recent repository decisions first (Tier 0), then runs a
  cross-family model with repo rules and code (Tier 1), and escalates to a
  multi-model panel (Tier 2) on low confidence, hard-to-reverse choices, or
  high-stakes paths (schema, auth, billing, secrets).
- Follow `nextAction`:
  - `proceed`: apply `decision` immediately and keep moving.
  - `wait_for_human`: stop and hand the pre-digested options to the owner
    (used only for irreversible or owner-authority choices).
  - `wait`: poll again with `decisionId`.

### 2. Run the pull request review loop
- Run tests, lint, and typecheck locally before every push. Never push red.
- After pushing, block on `wait_for_review` with your pushed `headSha`, then
  read `get_review` and follow `payload.nextAction` (`fix`, `wait`, `trigger`,
  `rate`, `escalate`, `done`, or `stop`).
- Check `solutionOptions` on findings when present: CodePanel proposes 2–3
  approaches and marks one `recommended`.
- If a finding is unclear, call `ask_reviewer` with its `ref` (e.g. `F3`)
  before disputing it.
- Batch fixes into **one push per round**. Never push while a round is still
  running (`nextAction: "wait"`), and never push for suggestions alone once
  the gate is green.
- Rate every finding you acted on or checked using `rate_finding` (or one PR
  comment with `/feedback F3 up fixed --agent <your-agent>`). Only dispute
  (`down false_positive|wrong_location|not_worth_fixing|duplicate`) with
  concrete evidence (`file:line`, test, or doc).

### 3. Handling repository permissions and friction points
- **`missing_scope` (403):** Stop and report the exact missing scope from the
  error payload (`read`, `reviews:write`, `repos:write`, `tasks:write`, or
  `interrupts:answer`). Never retry in a loop.
- **Missing `CodePanel` commit status (`no_status` / `missing_permission`):**
  Do not wait forever on branch protection. Tell the owner to accept Commit
  statuses on the CodePanel GitHub App installation, and check `get_review`
  for the actual gate verdict.
- **Round limit, budget cap, or plan limit (`round_limit_reached`,
  `budget_cap`, `plan_required`):** Do not re-trigger paid rounds. Run a local
  self-check with `get_review_brief` and record it with `submit_local_review`,
  or leave a clear note for the owner.
- **Auto-merge disabled or strict branch protection:** Never pass `--admin` or
  bypass rulesets. Once CI and `CodePanel` are green, leave the PR ready for
  a maintainer to merge.
- **Bot-authored PRs:** CodePanel skips untrusted bots by default. Comment
  `/review` on the PR, or ask the owner to add the bot to `trustedBotAuthors`.
- **Forks or read-only repos:** Push only to your own fork branch; never try
  to push to upstream or mutate upstream settings.
<!-- codepanel:end -->
  • Repository setup: focused prompt for .codepanel/rules.md and handoffs.
  • ask_decision: full input and response reference for the Decision Maker.
  • MCP server: install, scopes, and every MCP tool.
  • Merge gate: how findings map to the CodePanel commit status.
Last updated