Skip to content

fix: scope git add to vault directories in auto-commit.sh#40

Open
xiaolai wants to merge 1 commit intoagenticnotetaking:mainfrom
xiaolai:fix/nlpm-auto-commit-git-add-scope
Open

fix: scope git add to vault directories in auto-commit.sh#40
xiaolai wants to merge 1 commit intoagenticnotetaking:mainfrom
xiaolai:fix/nlpm-auto-commit-git-add-scope

Conversation

@xiaolai
Copy link
Copy Markdown

@xiaolai xiaolai commented Apr 21, 2026

Automated audit: This PR was generated by NLPM, a natural language programming linter, running via claude-code-action. Please evaluate the diff on its merits.

Security Fix (LOW)

File: hooks/scripts/auto-commit.sh:29

The hook used git add -A to stage all tracked and untracked files in the project root. This means any file inadvertently placed in the project directory — dotfiles, credential files, API keys, .env files — would be staged and committed automatically on every Write event without the user noticing.

Fix

Replaced git add -A with explicit paths scoped to the vault's known knowledge directories:

git add notes/ ops/ self/ inbox/ templates/ .arscontexta 2>/dev/null || true

This captures every file the hook is actually designed to commit while leaving anything outside those directories unstaged. The || true ensures the hook exits cleanly if the directories don't exist yet (e.g., early in vault setup).

Note: if your vault uses custom folder names configured in ops/derivation-manifest.md (e.g., reflections/ instead of notes/), you may want to adjust these paths to match. The write-validate.sh hook already scopes to */notes/* and */thinking/* for its checks, and this PR brings auto-commit.sh to the same principle.

Files changed

  • hooks/scripts/auto-commit.sh

git add -A staged every file in the project root, including dotfiles
and credentials that may have been accidentally placed outside the
vault's knowledge directories. Scoping to the known vault paths
(notes/, ops/, self/, inbox/, templates/, .arscontexta) prevents
inadvertent staging of sensitive content while still capturing all
intentional vault writes.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants