# Finalize Pr

> >

- **Type:** Skill
- **Install:** `agentstack add skill-codagent-ai-agent-skills-finalize-pr`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [Codagent-AI](https://agentstack.voostack.com/s/codagent-ai)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [Codagent-AI](https://github.com/Codagent-AI)
- **Source:** https://github.com/Codagent-AI/agent-skills/tree/main/skills/finalize-pr

## Install

```sh
agentstack add skill-codagent-ai-agent-skills-finalize-pr
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# codagent:finalize-pr

Push the PR, wait for CI, fix any failures or review comments, and repeat until the PR is green — or pause when termination rules require human input.

## Procedure

### Step 1 — Push the PR

Invoke `codagent:push-pr` to commit, push, and create or update the pull request.

If push-pr fails (e.g. no remote, auth error), report the error and stop.

### Step 2 — Wait for CI

Invoke `codagent:wait-ci` to poll CI status and gather review comments.

The wait-ci skill returns one of four statuses:
- `passed` — CI green, no blocking reviews, no PR comments
- `failed` — CI failures or `CHANGES_REQUESTED` reviews
- `comments` — CI green but PR comments need addressing
- `pending` — checks still running after timeout

### Step 3 — Evaluate result

**On `passed`:** Workflow is complete. Report success with the PR URL. Stop.

**On `pending`:** Report which checks are still running. Use the appropriate tool for asking the user a question or requesting input to ask whether to wait longer or proceed.

**On `failed` or `comments`:** Record the failure signature (the set of failing CI check names, or `comments-only` if CI passed but comments exist), then proceed to Step 4.

### Step 4 — Fix and retry

Check termination rules before attempting a fix:

1. **Max 3 fix cycles.** If this would be the 4th fix attempt, pause immediately — show current CI status and use the appropriate tool for asking the user a question or requesting input to ask how to proceed. Do NOT attempt a 4th cycle.

2. **Same failure persists after 2 fix attempts.** If the failure signature from Step 3 matches the previous cycle's failure signature AND this is the 2nd consecutive attempt at the same failure, pause immediately — explain the persistent failure in detail and use the appropriate tool for asking the user a question or requesting input to ask for guidance. "Same failure" means the identical CI check name(s) appear as failing across two consecutive wait-ci results after fix attempts.

If neither termination rule applies:

- Invoke `codagent:fix-pr` to address CI failures and/or review comments
- Return to Step 2

### Failure tracking

Maintain a running count and history across cycles:

| Cycle | Failure signature                        | Action          |
|-------|------------------------------------------|-----------------|
| 1     | `["lint", "test-unit"]`                  | fix-pr → retry  |
| 2     | `["test-unit"]`                          | fix-pr → retry  |
| 3     | `["test-unit"]`                          | PAUSE (same failure persisted 2 attempts) |

Another example:

| Cycle | Failure signature  | Action          |
|-------|--------------------|-----------------|
| 1     | `["lint"]`         | fix-pr → retry  |
| 2     | `["test-e2e"]`     | fix-pr → retry  |
| 3     | `["test-e2e"]`     | PAUSE (same failure persisted 2 attempts, AND max 3 cycles) |

## Notes

- Can be invoked standalone at any point — gathers its own state from the current branch's PR
- Does NOT archive the change — archiving is a separate step that happens before this skill
- Each sub-skill (`push-pr`, `wait-ci`, `fix-pr`) is independently invocable for ad-hoc use

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [Codagent-AI](https://github.com/Codagent-AI)
- **Source:** [Codagent-AI/agent-skills](https://github.com/Codagent-AI/agent-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-codagent-ai-agent-skills-finalize-pr
- Seller: https://agentstack.voostack.com/s/codagent-ai
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
