Skip to main content
NOV 2026 Latest guide updates. Latest: AI Design Patterns Local vs cloud AI Grill me Changelog →
T09 Beginner Technical

Workspace Hygiene

Keeping context clean by blocking what Claude should not read

PDF editions Β· Guide v3.44.1 Β· Updated

There is no .claudeignore

Claude Code has no .claudeignore file in the .gitignore mold. Blocking file access goes through permissions.deny in .claude/settings.json, using direct path patterns such as Read(*.env*). The file_path: qualifier is invalid for Read, Edit and Write permission rules.

{
"permissions": {
"deny": [
"Read(*.env*)",
"Edit(*.env*)",
"Write(*.env*)",
"Read(*.pem)",
"Read(*.key)",
"Read(*credentials*)",
"Bash(cat .env*)"
]
}
}

Why it matters

deny has the highest precedence: no allow or ask rule, at any scope, can override it. The rule blocks Read, Edit, Write calls, and Bash commands that explicitly match a deny pattern. It does not block generic Bash commands without a dedicated deny rule, nor an ls .env* that reveals the file exists without exposing its contents.

What permissions.deny covers

VectorBlocked
Read()Yes
Edit() / Write() with a ruleYes
Bash(cat .env) with explicit ruleYes
Generic Bash without a deny ruleNo
ls .env* (filename)Partial

For defense-in-depth: store secrets outside the project directory, add a PreToolUse hook as a second lock, never commit secrets even β€œblocked” ones.

.gitignore vs permissions.deny

MechanismRoleScope
.gitignoreExcludes from version controlGit
permissions.denyBlocks reading/editing/writing via toolsClaude Code
respectGitignore (default: true)The @ picker respects .gitignore patternsClaude Code

These three mechanisms are independent. A file can be ignored by Git without being blocked for Claude, and the reverse.

.claude/
β”œβ”€β”€ settings.json # Team config (committed)
β”œβ”€β”€ settings.local.json # Local config (gitignore)
β”œβ”€β”€ agents/ # Custom agents
β”œβ”€β”€ skills/ # Skills (includes slash commands since CC 2.1.3)
β”œβ”€β”€ hooks/ # Automation scripts
└── rules/ # Shared conventions, optionally path-scoped

The agents/, skills/, hooks/ and rules/ folders are committed with the project. settings.local.json and the project-root CLAUDE.local.md hold local configuration and personal instructions. Auto-memory lives under ~/.claude/projects/<project>/memory/, separately from this tree.

Clean workspace checklist

  • .env*, *.pem, *.key, *credentials* in permissions.deny
  • Deny rules covering Read, Edit, Write AND the equivalent Bash commands
  • Secrets stored outside the project directory where possible
  • settings.local.json in .gitignore
  • PreToolUse hook as a second lock on critical files

Enter your email to read the full card and get the complete PDF bundle.

All content is free and open-source. We just ask for your email.

PDF: