# {{ project_name }} - Claude Code Configuration

{% if not grip_global %}
Powered by GRIP Mirror v{{ version }}. Safety gates and efficiency rules for Claude Code.
{% else %}
Project overrides for GRIP-managed environment. GRIP Mirror v{{ version }}.
Global rules inherited from ~/.claude/ — do not duplicate here.
{% endif %}

---

{% if not grip_global %}
## Safety Gates (Enforced by Hook)

The following gates run on every tool call via PreToolUse hook:

| Gate | Purpose |
|------|---------|
| 0. Always Allow | Skip critical tools (AskUserQuestion, etc.) |
| 1. Dependency Guardian | Block reads from node_modules, venv, dist, etc. |
| 2. Destructive Git | Block force push, reset --hard without approval |
| 2a. Git Push Gate | Block force push and protected branch push |
| 3. Secrets Detection | Block committing .env, credentials, keys |
| 5. Tool Substitution | Redirect grep->rg, find->fd, cat->Read |
| 6. Bash Linting | Block dangerous bash patterns (semicolons, negation) |
| 7. Temp Script | Block creating temporary scripts |
| A. Env Var Protection | Block reading sensitive env vars (API keys, tokens) |
| D. Network Binding | Block 0.0.0.0 binding without authentication |
| 9. Context Gate | Halt at 85% context to prevent cutoff |

## Core Rules

1. **Never read dependency folders**: node_modules, .next, dist, build, __pycache__, venv, target, vendor
2. **File read optimization**: Batch reads early, targeted edits later. Check cache before re-reading.
3. **Confidence gate**: When uncertain, HALT and ask the user.
4. **Context gate**: At 85% context usage, HALT and ask user how to proceed.
5. **Anti-drift**: After commits/phase completion, output remaining work before accepting new tasks.

{% endif %}
## Project Details

- **Type**: {{ project_type }}
- **Mirror mode**: {% if grip_global %}grip-user{% else %}standalone{% endif %}

{{ type_additions }}

## Persistent Memory

Update `memory/MEMORY.md` with:
- Architecture decisions and their rationale
- Patterns discovered during development
- Known issues and workarounds
- Key file paths and their purposes

Review MEMORY.md at session start. Update at session boundaries.
