SShortSingh.
Back to feed

Block Claude Code from editing .env and .git: deny rules or a 29-line hook

0
·5 views

A earlier guide's shell hook missed file edits, since the agent can change files with its edit tools without running any command. That leaves .env, .git/config, and Claude's own settings open to change, including switching off the guard itself. The article explains two options in Claude Code: a deny rule in settings.json, which the tool enforces directly, and a PreToolUse hook that inspects each edit's path before it runs. Folders like .git and .claude already prompt for approval in default and acceptEdits modes, though not in bypassPermissions mode, and .env is not on that list. The guide provides a 29-line Node.js hook script to block matching paths, and it was tested on Claude Code 2.1.332 against the reference documentation dated 27 November 2026.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Frontend resumes should weave tech keywords into achievement bullets, not tag clouds

A common frontend resume mistake is listing 15 or more technologies in a single skills block, which is viewed as a weak signal. The article argues that keywords like React, TypeScript, and Next.js should appear inside bullets describing concrete work and outcomes. Applicant tracking systems weigh where terms appear and what they sit next to, so context such as performance metrics strengthens a match. Human reviewers also gain confidence when tools are tied to specific projects and measurable impact. The author suggests small edits, such as rewriting the summary and grouping skills into categories, rather than a full resume overhaul.

0
ProgrammingDEV Community ·

Agent Memory Persistence: Splitting Session State from Long-Term Facts

A DEV Community article argues that agent memory persistence across sessions works best with two stores serving different purposes. Redis would hold current session state and recent turns under a time-to-live, keyed by tenant and session. A vector database such as pgvector would store distilled long-term facts, filtered by user before similarity ranking. A background worker would move facts between the two so replies never wait on extraction. The author notes that persisting all memory types in one store is a common design mistake, and that the accompanying code is a reference implementation without run benchmarks.

0
ProgrammingDEV Community ·

Auditable Feature Flags in Node: Linking Toggle Decisions to Notification Delivery

A small feature-flag service helps during delivery incidents only if each toggle decision can be linked to the notification attempt that followed it. The approach stores versioned flag records, evaluates them deterministically, and emits structured decision events that share trace and order identifiers with the delivery worker. Each attempt should form a reconstructable chain from order to flag evaluation to adapter call and provider response. Recording stable fields such as the flag version, adapter choice, and decision reason makes failures easier to group and diagnose, while avoiding the logging of sensitive message or payment data. Stale toggle writes should be rejected through a compare-and-set check, and the article notes that strong consistency across regions involves trade-offs in latency and operational complexity.

0
ProgrammingDEV Community ·

Google Search AI Mode Adds Opt-In Personal Context, Starting With Google Wallet

Google is starting to roll out opt-in personal context connections in Search's AI Mode, with Google Wallet as the first supported app. When a user enables the connection, AI Mode can draw on spending information alongside search results to shape its answers. Integrations with Google Drive and the Gemini app are planned for the coming weeks. Google describes the Wallet and Drive access as read-only, and users can manage connected apps in settings. The initial rollout is limited to eligible users in the U.S. who use English.