Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .failproofai/policies-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"enabledPolicies": [
"sanitize-jwt",
"sanitize-api-keys",
"sanitize-connection-strings",
"sanitize-private-key-content",
"sanitize-bearer-tokens",
"protect-env-vars",
"block-env-files",
"block-read-outside-cwd",
"block-sudo",
"block-curl-pipe-sh",
"block-rm-rf",
"block-failproofai-commands",
"block-secrets-write",
"block-push-master",
"block-force-push",
"block-work-on-main",
"warn-git-amend",
"warn-git-stash-drop",
"warn-all-files-staged",
"warn-destructive-sql",
"warn-schema-alteration",
"warn-package-publish",
"warn-global-package-install",
"warn-large-file-write",
"warn-background-process",
"warn-repeated-tool-calls",
"require-commit-before-stop",
"require-push-before-stop",
"require-pr-before-stop",
"require-ci-green-before-stop"
],
"policyParams": {
"block-force-push": {
"hint": "Create a new branch from your current HEAD (e.g. `git checkout -b <new-branch>`) and push that instead."
}
}
}
25 changes: 25 additions & 0 deletions .failproofai/policies/workflow-policies.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* workflow-policies.mjs — Convention-based workflow policies for this repo
*
* Automatically loaded from .failproofai/policies/ — no config changes needed.
*/
import { customPolicies, allow, instruct } from "failproofai";

// Remind to update CHANGELOG before committing
customPolicies.add({
name: "changelog-check",
description: "Remind Claude to update CHANGELOG.md before committing",
match: { events: ["PreToolUse"] },
fn: async (ctx) => {
if (ctx.toolName !== "Bash") return allow();
const cmd = String(ctx.toolInput?.command ?? "");
if (/git\s+commit/.test(cmd)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Broaden commit detection to avoid missing valid git commit forms.

Current regex can miss commands like git -c key=value commit -m ..., so reminders won’t trigger consistently.

🔧 Proposed fix
-    if (/git\s+commit/.test(cmd)) {
+    const isGitCommit =
+      /^\s*(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)*git(?:\s+-\S+)*\s+commit\b/.test(cmd);
+    if (isGitCommit) {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (/git\s+commit/.test(cmd)) {
const isGitCommit =
/^\s*(?:[A-Za-z_][A-Za-z0-9_]*=\S+\s+)*git(?:\s+-\S+)*\s+commit\b/.test(cmd);
if (isGitCommit) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.failproofai/policies/workflow-policies.mjs at line 16, Replace the narrow
regex /git\s+commit/ with a broader pattern that allows intervening git options
(e.g., -c key=value or other flags) between "git" and "commit"; in other words,
change the condition that currently tests /git\s+commit/ so it matches "git"
followed by zero or more space‑separated tokens (including tokens starting with
'-') and then "commit", and ensure you use a word boundary so only actual commit
commands match.

return instruct(
"Check whether CHANGELOG.md needs an update for this commit. " +
"Every PR must include an entry under the `## Unreleased` section. " +
"Use the appropriate subsection: Features, Fixes, Docs, or Dependencies."
);
}
return allow();
},
});
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

### Features
- Add `changelog-check` convention policy to remind agent to update CHANGELOG before committing

### Docs
- Document cross-cutting `hint` param in built-in policies reference and add `block-force-push` hint example
- Add `block-force-push` hint to project config suggesting fresh branch as alternative

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Add PR numbers to the new Unreleased bullets.

These entries should include the PR reference suffix to match the repo changelog convention.

✏️ Proposed fix
 ### Features
-- Add `changelog-check` convention policy to remind agent to update CHANGELOG before committing
+- Add `changelog-check` convention policy to remind agent to update CHANGELOG before committing (`#94`)

 ### Docs
-- Document cross-cutting `hint` param in built-in policies reference and add `block-force-push` hint example
-- Add `block-force-push` hint to project config suggesting fresh branch as alternative
+- Document cross-cutting `hint` param in built-in policies reference and add `block-force-push` hint example (`#94`)
+- Add `block-force-push` hint to project config suggesting fresh branch as alternative (`#94`)

Based on learnings: Update CHANGELOG.md in every PR under ## Unreleased, and include PR numbers per entry (e.g., (#123)).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- Add `changelog-check` convention policy to remind agent to update CHANGELOG before committing
### Docs
- Document cross-cutting `hint` param in built-in policies reference and add `block-force-push` hint example
- Add `block-force-push` hint to project config suggesting fresh branch as alternative
- Add `changelog-check` convention policy to remind agent to update CHANGELOG before committing (`#94`)
### Docs
- Document cross-cutting `hint` param in built-in policies reference and add `block-force-push` hint example (`#94`)
- Add `block-force-push` hint to project config suggesting fresh branch as alternative (`#94`)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` around lines 6 - 10, Update the bullets under the "##
Unreleased" section (e.g., the lines mentioning "Add `changelog-check`
convention policy" and the "Docs" bullets about `hint` and `block-force-push`)
to append the PR reference suffix for each entry (format: " (`#123`)") so every
Unreleased bullet includes its PR number; ensure the PR id is accurate for each
item and preserve existing wording and markdown structure.


## 0.0.2-beta.7 — 2026-04-14

### Features
Expand Down
18 changes: 17 additions & 1 deletion docs/built-in-policies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ Policies are grouped into categories:

---

<Tip>
Every policy supports an optional `hint` field in `policyParams`. The hint is appended to the deny or instruct message Claude sees, giving actionable guidance without modifying policy code. Works with built-in, custom, and convention policies. See [Configuration → hint](/configuration#hint-cross-cutting) for details.
</Tip>

---

## Dangerous commands

Prevent agents from running operations that are hard to undo or that could damage the host system.
Expand Down Expand Up @@ -307,7 +313,17 @@ To allow pushing to all branches (effectively disabling this policy without remo
**Event:** PreToolUse (Bash)
**Default:** Denies `git push --force` and `git push -f`.

No parameters.
No policy-specific parameters. Use the cross-cutting [`hint`](/configuration#hint-cross-cutting) to suggest alternatives:

```json
{
"policyParams": {
"block-force-push": {
"hint": "Create a new branch from your current HEAD (e.g. `git checkout -b <new-branch>`) and push that instead."
}
}
}
```

---

Expand Down