You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add pre-commit hooks for basic formatting and file sanity checks ⚙️ Configuration changes✨ Enhancement🕐 Less than 5 minutes
Description
• Add standard pre-commit hooks for whitespace, EOF, and debug-statement checks.
• Validate common config file formats (JSON/TOML/YAML) before commits.
• Extend existing pre-commit setup alongside the repo’s local hook.
➖ Requires agreeing on toolchain and config (pyproject, etc.)
2. Enforce the same checks in CI only (or in addition)
➕ Guaranteed enforcement even if developers skip hooks
➕ Centralized, reproducible checks in PR pipeline
➖ Slower feedback loop than local hooks
➖ Still benefits from local pre-commit for fast iteration
Recommendation: The current approach is a good low-friction baseline for repository hygiene. Consider adding CI enforcement for these checks, and optionally introduce language-specific formatters/linters later if the repo needs stricter style guarantees.
• Adds the 'pre-commit/pre-commit-hooks' repository and enables common checks (debug statements, JSON/TOML/YAML validation, whitespace/EOF fixes, private key detection, and test naming). Keeps the existing local hook configuration intact.
1. Prompts checked before unstaged 🐞 Bug☼ Reliability
Description
The newly added pre-commit-hooks (notably trailing-whitespace / end-of-file-fixer /
detect-private-key) will run before the repo’s unstage-ai-prompts hook, so a staged
.prompts/*.md|*.txt file can be rewritten or cause hook failure even though the project intends to
automatically unstage prompt files before committing.
The repo defines .prompts as the prompt-recording directory and explicitly implements
unstage-ai-prompts to remove .prompts/ files from the git index before committing. Adding
general-purpose formatting/security hooks before the local hooks means staged .prompts/* files can
be processed (and potentially fail) prior to being unstaged.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
New generic `pre-commit-hooks` are added ahead of the local `unstage-ai-prompts` hook. If a user accidentally (or forcibly) stages `.prompts/*.md` or `.prompts/*.txt`, these new hooks can run on those files first, potentially modifying them or failing the commit before the safety hook removes them from the index.
## Issue Context
This repo’s design explicitly includes an `unstage-ai-prompts` pre-commit hook to ensure prompt files are never committed.
## Fix Focus Areas
- .pre-commit-config.yaml[1-33]
## Suggested fix
Add a pre-commit-wide exclude for the prompts directory (or per-hook excludes) so formatting/security checks do not run on `.prompts/**` at all, e.g.:
```yaml
exclude: ^\.prompts/
```
Optionally apply `exclude: ^\.prompts/` per hook if you prefer not to exclude prompts from all hooks.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a few pre-commit hooks for formatting the code