> ## Documentation Index
> Fetch the complete documentation index at: https://exosphere-auto-translate-docs-20260626-1023.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Built in policies

title: Built-in Policies
description: "सभी 39 built-in policies जो common agent failure modes को पकड़ते हैं"
icon: shield
------------

failproofai 39 built-in policies के साथ आता है जो common agent failure modes को पकड़ते हैं। प्रत्येक policy एक specific hook event type और tool name पर fires करता है। Nineteen policies parameters स्वीकार करती हैं जो आपको code लिखे बिना उनके behavior को tune करने देती हैं। Five workflow policies एक commit → push → PR → CI pipeline enforce करती हैं जिससे पहले कि Claude रुके।

***

## Overview

Policies को categories में grouped किया गया है:

| Category                                    | Policies                                                                                                                                     | Hook type   |
| ------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| [Dangerous commands](#dangerous-commands)   | block-sudo, block-rm-rf, block-curl-pipe-sh, block-failproofai-commands                                                                      | PreToolUse  |
| [Infra commands](#infra-commands)           | block-kubectl, block-terraform, block-aws-cli, block-gcloud, block-az-cli, block-helm, block-gh-pipeline                                     | PreToolUse  |
| [Secrets (sanitizers)](#secrets-sanitizers) | sanitize-jwt, sanitize-api-keys, sanitize-connection-strings, sanitize-private-key-content, sanitize-bearer-tokens                           | PostToolUse |
| [Environment](#environment)                 | block-env-files, protect-env-vars                                                                                                            | PreToolUse  |
| [File access](#file-access)                 | block-read-outside-cwd, block-secrets-write                                                                                                  | PreToolUse  |
| [Git](#git)                                 | block-push-master, block-work-on-main, block-force-push, warn-git-amend, warn-git-stash-drop, warn-all-files-staged                          | PreToolUse  |
| [Database](#database)                       | warn-destructive-sql, warn-schema-alteration                                                                                                 | PreToolUse  |
| [Warnings](#warnings)                       | warn-large-file-write, warn-package-publish, warn-background-process, warn-global-package-install                                            | PreToolUse  |
| [Package managers](#package-managers)       | prefer-package-manager                                                                                                                       | PreToolUse  |
| [Workflow](#workflow)                       | require-commit-before-stop, require-push-before-stop, require-pr-before-stop, require-no-conflicts-before-stop, require-ci-green-before-stop | Stop        |

* **`block-`** — agent को आगे बढ़ने से रोकता है।
* **`warn-`** — agent को additional context देता है ताकि वह self-correct कर सके।
* **`sanitize-`** — agent को देखने से पहले tool output से sensitive data को scrub करता है।

### Namespaces

प्रत्येक policy एक `<namespace>/<name>` slot में रहती है। Built-in policies **`failproofai/`** namespace में belong करती हैं — उदाहरण के लिए, `failproofai/sanitize-jwt`। Namespace collisions को prevent करता है जब आप similar short names वाली custom या third-party policies भी load करते हैं।

आपके config में आप एक built-in को either its short name या its qualified name से refer कर सकते हैं; दोनों forms same policy को resolve करते हैं:

```json theme={null}
{
  "enabledPolicies": [
    "sanitize-jwt",
    "failproofai/block-rm-rf"
  ]
}
```

अगर एक name में कोई `/` नहीं है, तो failproofai इसे default namespace `failproofai` में treat करता है। Names जिनमें पहले से एक `/` है (जैसे `myorg/foo`, `custom/my-hook`) को as-is रखा जाता है।

* **`require-`** — Stop event को block करता है जब तक कि conditions पूरी न हों।

***

<Tip>
  प्रत्येक policy `policyParams` में एक optional `hint` field को support करती है। Hint को deny या instruct message में append किया जाता है जो Claude देखता है, actionable guidance देता है बिना policy code को modify किए। Built-in, custom, और convention policies के साथ काम करता है। Details के लिए [Configuration → hint](/hi/configuration#hint-cross-cutting) देखें।
</Tip>

***

## Dangerous commands

Agents को ऐसे operations चलाने से prevent करें जो undo करना मुश्किल हैं या host system को damage कर सकते हैं।

### `block-sudo`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `sudo` command को deny करता है।

`sudo` keyword को contain करने वाले invocations को block करता है। Pattern matching parsed command tokens पर किया जाता है, raw string पर नहीं, shell operator injection के माध्यम से bypass को prevent करने के लिए।

**Parameters:**

| Param           | Type       | Default | Description                                                                                                  |
| --------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| `allowPatterns` | `string[]` | `[]`    | Exact command prefixes जो permitted हैं। प्रत्येक entry को parsed argv tokens के विरुद्ध match किया जाता है। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-sudo": {
      "allowPatterns": ["sudo systemctl status", "sudo journalctl"]
    }
  }
}
```

इस config के साथ, `sudo systemctl status nginx` को allow किया जाता है, लेकिन `sudo rm /etc/hosts` को deny किया जाता है।

<Note>
  Patterns को parsed tokens के विरुद्ध match किया जाता है, raw command string के विरुद्ध नहीं। यह appended shell operators के माध्यम से bypass को prevent करता है (जैसे `sudo systemctl status x; rm -rf /` को `sudo systemctl status *` के विरुद्ध match नहीं किया जाता)।
</Note>

***

### `block-rm-rf`

**Event:** PreToolUse (Bash)\
**Default:** `rm -rf`, `rm -fr`, और similar recursive deletion forms को deny करता है।

**Parameters:**

| Param        | Type       | Default | Description                                                     |
| ------------ | ---------- | ------- | --------------------------------------------------------------- |
| `allowPaths` | `string[]` | `[]`    | Paths जो recursively delete करने के लिए safe हैं (जैसे `/tmp`)। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-rm-rf": {
      "allowPaths": ["/tmp", "/var/cache"]
    }
  }
}
```

***

### `block-curl-pipe-sh`

**Event:** PreToolUse (Bash)\
**Default:** `curl <url> | bash`, `curl <url> | sh`, `wget <url> | bash`, और similar patterns को deny करता है।

कोई parameters नहीं।

***

### `block-failproofai-commands`

**Event:** PreToolUse (Bash)\
**Default:** Commands को deny करता है जो failproofai को uninstall या disable करेंगे (जैसे `npm uninstall failproofai`, `failproofai policies --uninstall`)।

कोई parameters नहीं।

***

## Infra commands

Coding agents को infrastructure CLIs चलाने या CI/CD pipelines trigger करने से रोकें। इस category में सभी policies **opt-in** हैं (`defaultEnabled: false`) — agents जिन्हें legitimately `kubectl`, `terraform`, आदि को call करने की जरूरत है, वे policy के enabled न होने तक disrupted नहीं होंगे। जब enabled हो, तो matched CLI के हर invocation को deny किया जाता है जब तक कि command `allowPatterns` में एक entry से match न हो।

Pattern grammar [`block-sudo`](#block-sudo) जैसा ही है: tokens को parsed argv के विरुद्ध match किया जाता है, `*` एक token के लिए wildcard है, और किसी भी command जिसमें standalone shell operator (`&&`, `||`, `|`, `;`) या embedded shell metacharacters वाला token है, को injection bypasses को prevent करने के लिए allowlist matching से पहले reject किया जाता है।

### `block-kubectl`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `kubectl` invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                                |
| --------------- | ---------- | ------- | ------------------------------------------ |
| `allowPatterns` | `string[]` | `[]`    | kubectl command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-kubectl": {
      "allowPatterns": ["kubectl get *", "kubectl describe *", "kubectl logs *"]
    }
  }
}
```

इस config के साथ, `kubectl get pods` को allow किया जाता है लेकिन `kubectl apply -f deploy.yaml` को deny किया जाता है।

***

### `block-terraform`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `terraform` या `tofu` (OpenTofu) invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                                       |
| --------------- | ---------- | ------- | ------------------------------------------------- |
| `allowPatterns` | `string[]` | `[]`    | terraform/tofu command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-terraform": {
      "allowPatterns": ["terraform plan", "terraform validate", "terraform show *"]
    }
  }
}
```

***

### `block-aws-cli`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `aws` CLI invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                                |
| --------------- | ---------- | ------- | ------------------------------------------ |
| `allowPatterns` | `string[]` | `[]`    | aws CLI command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-aws-cli": {
      "allowPatterns": ["aws s3 ls *", "aws sts get-caller-identity"]
    }
  }
}
```

***

### `block-gcloud`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `gcloud` (Google Cloud) CLI invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                               |
| --------------- | ---------- | ------- | ----------------------------------------- |
| `allowPatterns` | `string[]` | `[]`    | gcloud command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-gcloud": {
      "allowPatterns": ["gcloud auth list", "gcloud config list"]
    }
  }
}
```

***

### `block-az-cli`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `az` (Azure) CLI invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                               |
| --------------- | ---------- | ------- | ----------------------------------------- |
| `allowPatterns` | `string[]` | `[]`    | az CLI command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-az-cli": {
      "allowPatterns": ["az account show", "az group list"]
    }
  }
}
```

***

### `block-helm`

**Event:** PreToolUse (Bash)\
**Default:** किसी भी `helm` invocation को deny करता है।

**Parameters:**

| Param           | Type       | Default | Description                             |
| --------------- | ---------- | ------- | --------------------------------------- |
| `allowPatterns` | `string[]` | `[]`    | helm command prefixes जो permitted हैं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-helm": {
      "allowPatterns": ["helm list", "helm status *"]
    }
  }
}
```

***

### `block-gh-pipeline`

**Event:** PreToolUse (Bash)\
**Default:** निम्नलिखित `gh` CLI subcommands को deny करता है जो state mutate करते हैं या pipelines trigger करते हैं:

* `gh workflow run`, `gh workflow enable`, `gh workflow disable`
* `gh run rerun`, `gh run cancel`
* `gh pr merge`
* `gh release create`, `gh release delete`
* `gh cache delete`
* `gh secret set`, `gh secret delete`

Read-only `gh` subcommands जैसे `gh pr view`, `gh pr list`, `gh run list`, `gh release view`, और `gh api repos/.../...` को इस policy द्वारा match **नहीं** किया जाता है — वे workflow checks के लिए routinely needed हैं (failproofai के अपने `require-ci-green-before-stop` सहित)।

**Parameters:**

| Param           | Type       | Default | Description                                                                           |
| --------------- | ---------- | ------- | ------------------------------------------------------------------------------------- |
| `allowPatterns` | `string[]` | `[]`    | Specific scripted invocations को allow करने के लिए भले ही वे otherwise deny किए जाएं। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-gh-pipeline": {
      "allowPatterns": ["gh run rerun *"]
    }
  }
}
```

***

## Secrets (sanitizers)

Agents को अपने context या output में credentials leak करने से रोकें। Sanitizer policies **PostToolUse** events पर fire करती हैं। जब Claude एक Bash command चलाता है, एक file को read करता है, या कोई भी tool को call करता है, तो ये policies output को inspect करती हैं इससे पहले कि वह Claude को return किया जाए। अगर एक secret pattern detect होता है, तो policy एक deny decision return करता है जो output को pass back होने से prevent करता है।

### `sanitize-jwt`

**Event:** PostToolUse (all tools)\
**Default:** JWT tokens को redact करता है (three base64url segments separated by `.`)।

कोई parameters नहीं।

***

### `sanitize-api-keys`

**Event:** PostToolUse (all tools)\
**Default:** Common API key formats को redact करता है: Anthropic (`sk-ant-`), OpenAI (`sk-`), GitHub PATs (`ghp_`), AWS access keys (`AKIA`), Stripe keys (`sk_live_`, `sk_test_`), और Google API keys (`AIza`)।

**Parameters:**

| Param                | Type                                 | Default | Description                                                        |
| -------------------- | ------------------------------------ | ------- | ------------------------------------------------------------------ |
| `additionalPatterns` | `{ regex: string; label: string }[]` | `[]`    | Additional regex patterns को secrets के रूप में treat करने के लिए। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "sanitize-api-keys": {
      "additionalPatterns": [
        { "regex": "myco_[A-Za-z0-9]{32}", "label": "MyCo internal API key" },
        { "regex": "pat_[0-9a-f]{40}", "label": "Internal PAT" }
      ]
    }
  }
}
```

***

### `sanitize-connection-strings`

**Event:** PostToolUse (all tools)\
**Default:** Database connection strings को redact करता है जिनमें embedded credentials हैं (जैसे `postgresql://user:password@host/db`)।

कोई parameters नहीं।

***

### `sanitize-private-key-content`

**Event:** PostToolUse (all tools)\
**Default:** PEM blocks को redact करता है (`-----BEGIN PRIVATE KEY-----`, `-----BEGIN RSA PRIVATE KEY-----`, आदि)।

कोई parameters नहीं।

***

### `sanitize-bearer-tokens`

**Event:** PostToolUse (all tools)\
**Default:** `Authorization: Bearer <token>` headers को redact करता है जहाँ token 20 या अधिक characters है।

कोई parameters नहीं।

***

## Environment

Sensitive environment configuration को agents द्वारा read या expose किए जाने से protect करें।

### `block-env-files`

**Event:** PreToolUse (Bash, Read)\
**Default:** `.env` files को read करने को deny करता है via `cat .env`, Read tool calls with `.env` as the file path, आदि।

`.envrc` या अन्य environment-adjacent files को block नहीं करता - केवल exactly `.env` नामक files को।

कोई parameters नहीं।

***

### `protect-env-vars`

**Event:** PreToolUse (Bash)\
**Default:** Commands को deny करता है जो environment variables को print करते हैं: `printenv`, `env`, `echo $VAR`।

कोई parameters नहीं।

***

## File access

Agents को project boundaries के अंदर काम करने और sensitive files से दूर रखें।

### `block-read-outside-cwd`

**Event:** PreToolUse (Read, Bash)\
**Default:** Project root के बाहर files को read करने को deny करता है। Boundary `CLAUDE_PROJECT_DIR` है (Claude Code द्वारा प्रति session में set किया गया), जिसका fallback session के current working directory में है जब वह variable unset हो। Live `cwd` की बजाय project root का use करने का मतलब है कि boundary stable रहता है भले ही Claude किसी subdirectory में `cd` करे।

**Parameters:**

| Param        | Type       | Default | Description                                                                 |
| ------------ | ---------- | ------- | --------------------------------------------------------------------------- |
| `allowPaths` | `string[]` | `[]`    | Absolute path prefixes जो permitted हैं भले ही वे project root के बाहर हों। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-read-outside-cwd": {
      "allowPaths": ["/shared/data", "/opt/company/config"]
    }
  }
}
```

***

### `block-secrets-write`

**Event:** PreToolUse (Write, Edit)\
**Default:** Files में writes को deny करता है जो commonly private keys और certificates के लिए use होती हैं: `id_rsa`, `id_ed25519`, `*.key`, `*.pem`, `*.p12`, `*.pfx`।

**Parameters:**

| Param                | Type       | Default | Description                                                     |
| -------------------- | ---------- | ------- | --------------------------------------------------------------- |
| `additionalPatterns` | `string[]` | `[]`    | Additional filename patterns (glob-style) को block करने के लिए। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-secrets-write": {
      "additionalPatterns": [".token", ".secret"]
    }
  }
}
```

***

## Git

Accidental pushes, force-pushes, और branch mistakes को prevent करें जो undo करना मुश्किल हैं।

### `block-push-master`

**Event:** PreToolUse (Bash)\
**Default:** `git push origin main` और `git push origin master` को deny करता है।

**Parameters:**

| Param               | Type       | Default              | Description                                        |
| ------------------- | ---------- | -------------------- | -------------------------------------------------- |
| `protectedBranches` | `string[]` | `["main", "master"]` | Branch names जो directly को push नहीं किए जा सकते। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "block-push-master": {
      "protectedBranches": ["main", "master", "release", "prod"]
    }
  }
}
```

<Tip>
  सभी branches को push करने की allow देने के लिए (effectively इस policy को `enabledPolicies` से remove किए बिना disable करने के लिए), `protectedBranches: []` set करें।
</Tip>

***

### `block-work-on-main`

**Event:** PreToolUse (Bash)\
**Default:** `git commit`, `git merge`, `git rebase`, और `git cherry-pick` को deny करता है जबकि working tree `main` या `master` पर है। Branch creation और switching (`git checkout`, `git checkout -b`, `git switch`, `git switch -c`) को affected नहीं किया जाता।

**Parameters:**

| Param               | Type       | Default              | Description                                                               |
| ------------------- | ---------- | -------------------- | ------------------------------------------------------------------------- |
| `protectedBranches` | `string[]` | `["main", "master"]` | Branch names जिन पर commit/merge/rebase/cherry-pick को deny किया जाता है। |

***

### `block-force-push`

**Event:** PreToolUse (Bash)\
**Default:** `git push --force` और `git push -f` को deny करता है।

कोई policy-specific parameters नहीं। Cross-cutting [`hint`](/hi/configuration#hint-cross-cutting) का use करके alternatives suggest करें:

```json theme={null}
{
  "policyParams": {
    "block-force-push": {
      "hint": "अपने current HEAD से एक new branch create करें (जैसे `git checkout -b <new-branch>`) और उसे instead push करें।"
    }
  }
}
```

***

### `warn-git-amend`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `git commit --amend` चलाते समय carefully proceed करने के लिए instruct करता है। Command को block नहीं करता।

कोई parameters नहीं।

***

### `warn-git-stash-drop`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `git stash drop` चलाने से पहले confirm करने के लिए instruct करता है। Command को block नहीं करता।

कोई parameters नहीं।

***

### `warn-all-files-staged`

**Event:** PreToolUse (Bash)\
**Default:** Claude को review करने के लिए instruct करता है कि वह क्या stage कर रहा है जब `git add -A` या `git add .` चलाता है। Command को block नहीं करता।

कोई parameters नहीं।

***

## Database

Destructive SQL operations को catch करें इससे पहले कि वे आपके database के विरुद्ध execute हों।

### `warn-destructive-sql`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `DROP TABLE`, `DROP DATABASE`, या `WHERE` clause के बिना `DELETE` contain करने वाले SQL को confirm करने से पहले instruct करता है।

कोई parameters नहीं।

***

### `warn-schema-alteration`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `ALTER TABLE` statements चलाने से पहले confirm करने के लिए instruct करता है।

कोई parameters नहीं।

***

## Warnings

Agents को potentially risky लेकिन non-destructive operations से पहले extra context दें।

### `warn-large-file-write`

**Event:** PreToolUse (Write)\
**Default:** Claude को 1024 KB से बड़ी files को write करने से पहले confirm करने के लिए instruct करता है।

**Parameters:**

| Param         | Type     | Default | Description                                                                  |
| ------------- | -------- | ------- | ---------------------------------------------------------------------------- |
| `thresholdKb` | `number` | `1024`  | File size threshold (kilobytes में) जिससे ऊपर एक warning issue किया जाता है। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "warn-large-file-write": {
      "thresholdKb": 256
    }
  }
}
```

<Note>
  Hook handler 1 MB stdin limit को payloads पर enforce करता है। इस policy को small content के साथ test करने के लिए, `thresholdKb` को 1024 के well below एक value में set करें।
</Note>

***

### `warn-package-publish`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `npm publish` चलाने से पहले confirm करने के लिए instruct करता है।

कोई parameters नहीं।

***

### `warn-background-process`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `nohup`, `&`, `disown`, या `screen` via background processes launch करते समय careful होने के लिए instruct करता है।

कोई parameters नहीं।

***

### `warn-global-package-install`

**Event:** PreToolUse (Bash)\
**Default:** Claude को `npm install -g`, `yarn global add`, या `pip install` without a virtual environment चलाने से पहले confirm करने के लिए instruct करता है।

कोई parameters नहीं।

***

## Package managers

Enforce करें कि agent कौन से package managers use करने की allow दी जाती है।

### `prefer-package-manager`

**Event:** PreToolUse (Bash)\
**Default:** Disabled। जब enabled हो, तो किसी भी package manager command को block करता है जो `allowed` list में नहीं है और Claude को एक allowed manager का use करके command को rewrite करने के लिए बताता है।

Detects: pip, pip3, python -m pip, npm, npx, yarn, pnpm, pnpx, bun, bunx, uv, poetry, pipenv, conda, cargo।

| Parameter | Type      | Default | Description                                                                                                                            |
| --------- | --------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `allowed` | string\[] | `[]`    | Allowed package manager names। कोई भी detected manager जो इस list में नहीं है, को block किया जाता है। जब empty हो, policy एक no-op है। |
| `blocked` | string\[] | `[]`    | Additional manager names को built-in list के beyond block करने के लिए (जैसे `['pdm', 'pipx']`)।                                        |

Built-in block list में शामिल है: pip, pip3, npm, npx, yarn, pnpm, pnpx, bun, bunx, uv, poetry, pipenv, conda, cargo। इस list में नहीं managers को append करने के लिए `blocked` का use करें।

**Example configuration:**

```json theme={null}
{
  "enabledPolicies": ["prefer-package-manager"],
  "policyParams": {
    "prefer-package-manager": {
      "allowed": ["uv", "bun"],
      "blocked": ["pdm", "pipx"]
    }
  }
}
```

इस config के साथ, `pip install flask` और `pdm install flask` दोनों को deny किया जाता है एक message के साथ जो Claude को `uv` या `bun` use करने के लिए बताता है। Commands जैसे `uv pip install flask` को allow किया जाता है क्योंकि `uv` allowlist में है और पहले check किया जाता है।

***

## AI behavior

Detect करें कि जब agents stuck हों या unexpectedly behave करें।

### `warn-repeated-tool-calls`

**Event:** PreToolUse (all tools)\
**Default:** Claude को reconsider करने के लिए instruct करता है जब same tool को 3+ times identical parameters के साथ call किया जाता है - एक common sign है कि agent एक loop में stuck है।

कोई parameters नहीं।

***

## Workflow

एक disciplined end-of-session workflow को enforce करें। ये policies **Stop** event पर fire करती हैं और agent को stopping से deny करती हैं जब तक कि प्रत्येक condition पूरी न हो। वे एक natural dependency chain को follow करती हैं: commit → push → PR → CI। अगर एक policy deny करती है, तो chain में later policies को skip किया जाता है (deny short-circuits)।

सभी workflow policies **fail-open** हैं: अगर required tool available नहीं है (जैसे `gh` installed न हो, कोई git remote न हो), तो policy allow करती है एक informational message के साथ जो समझाता है कि check को क्यों skip किया गया।

### Per-CLI Stop semantics

Stop enforcement सातों supported CLIs में slightly अलग दिखाई देता है क्योंकि प्रत्येक एक अलग expose करता है "agent finished" hook contract। **Outcome** same है — agent stopping से दूर नहीं हो सकता जबकि एक workflow gate failing है — लेकिन **mechanics** अलग हैं। नीचे दी गई table एक summary देती है; केवल Pi के पास एक user-visible quirk है जिसे समझने की जरूरत है इससे पहले कि आप एक `require-*-before-stop` policy को enable करें।

| CLI                      | When the gate fires          | What you see                                                                                                                                                                                                                                                                                                                                                 |
| ------------------------ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Claude Code              | Same agent loop, immediately | Claude continues working — fixes the issue, then attempts to finish again. No interruption visible to you.                                                                                                                                                                                                                                                   |
| Codex                    | Same agent loop, immediately | Same as Claude.                                                                                                                                                                                                                                                                                                                                              |
| GitHub Copilot CLI       | Same agent loop, immediately | Same as Claude (uses Copilot's `{decision:"block", reason}` retry channel — verified empirically against Copilot CLI 1.0.41).                                                                                                                                                                                                                                |
| Cursor Agent             | Same agent loop, immediately | Same as Claude (uses Cursor's `{followup_message}` channel — capped at `loop_limit`, default 5 retries).                                                                                                                                                                                                                                                     |
| Gemini CLI               | Same agent loop, immediately | Same as Claude (uses Gemini's `{decision:"block", reason}` channel on `AfterAgent`).                                                                                                                                                                                                                                                                         |
| OpenCode                 | Same agent loop, immediately | Same as Claude (uses OpenCode's `client.session.prompt(...)` SDK call routed through `hookSpecificOutput.additionalContext`).                                                                                                                                                                                                                                |
| **Pi (pi-coding-agent)** | **Next user turn**           | **Pi visibly stops** when the gate fires — its agent loop exits and you're returned to the prompt. The gate then fires the next time you submit a prompt: failproofai prepends a `MANDATORY ACTION REQUIRED` directive to that turn's system prompt, instructing the LLM to complete the workflow step (commit, push, etc.) before doing whatever you asked. |

<Note>
  **Pi limitation।** Pi का `AgentEndEvent` (Claude's `Stop` hook का upstream equivalent) का कोई Result type नहीं है — जिस time it fires तक, Pi का agent loop पहले ही exit हो चुका है। Pi को force नहीं किया जा सकता same loop को retry करने के लिए उसी तरह जैसे Claude / Copilot / Cursor / Gemini / OpenCode को कर सकते हैं। failproofai gate को Pi's `before_agent_start` event में shift करता है (जो next user prompt के बाद fires) ताकि workflow check अभी भी enforce हो, बस current one की बजाय next turn पर।

  **What this means in practice:**

  * Pi के stop करने के बाद, deny reason को in-memory capture किया जाता है keyed by Pi session id। बिल्कुल next prompt जो आप same Pi process में submit करते हैं वह इसे drains करता है: LLM को अपने system prompt के top पर `MANDATORY ACTION REQUIRED` directive दिखाई देता है, commits (या pushes / PR को open करता है / CI की wait करता है), और केवल तब आपकी request के साथ continue करता है। Captured deny reason one-shot है — एक बार drain होने के बाद, gate clear है।
  * Gate Pi की process lifetime से bounded है। अगर आप Pi को `Ctrl+C` करते हैं या turns के बीच quit करते हैं, तो in-memory entry को process के साथ drop किया जाता है और gate को miss किया जाता है। Claude, Copilot, Cursor, Gemini, और OpenCode की same bound है (agent को kill करो और gate miss हो जाता है) — Pi सिर्फ इसे अधिक visible बनाता है क्योंकि agent visibly exit करता है gate के fire होने से पहले।
  * एक pending deny को भी किसी भी reason (`new` / `resume` / `fork` / `quit`) से `session_shutdown` पर clear किया जाता है, इसलिए एक stale gate एक prior session से same Pi process में start किए गए fresh session में leak नहीं कर सकता।

  अगर आपको Claude-style same-loop retry की जरूरत है, तो अपनी `Stop` policies को किसी अन्य छः supported CLIs के under run करें। हम Pi upstream को track कर रहे हैं future के लिए एक Result type के साथ `AgentEndEvent` पर जो हमें इस gap को close करने देगा।
</Note>

### `require-commit-before-stop`

**Event:** Stop\
**Default:** Stopping को deny करता है जब uncommitted changes हों (modified, staged, या untracked files)। Working directory clean होने पर एक informational message return करता है।

कोई parameters नहीं।

***

### `require-push-before-stop`

**Event:** Stop\
**Default:** Stopping को deny करता है जब unpushed commits हों या जब current branch का कोई remote tracking branch न हो। Suggest करता है `git push -u` एक tracking branch create करने के लिए अगर needed है। अगर कोई remote configured न हो तो fail open करता है।

**Parameters:**

| Param    | Type     | Default    | Description                    |
| -------- | -------- | ---------- | ------------------------------ |
| `remote` | `string` | `"origin"` | Remote name जिसे push करना है। |

**Example:**

```json theme={null}
{
  "policyParams": {
    "require-push-before-stop": {
      "remote": "upstream"
    }
  }
}
```

***

### `require-pr-before-stop`

**Event:** Stop\
**Default:** Stopping को deny करता है जब current branch के लिए कोई pull request न exist करे, या जब existing PR को बिना merge किए close किया गया हो। Claude को `gh pr create` के साथ एक PR create करने के लिए instruct करता है। जब PR को **merge** किया जाता है, तो policy allow करती है (work ship हो गया है) और message एक hint देता है branch को switch करने के लिए (`git checkout main && git pull`)।

कोई parameters नहीं।

<Note>
  इस policy को [GitHub CLI](https://cli.github.com/) (`gh`) को installed और authenticated होने की जरूरत है।
  `gh auth login` को एक personal access token के साथ run करें जिसके पास pull requests को read access करने के लिए `repo` scope है। अगर `gh` installed न हो या authenticated न हो, तो policy fail open करती है और reason को Claude को report करती है।
</Note>

***

### `require-no-conflicts-before-stop`

**Event:** Stop\
**Default:** Stopping को deny करता है जब current branch को cleanly base branch में merge न किया जा सके। Policy पहले confirm करती है कि GitHub पर branch के लिए एक `OPEN` PR है — बिना एक के, कोई merge target नहीं है enforcement के लिए, इसलिए entire policy short-circuits to allow। एक बार `OPEN` PR confirm हो जाने के बाद, दो independent probes run करते हैं:

1. **Local** — `git merge-tree --write-tree --name-only origin/<baseBranch> HEAD`। Conflict पर, deny message conflicted files को name करता है ताकि Claude को exactly पता हो क्या resolve करना है।
2. **GitHub** — `gh pr view --json mergeable,state` result को reuse करता है पहले से fetched। Conflicts को catch करता है जो एक stale local `origin/<baseBranch>` को miss करने दे सकते हैं (जैसे कोई `main` पर एक conflicting PR land करने के बाद since last fetch)। एक `CONFLICTING` result deny करता है। एक `UNKNOWN` result भी deny करता है और Claude को \~10 seconds wait करने और फिर से check करने से पहले stop attempt करने से पहले instruct करता है — यह same-loop false negatives को prevent करता है जबकि GitHub recompute करता है।

Entirely skip करता है (allow करता है) जब: `gh` installed न हो, branch के लिए कोई PR न exist करे, PR का state `OPEN` न हो (जैसे `MERGED`, `CLOSED`), या `gh pr view` unparseable output return करे। भी fail open करता है जब `origin/<baseBranch>` locally missing हो या जब कोई commits base से ahead न हों — वे Layer 1 fall-throughs अभी भी cached PR mergeability consult करते हैं allow करने से पहले।

**Parameters:**

| Param        | Type     | Default  | Description                                        |
| ------------ | -------- | -------- | -------------------------------------------------- |
| `baseBranch` | `string` | `"main"` | Base branch को conflicts के लिए check करने के लिए। |

<Note>
  इस policy के लिए GitHub CLI (`gh`) required है। Policy एक `OPEN` PR को confirm करने के लिए `gh pr view` का use करती है exist करता है कोई conflict probe run करने से पहले — बिना `gh` के, policy short-circuits to allow करती है। `gh auth login` को एक personal access token के साथ run करें जिसके पास pull requests को read access करने के लिए `repo` scope है।
</Note>

***

### `require-ci-green-before-stop`

**Event:** Stop\
**Default:** Stopping को deny करता है जब CI checks fail हों या current branch पर अभी भी run हो रहे हों। दोनों GitHub Actions workflow runs और third-party bot checks को check करता है (जैसे CodeRabbit, SonarCloud, Codecov)। `skipped`, `cancelled`, और `neutral` conclusions को non-failing के रूप में treat करता है (latter example covers जैसे Socket Security alerts on outside contributor PRs, जहाँ app intentionally `neutral` report करता है बजाय success/failure के)। जब सभी checks pass करते हैं एक informational message return करता है।

कोई parameters नहीं।

<Note>
  इस policy को [GitHub CLI](https://cli.github.com/) (`gh`) को installed और authenticated होने की जरूरत है।
  `gh auth login` को एक personal access token के साथ run करें जिसके पास `repo` scope है Actions workflow runs और Checks API को read access करने के लिए। अगर `gh` installed न हो या authenticated न हो, तो policy fail open करती है और reason को Claude को report करती है।
</Note>

***

***

## Disabling individual policies

अपने config में `enabledPolicies` से एक specific policy को remove करें, या dashboard के Policies tab में इसे toggle off करें।

```json theme={null}
{
  "enabledPolicies": [
    "block-rm-rf",
    "sanitize-api-keys"
  ]
}
```

Policies जो `enabledPolicies` में listed न हों, run नहीं करती, भले ही `policyParams` entries उनके लिए exist करें।
