agentleFS
0xNyk0xNyk/lacp/CLAUDE.md

lacp

CLAUDE.md304 starsChanged 3 months agoMITView on GitHub

Framework for hardening, orchestrating, and validating Claude Code sessions on local machines. Hooks live in hooks/ and are installed to ~/.claude/ via bin/lacp-claude-hooks apply-profile. Profiles: minimal-stop, balanced, hardened-exec, quality-gate, quality-gate-v2, orient, session-start, pretool-guard, write-validate, thinking-partner. Set LACP_CONTEXT_MODE to activate a mode (injected at session start): lacp (no args) launches a hardened agent session:

  • Reads credentials
  • Deletes or force-pushes
  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this CLAUDE.md into the rules it gives an agent

20 rules. About 0 are common, 6 are distinctive, and 14 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 14

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    All bash scripts use set -euo pipefail

    line 37
  2. Very specific:

    All bin/ scripts source scripts/lacp-lib.sh for shared functions (log, die, require_cmd, etc.)

    line 38
  3. Very specific:

    All configurable via env or .env file.

    line 97
  4. Very specific:

    Run bin/lacp-test before pushing

    line 216
  5. Very specific:

    MUST run impact analysis before editing any symbol: Before modifying a function, class, or method, run gitnexus_impact({target: …

    line 227
  6. Distinctive:

    MUST warn the user: if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.

    line 229
  7. Very specific:

    When exploring unfamiliar code, use gitnexus_query({query: "concept"}) to find execution flows instead of grepping.

    line 230
  8. Very specific:

    When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use gitnexus_context({name: …

    line 231
  9. Very specific:

    Renaming: MUST use gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true}) first.

    line 242
  10. Very specific:

    Extracting/Splitting: MUST run gitnexus_context({name: "target"}) to see all incoming/outgoing refs, then gitnexus_impact({target: …

    line 243
  11. Very specific:

    After any refactor: run gitnexus_detect_changes({scope: "all"}) to verify only expected files changed.

    line 244
  12. Very specific:

    NEVER edit a function, class, or method without first running gitnexus_impact on it.

    line 248
  13. Distinctive:

    NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.

    line 249
  14. Very specific:

    NEVER rename symbols with find-and-replace — use gitnexus_rename which understands the call graph.

    line 250
  15. Very specific:

    NEVER commit changes without running gitnexus_detect_changes() to check affected scope.

    line 251
  16. Distinctive:

    Before completing any code modification task, verify:

    line 283
  17. Distinctive:

    No HIGH/CRITICAL risk warnings were ignored

    line 285
  18. Distinctive:

    All d=1 (WILL BREAK) dependents were updated

    line 287
  19. Distinctive:

    After committing code changes, the GitNexus index becomes stale.

    line 291
  20. Very specific:

    If the index previously included embeddings, preserve them by adding --embeddings:

    line 297

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

LACP — Local Agent Control Plane

Framework for hardening, orchestrating, and validating Claude Code sessions on local machines.

Key Directories

PathPurpose
bin/CLI commands (lacp-test, lacp-doctor, lacp-brain-expand, etc.)
hooks/Claude Code hooks (SessionStart, PostToolUse, Stop)
scripts/lacp-lib.shShared shell library — sourced by all bin/ commands
scripts/ci/CI test scripts (test-*.sh)
scripts/runners/Pipeline runners (brain-expand steps, etc.)
automation/scripts/44 Python + 22 shell automation scripts (brain-expand steps, RAG, benchmarks, sync)
config/Policy files (sandbox, MCP auth, route policy)
dist/Distribution/packaging assets
Formula/Homebrew formula

Running Tests

# Full suite (~60 tests)
bin/lacp-test

# Quick suite (doctor + route policy)
bin/lacp-test --quick

# Isolated (temporary roots, no side effects)
bin/lacp-test --isolated

# Single test
bash scripts/ci/test-<name>.sh

Conventions

  • All bash scripts use set -euo pipefail
  • All bin/ scripts source scripts/lacp-lib.sh for shared functions (log, die, require_cmd, etc.)
  • CI tests use assert_eq pattern — compare actual vs expected, print PASS/FAIL
  • CI tests create temp dirs, trap cleanup EXIT — no leftover state
  • JSON output via --json flag on bin/ commands

Hook Architecture

Hooks live in hooks/ and are installed to ~/.claude/ via bin/lacp-claude-hooks apply-profile.

HookEventPurpose
stop_quality_gate.pyStopCriteria-based scoring (4 dimensions, weighted avg) + test verification + heuristics + handoff artifact generation
session_start.pySessionStartGit context + test cmd caching + focus brief + handoff injection + stale contract cleanup
eval_checkpoint.pyPostToolUse(Write/Edit)Continuous QA — runs tests at intervals during work, injects feedback on failure
pretool_guard.pyPreToolUseCo-author, scp/root, rm -rf, publishing, exfiltration guards
thinking_nudge.pyUserPromptSubmitNudges user to state position before asking questions (opt-in)
detect_session_changes.py(library)Scans transcript for file changes (imported by stop hook)
hook_telemetry.py(library)JSONL telemetry logger with rotation (imported by stop hook)
hook_contracts.py(library)Typed state exchange between hooks (SessionStartOutput, SprintContract, EvalCheckpoint, HandoffArtifact)
write_validate.pyPostToolUse(Write)YAML frontmatter schema validation
session_orient.shSessionStartVault tree, recent changes (legacy bash)
stop_quality_gate.shStopOllama-backed rationalization detection (legacy bash)

Profiles: minimal-stop, balanced, hardened-exec, quality-gate, quality-gate-v2, orient, session-start, pretool-guard, write-validate, thinking-partner.

Context Modes

Set LACP_CONTEXT_MODE to activate a mode (injected at session start):

ModePurpose
brainstormDesign exploration before implementation (no code until design approved)
debugging4-phase systematic root cause investigation
handoff-resumeContinue from previous session handoff artifact
implementationFocused implementation partner
reviewCode review mode
sprintPre-agreed completion criteria (sprint contracts)
tddStrict RED-GREEN-REFACTOR discipline
thinking-partnerChallenge assumptions, surface blind spots
verificationEvidence-before-claims discipline

CLI Stream

lacp (no args) launches a hardened agent session:

lacp                              # auto-detects claude/codex/hermes/opencode/gemini/goose/aider/openclaw
lacp --mode tdd                   # TDD mode with eval checkpoints
lacp --mode debugging             # systematic debugging mode
lacp --resume                     # continue last session
lacp "fix the auth bug"           # one-shot prompt
lacp watch --follow               # live telemetry stream
lacp watch --summary              # session health overview
lacp handoff show                 # view handoff artifact for current dir
lacp scaffold-audit               # identify removable pipeline stages

Environment Variables

All configurable via env or .env file. Key ones:

  • LACP_AUTOMATION_ROOT — automation scripts root (default: <repo>/automation)
  • LACP_KNOWLEDGE_ROOT — knowledge graph root (default: ~/.lacp/knowledge)
  • LACP_DRAFTS_ROOT — article drafts root (default: ~/.lacp/drafts)
  • LACP_OBSIDIAN_VAULT — Obsidian vault path (default: ~/obsidian/vault)
  • LACP_WRITE_VALIDATE_PATHS — colon-separated paths for write validation

Obsidian Data Access

bin/lacp-obsidian-cli wraps the official Obsidian CLI (1.12+) for vault data access:

  • check — verify CLI installed, app running, vault accessible
  • read <note> — read a note via official CLI
  • search <query> — search the vault
  • doctor — full CLI diagnostic

This is separate from bin/lacp-obsidian (config management). The third-party obsidian-mcp npm package has been removed in favor of the official CLI.

  • LACP_TAXONOMY_PATH — taxonomy.json location for category validation
  • LACP_CONTEXT_MODE — active context mode (tdd, debugging, sprint, etc.)
  • LACP_EVAL_CHECKPOINT_ENABLED — enable continuous QA during work (default: 0)
  • LACP_EVAL_CHECKPOINT_INTERVAL — run tests every N file writes (default: 10)
  • LACP_QUALITY_GATE_THRESHOLD — criteria scoring threshold 1-5 (default: 2.5)
  • LACP_BLIND_SPOT_ENABLED — enable blind spot reflection at session end (default: 0)

Full list of 40+ environment variables with defaults: config/lacp.env.example

Memory Architecture (two orthogonal axes)

LACP's memory is described along two independent dimensions. They are not the same axis — a note has both an access tier and a lifecycle layer.

Access tiers (where memory lives / how it's retrieved):

TierWhatBacked by
L1MEMORY.md — always in context (hard cap 200 lines)auto-memory + session_start.py cap guard
L2Topic files — on-demand reads~/.claude/projects/<slug>/memory/*.md
L3MCP-queried external knowledgeObsidian + smart-connections + qmd
L4Offline synthesis pipelinebrain-expand (11 stages)
L5Identity & provenanceagent-id + provenance

Lifecycle layers (what happens to a note from birth to retrieval):

LayerWhatBacked by
1Session memoryCLAUDE.md + auto-memory (MEMORY.md ≤200 lines, enforced)
2Knowledge graph at restObsidian vault + MCP bridge
3Ingestionbrain-ingest (tags new notes needs_curation: true)
4Curation — keeps the graph coherent between ingestion & retrievalsee below

Layer 4 (curation) is split across LACP, by job:

  • rename (title-shape normalization) → bin/lacp-curate / curate_titles.py, also brain-expand stage 7.8. Renames category/timestamp-shaped vault titles to claim-shaped ones drawn from each note's H1, fixing wikilinks vault-wide. Dry-run by default; hub-aware.
  • link (related-claim wikilink proposals) → brain-expand stage 7.5 (detect_knowledge_gaps.py).
  • prune (decay/archival) → brain-expand stages 7.7 (generate_review_queue.py, FSRS) + 8 (archive_inbox.py); knowledge-doctor reports orphans.
lacp curate                 # dry-run title-normalization report on default vault
lacp curate --json          # machine-readable proposals
lacp curate --apply         # apply renames + fix wikilinks vault-wide

The 200-line MEMORY.md cap is a structural constraint, not a style rule: past it the model under-parses and starts inventing entries. session_start.py warns when exceeded (configurable via LACP_MEMORY_MD_LINE_CAP).

Self-Memory System (SMS)

Psychology-informed agent memory based on Conway's Self-Memory System (2005).

Five principles implemented:

  1. Hierarchical temporal — episodes grouped into epochs (life periods)
  2. Goal-relevant filtering — focus brief gates memory retrieval
  3. Emotional weighting — significance scoring (0-1) biases recall
  4. Narrative coherence — agent story arc across sessions
  5. Co-emergent self-model — identity ↔ memory feedback loop
lacp sms context           # what SMS injects at session start
lacp sms episodes          # recorded episodes with significance
lacp sms significance      # significance distribution
lacp sms synthesize        # create epoch from recent episodes
lacp sms narrative         # view/update agent narrative
lacp sms self-model        # view/update evolving self-model

Core module: hooks/self_memory_system.py Data: ~/.lacp/sms/ (episodes.jsonl, epochs.jsonl, narrative.json, self-model.json)

Development Workflow (gstack)

LACP composes with gstack's six-command flow. gstack choreographs the dev loop with persona gates; LACP hardens execution within each phase. They are complementary, not competing.

office-hours → plan-ceo-review → plan-eng-review → build → review → qa → ship
PhaseOwner
/office-hours, /plan-ceo-review, /plan-eng-reviewgstack (scope + architecture gates)
buildLACP (context modes + eval checkpoints)
/reviewboth — LACP's stop quality gate + code-reviewer; gstack's staff-eng persona
/qagstack (real-browser QA — LACP has no browser QA)
/shipgstack orchestrates; runs lacp-pr-preflight as its audit step when present

Set LACP_WORKFLOW=gstack to inject a one-line reminder of this flow at session start (notes which steps LACP already covers, to avoid double-gating). It is a no-op when unset and has no hard dependency on gstack being installed.

Lean on gstack for the genuine LACP gaps: /qa (browser QA) and /plan-ceo-review (scope challenge). Avoid double-running tests/PR steps that both /ship and lacp-pr-preflight own.

Git Workflow

  • Branch from main for features: feat/<name>
  • Conventional commits: feat:, fix:, test:, docs:, refactor:, chore:
  • Run bin/lacp-test before pushing
<!-- gitnexus:start -->

GitNexus — Code Intelligence

This project is indexed by GitNexus as lacp (264 symbols, 453 relationships, 13 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely.

If any GitNexus tool warns the index is stale, run npx gitnexus analyze in terminal first.

Always Do

  • MUST run impact analysis before editing any symbol. Before modifying a function, class, or method, run gitnexus_impact({target: "symbolName", direction: "upstream"}) and report the blast radius (direct callers, affected processes, risk level) to the user.
  • MUST run gitnexus_detect_changes() before committing to verify your changes only affect expected symbols and execution flows.
  • MUST warn the user if impact analysis returns HIGH or CRITICAL risk before proceeding with edits.
  • When exploring unfamiliar code, use gitnexus_query({query: "concept"}) to find execution flows instead of grepping. It returns process-grouped results ranked by relevance.
  • When you need full context on a specific symbol — callers, callees, which execution flows it participates in — use gitnexus_context({name: "symbolName"}).

When Debugging

  1. gitnexus_query({query: "<error or symptom>"}) — find execution flows related to the issue
  2. gitnexus_context({name: "<suspect function>"}) — see all callers, callees, and process participation
  3. READ gitnexus://repo/lacp/process/{processName} — trace the full execution flow step by step
  4. For regressions: gitnexus_detect_changes({scope: "compare", base_ref: "main"}) — see what your branch changed

When Refactoring

  • Renaming: MUST use gitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true}) first. Review the preview — graph edits are safe, text_search edits need manual review. Then run with dry_run: false.
  • Extracting/Splitting: MUST run gitnexus_context({name: "target"}) to see all incoming/outgoing refs, then gitnexus_impact({target: "target", direction: "upstream"}) to find all external callers before moving code.
  • After any refactor: run gitnexus_detect_changes({scope: "all"}) to verify only expected files changed.

Never Do

  • NEVER edit a function, class, or method without first running gitnexus_impact on it.
  • NEVER ignore HIGH or CRITICAL risk warnings from impact analysis.
  • NEVER rename symbols with find-and-replace — use gitnexus_rename which understands the call graph.
  • NEVER commit changes without running gitnexus_detect_changes() to check affected scope.

Tools Quick Reference

ToolWhen to useCommand
queryFind code by conceptgitnexus_query({query: "auth validation"})
context360-degree view of one symbolgitnexus_context({name: "validateUser"})
impactBlast radius before editinggitnexus_impact({target: "X", direction: "upstream"})
detect_changesPre-commit scope checkgitnexus_detect_changes({scope: "staged"})
renameSafe multi-file renamegitnexus_rename({symbol_name: "old", new_name: "new", dry_run: true})
cypherCustom graph queriesgitnexus_cypher({query: "MATCH ..."})

Impact Risk Levels

DepthMeaningAction
d=1WILL BREAK — direct callers/importersMUST update these
d=2LIKELY AFFECTED — indirect depsShould test
d=3MAY NEED TESTING — transitiveTest if critical path

Resources

ResourceUse for
gitnexus://repo/lacp/contextCodebase overview, check index freshness
gitnexus://repo/lacp/clustersAll functional areas
gitnexus://repo/lacp/processesAll execution flows
gitnexus://repo/lacp/process/{name}Step-by-step execution trace

Self-Check Before Finishing

Before completing any code modification task, verify:

  1. gitnexus_impact was run for all modified symbols
  2. No HIGH/CRITICAL risk warnings were ignored
  3. gitnexus_detect_changes() confirms changes match expected scope
  4. All d=1 (WILL BREAK) dependents were updated

Keeping the Index Fresh

After committing code changes, the GitNexus index becomes stale. Re-run analyze to update it:

npx gitnexus analyze

If the index previously included embeddings, preserve them by adding --embeddings:

npx gitnexus analyze --embeddings

To check whether embeddings exist, inspect .gitnexus/meta.json — the stats.embeddings field shows the count (0 means no embeddings). Running analyze without --embeddings will delete any previously generated embeddings.

Claude Code users: A PostToolUse hook handles this automatically after git commit and git merge.

CLI

TaskRead this skill file
Understand architecture / "How does X work?".claude/skills/gitnexus/gitnexus-exploring/SKILL.md
Blast radius / "What breaks if I change X?".claude/skills/gitnexus/gitnexus-impact-analysis/SKILL.md
Trace bugs / "Why is X failing?".claude/skills/gitnexus/gitnexus-debugging/SKILL.md
Rename / extract / split / refactor.claude/skills/gitnexus/gitnexus-refactoring/SKILL.md
Tools, resources, schema reference.claude/skills/gitnexus/gitnexus-guide/SKILL.md
Index, status, clean, wiki CLI commands.claude/skills/gitnexus/gitnexus-cli/SKILL.md
<!-- gitnexus:end -->

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.