> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getshrike.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# GitHub Action

> Generate an advisory or gated Shrike workflow with ci install, or wire the Action manually for read-only delta mode or a verified cleanup PR.

The Shrike Action is a thin wrapper around the CLI. `mode: delta` reports newly dead code without changing files; `mode: prune` produces a verified cleanup PR.

## Generate a workflow

```bash theme={null}
npx shrike ci install
```

Expected: `created .github/workflows/shrike.yml` with an advisory delta workflow. The default is `fail-on: never` and `permissions: contents: read`. Nothing is committed, pushed, or analyzed by the installer.

```bash theme={null}
npx shrike ci install --dry-run       # print the YAML, write nothing
npx shrike ci install --gate          # make newly dead code blocking
npx shrike ci install --path .github/workflows/shrike-delta.yaml
npx shrike ci install --base origin/main --max-items 25
```

| Flag | Effect |
| - | - |
| `--gate` | Sets `fail-on: newly-dead` and adds `pull-requests: write` to the generated permissions. Without it, the workflow is advisory. |
| `--path <path>` | Workflow path inside `.github/workflows/`, ending in `.yml` or `.yaml`. |
| `--base <ref>` | Base ref passed to the Action. Default `origin/main`. |
| `--max-items <n>` | Fail when the delta exceeds this many items. `0` disables the cap. |
| `--dry-run` | Print the generated YAML and write nothing. |
| `--force` | Replace an existing file that is not Shrike-managed. |
| `--json` | Return `{ path, action, mode, base, gate }`, plus `dryRun: true` when `--dry-run` is set. |

The installer is conservative:

* It refuses absolute paths, `..`, paths outside `.github/workflows/`, and symlinks that escape the repository.
* An identical workflow is `unchanged`. A different file is `skipped` with exit `2` unless you pass `--force`.
* It never edits another workflow file, including `.github/workflows/ci.yml`.
* It never runs analysis, project scripts, or network requests, and never uses secrets.

> [!NOTE]
>
> The generated workflow references `getshrike/shrike/packages/action@v1`. The Action resolves a project-local `getshrike` install (or `SHRIKE_CLI`). Keep `getshrike` in the project's `devDependencies`, or add an install step before the Action, so the workflow can run.

The advisory workflow:

```yaml theme={null}
# Generated by shrike ci install
# Advisory by default: report dead weight and newly dead code without
# failing the pull request. Use --gate to make newly dead code blocking.
name: shrike

on:
  pull_request:

permissions:
  contents: read

jobs:
  shrike:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: getshrike/shrike/packages/action@v1
        with:
          mode: delta
          base: origin/main
          fail-on: never
          max-items: "0"
```

With `--gate`, the generated workflow sets `fail-on: newly-dead` and permissions become:

```yaml theme={null}
permissions:
  contents: read
  pull-requests: write
```

## Action inputs and outputs

| Input | Default | Purpose |
| - | - | - |
| `mode` | `delta` | `delta` (read-only) or `prune` (verified cleanup PR). |
| `base` | empty | Base git ref. Falls back to `GITHUB_BASE_REF`, then `origin/main`. |
| `max-items` | `0` | In delta mode, fail when the item count exceeds this value. `0` disables the cap. |
| `fail-on` | `never` | In delta mode, `newly-dead` fails on any newly dead item; `never` fails only through `max-items`. |

| Output | Meaning |
| - | - |
| `count` | Number of newly dead items in delta mode. |
| `delta-path` | Path to the JSON delta artifact, `.shrike/action-delta.json`. |
| `outcome` | Prune outcome. |
| `receipts` | Number of receipts written by prune. |

## Delta mode

Delta mode is read-only. It runs the CLI's `delta` command with `--json --allow-dirty --fail-on never`, writes `.shrike/action-delta.json`, and posts a step summary. It exits `1` when `max-items` is exceeded or when `fail-on: newly-dead` finds anything. It never opens a PR or changes source files.

> [!NOTE]
>
> Grant only `contents: read` for delta mode. The advisory default writes a step summary and artifact, not a PR comment.

```yaml theme={null}
name: Shrike delta
on: [pull_request]

permissions:
  contents: read

jobs:
  shrike:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 24
      - run: npm install --no-save getshrike
      - uses: getshrike/shrike/packages/action@v1
        with:
          mode: delta
          base: origin/${{ github.base_ref }}
          fail-on: newly-dead
```

## Prune mode

Prune mode runs `shrike prune --base <base> --json --pr`, opens a draft PR with `gh`, and writes receipts. It refuses fork pull requests with exit `2` because the write token is not trusted; a missing or unreadable event file on a PR also fails closed.

> [!WARNING]
>
> Prune mode writes commits and opens a pull request. Grant only `contents: write` and `pull-requests: write`. The Action does not need `actions: write`.

```yaml theme={null}
name: Shrike prune
on: [pull_request]

permissions:
  contents: write
  pull-requests: write

jobs:
  shrike:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: actions/setup-node@v4
        with:
          node-version: 24
      - run: npm install --no-save getshrike
      - uses: getshrike/shrike/packages/action@v1
        with:
          mode: prune
          base: origin/${{ github.base_ref }}
```

The Action supplies the GitHub Actions bot git identity when the runner has none, so prune can commit its verified batch. See [Verified pruning](https://docs.getshrike.dev/guides/verified-pruning.md) for verification and receipts.

## Fork pull requests

* **Delta mode** is read-only and safe to run with the default read token on fork PRs.
* **Prune mode** refuses fork PRs rather than using an untrusted write token. Run cleanup from a branch in the main repository, or have a maintainer run it locally.

Do not switch to `pull_request_target` to work around this: it gives a workflow write access in the context of the base repository, which is unsafe for untrusted PR content.

## Next

* [Agent integrations](https://docs.getshrike.dev/guides/agent-integrations.md) — install the skill and hook.
* [Exit codes](https://docs.getshrike.dev/reference/exit-codes.md) — what the Action returns in CI.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.