D

Deny Sensitive Files Setup

Production-ready setting that handles deny, access, sensitive, files. Includes structured workflows, validation checks, and reusable patterns for permissions.

SettingClipticspermissionsv1.0.0MIT
0 views0 copies

Deny Sensitive Files Setup

Block Claude Code from reading environment files, secrets, and credential configurations.

When to Use This Setting

Apply this setting when you need to:

  • Prevent accidental exposure of API keys, database passwords, and authentication tokens during Claude Code sessions
  • Enforce security policies that restrict AI tool access to sensitive configuration files
  • Create a baseline security layer that protects credentials regardless of other permission settings Consider alternatives when:
  • You need Claude Code to read environment files for debugging configuration issues
  • Your project uses encrypted secrets management and the raw files do not contain plaintext credentials

Quick Start

Configuration

name: deny-sensitive-files-setup type: setting category: permissions

Example Application

claude setting:apply deny-sensitive-files-setup

Example Output

Setting applied. Changes:
- permissions.deny: [Read(./.env), Read(./.env.*), Read(./secrets/**), Read(./config/credentials.json)]

Core Concepts

Sensitive File Protection Overview

AspectDetails
.env FilesEnvironment variable files containing API keys, database URLs, and service credentials
.env.* VariantsEnvironment-specific files like .env.production, .env.staging, .env.local
Secrets DirectoryDedicated directory for certificates, private keys, and other secret materials
Credentials JSONApplication-level credential configuration files with authentication details

Deny Rule Architecture

+---------------------------+
|  Claude Code Read Request |
+---------------------------+
         |
         v
+---------------------------+
|  Deny Rule Check          |
+---------------------------+
|  .env         -> BLOCKED  |
|  .env.*       -> BLOCKED  |
|  secrets/**   -> BLOCKED  |
|  config/      |           |
|   credentials |           |
|   .json       -> BLOCKED  |
+---------------------------+
         |
    blocked / allowed
         |         |
         v         v
     REJECT    Continue to
     request   allow list
               evaluation

Configuration

ParameterTypeDefaultDescription
permissions.denyarray[]List of file read patterns to block from Claude Code access
Read(./.env)stringN/ABlock reading the root .env file containing environment variables
Read(./.env.*)stringN/ABlock reading all .env variant files like .env.production
Read(./secrets/**)stringN/ABlock reading any file within the secrets directory tree
Read(./config/credentials.json)stringN/ABlock reading the application credentials configuration file

Best Practices

  1. Apply this setting as a base layer for all projects - Sensitive file protection should be the first setting applied, before any allow rules. Deny rules take precedence over allow rules, ensuring credentials are always protected.
  2. Extend the deny list for your project structure - The default list covers common patterns. Add project-specific entries for files like service-account.json, .npmrc with auth tokens, or private key files.
  3. Use .env.example for configuration reference - Create a .env.example file with placeholder values that Claude Code can read. This provides configuration context without exposing actual credentials.
  4. Audit deny rules against your file structure - Run a file listing of sensitive files in your project and verify each one is covered by a deny pattern. New developers may add credentials in unexpected locations.
  5. Combine with gitignore alignment - Your deny rules should generally mirror your .gitignore entries for sensitive files. If a file is too sensitive to commit, it is too sensitive for Claude Code to read.

Common Issues

  1. Claude Code cannot help with environment configuration - When deny rules block .env files, Claude Code cannot diagnose configuration issues. Temporarily share specific variable names without values or use .env.example files.
  2. Wildcard pattern too broad - The pattern Read(./.env.*) blocks all files starting with .env. If you have non-sensitive files matching this pattern, use more specific deny entries.
  3. Secrets directory not at expected path - If your project stores secrets in a non-standard location, the default deny rules will not cover them. Add custom entries for your project's actual secrets paths.
Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates