Correlation-network / CLAUDE.md
hemsby's picture
gates: sync to final DECODE hardening pattern
2eee090
|
Raw History Blame Contribute Delete
6.58 kB
# CLAUDE.md
## Session-start: ensure required plugins are installed
At the start of any new session in this repo, run `/plugin marketplace list`. If `claude-plugins-official` is not listed, install the four required plugins:
```
/plugin marketplace add anthropics/claude-plugins-official
/plugin install feature-dev@claude-plugins-official
/plugin install code-simplifier@claude-plugins-official
/plugin install claude-md-management@claude-plugins-official
/plugin install superpowers@claude-plugins-official
```
One-time per user per machine. `feature-dev` provides the `code-reviewer` subagent referenced by the reviewer procedure (and `code-architect` for plan review). Without `feature-dev` installed, every commit touching source code will be blocked by the commit-msg gate.
Subsequent sessions refresh plugins automatically.
## Reviewer procedure
Triggered by the Stop hook when the session modified substantive files and no fresh `.decode-reviewer-clean` marker exists. The Stop hook blocks session end and points the model back to this procedure. Steps, in order:
1. Run `git diff HEAD` via Bash.
2. Dispatch `feature-dev:code-reviewer` via the Agent tool. Pass the diff as context. Instruct: review only the changes, target latency under 90 seconds, report only blocking issues (confidence ≥ 80).
3. When the reviewer returns:
- **No blocking issues** → compute `HEAD_SHA=$(git rev-parse HEAD)` and `DIFF_HASH=$(bash scripts/reviewer-hash.sh)`, then Write `.decode-reviewer-clean` with exactly one line: `<HEAD-SHA> <DIFF-HASH> <ISO-8601-UTC-timestamp>`. The hash helper covers tracked-file diffs AND untracked file contents; do not substitute a plain `git diff | git hash-object` pipe — it misses untracked files and lets create-file → pass-review → silent-edit bypass the marker.
- **Blocking issues** → Write `.decode-reviewer-findings.md` with the list. Do NOT write `.decode-reviewer-clean`.
4. Return.
If the `feature-dev` plugin is not installed, stop and ask the user to run `/plugin install feature-dev@claude-plugins-official`.
The `commit-msg` git hook blocks commits unless the marker's HEAD and DIFF hashes both match the current repo state, or the commit message contains `[override-reviewer: <reason>]`. Binding to the diff content means any edit made after review invalidates the marker. Overrides are visible forever in `git log --grep="override-reviewer"`.
## DECODE base rules
This repo enforces DECODE's Claude Code standards. The full rule catalog lives at https://github.com/implicitdiagnosticsandsolutions/decode-claude-wiki/tree/main/docs/rules — rules are loaded by reference.
**The short version — what you must follow:**
1. **Reviewer subagent required before commit.** For any change that touches source code, generator scripts, or data outputs, dispatch the `feature-dev:code-reviewer` subagent before committing. The Stop hook blocks session end until this procedure is handled. Committing without a fresh `.decode-reviewer-clean` marker is blocked by `.githooks/commit-msg` unless the commit message contains `[override-reviewer: <reason>]`. Overrides are visible forever in `git log --grep="override-reviewer"`.
2. **Verify before claiming.** Before saying "X works", "it's documented", or "it's in memory", run a concrete check. Paste the output. "Should" is a red flag — replace it with a check.
3. **Patch the source, not the generated artifact.** If a file under `output/` or `dist/` was produced by a script, edit the script and regenerate. Never edit the artifact directly.
4. **Stage files explicitly.** Never `git add -A` or `git add .`. Name each file.
5. **No AI attribution in commits.** Conventional format, human author.
## Optional final cleanup
This template also ships a repo-local `deslop` skill under `.claude/skills/deslop/`.
Use it after a change already works and before commit when you want a final pass focused on:
- removing unnecessary wrappers or indirection
- preserving source-of-truth files and types
- catching debug leftovers and placeholder comments
- reducing AI slop without widening scope
`deslop` is advisory, not a hard gate.
## First-time setup in this repo
Setup runs automatically on Claude Code session start via the `ensure-setup.sh` SessionStart hook — it wires `.githooks` into git (`core.hooksPath`) so the commit-msg and pre-commit gates fire. Idempotent; no-ops once wired.
If you commit from a plain terminal in a fresh clone without ever opening a Claude Code session, the hooks will not fire until you run setup manually:
```bash
bash scripts/setup.sh
```
## Destructive operations
Destructive git operations (`push --force`, `reset --hard`, `clean -f`, `branch -D`, etc.) are blocked by the `block-dangerous-git.sh` PreToolUse hook. If you genuinely need one, ask the user to run it manually after explicit chat confirmation.
Writes to `.env*`, `credentials*`, `*.pem`, `*.key`, and other secret files are blocked by `block-env-writes.sh`.
---
<!-- Per-repo section below. Fill in repo-specific conventions. -->
## This repo
`network_html` ist eine Streamlit-App die aus Excel-Korrelationsmatrizen interaktive HTML-Netzwerk-Visualisierungen erzeugt. DECODE-Consultants nutzen sie um implizite Markenattribute (aus SAT/MAT-Tests) als vis-network-Graphen zu explorieren. Deployed auf HuggingFace Spaces (`DecodeMarketing/Correlation-network`), auto-deploy bei Push auf `main`.
**Lokal starten:**
```bash
pip install -r requirements.txt
streamlit run app.py
# öffnet http://localhost:8501
```
**Source-Layout:**
- `app.py` — Streamlit UI, Entry Point (~180 Zeilen)
- `parse_excel.py` — Excel-Erkennung und Datenextraktion
- `build_network.py` — Netzwerk-Aufbau und HTML-Template-Generierung
- `config.py` — Konstanten (Farben, DECODE-Brand-Blau `#283273`)
- `velocity_source.py` — Velocity-Datenquelle
- `requirements.txt` — Python-Abhängigkeiten (Quelle der Wahrheit)
**Repo-spezifische Regeln:**
- Der generierte HTML-Output ist ein Artefakt — nie direkt bearbeiten, immer über `build_network.py` regenerieren.
- `sample_data/` ist gitignored (enthält Kundendaten) — nie committen.
- Auto-Detection von `CORR_THRESHOLD` schlägt immer fehl; Default 6.0 ist beabsichtigt, nicht fixen ohne echten Testfall.
- Deployment-Secret `HF_TOKEN` liegt als GitHub Repo Secret — nie in Code oder Commits.
**Bekannte Einschränkungen (nicht "fixen" ohne Absprache):**
- Cut-off-Detection schlägt auf echten Dateien immer fehl → Default 6.0
- Per-Brand-Matrizen werden ignoriert → nur "mean across all brands"