Stop AI from breaking your intentional code
Structured memory items that surface context before you edit and check decisions after you diff. Keep your team's institutional knowledge alive.
$ codefidence context --file src/billing/invoice.ts
[codefidence] Domain: billing (confidence: verified)
Memory:
[exception] Client X uses legacy pricing [confirmed]
[decision] No dedup on imported rows [verified]
[business] Invoice issued after sync [seen-in-code]
Dependencies: payments, taxes
$ codefidence context --file src/billing/invoice.ts
[codefidence] Domain: billing (confidence: verified)
Memory:
[exception] Client X uses legacy pricing [confirmed]
[decision] No dedup on imported rows [verified]
[business] Invoice issued after sync [seen-in-code]
Dependencies: payments, taxes
The invisible knowledge problem
Every project accumulates knowledge that lives outside the code.
The Problem
- ✗ Critical knowledge lives in Notion, Slack, PR comments, and developers' heads
- ✗ AI assistants "fix" intentional behavior they don't understand
- ✗ New developers undo deliberate decisions and break things that looked broken
- ✗ Knowledge leaves when people leave
The Solution
- ✓ A
.wiki/directory with structured memory items in your repo - ✓ Exceptions, decisions, and business rules linked to the files they affect
- ✓ Context surfaced automatically before file edits via Claude Code hooks
- ✓ Changes checked against known decisions after every diff
How it works
codefidence operates at two critical moments in your workflow.
Before Editing
context --file
Surfaces relevant memory items
You Edit Code
AI or developer makes changes
Write code with full context awareness
After Changes
check-diff
Flags affected decisions
Everything you need
A complete toolkit for preserving and surfacing project knowledge.
Memory Items
Capture exceptions, decisions, and business rules as structured YAML items linked to the files they affect.
Context Surfacing
Automatically surfaces relevant memory items before file edits via Claude Code PreToolUse hooks.
Diff Checking
Flags affected exceptions and decisions after code changes, preventing unintended reversions.
Confidence Levels
Five trust levels from confirmed to needs-validation help you know which knowledge to rely on.
Multi-Language Support
Scans TypeScript, JavaScript, Python, Rust, Go, Ruby, Java, and PHP codebases.
Candidate Workflow
Auto-generates potential memory items from heuristics. Review, promote, or reject candidates.
Drift Detection
Identifies when wiki notes become stale or when code changes violate documented decisions.
CI Integration
Run check-diff with --pr-comment in CI to flag knowledge violations on pull requests.
Get started in 60 seconds
No Rust toolchain needed. Install via npm and initialize in your project.
Install
npm install -g @agence-debord/codefidence Initialize in your project
cd your-project
codefidence init --full Scans your codebase, installs Claude Code hooks, patches CLAUDE.md, and installs slash commands.
See what was found
codefidence status Review discovered domains, memory items, confidence levels, and coverage.
Command reference
A complete CLI for managing your project's knowledge base.
Read
consult [domain] Display memory items for a domain or all domains. search <term> Full-text search across all memory items. status Overview of domains, items, coverage, and health. review [domain] Interactive review of items that need attention or validation. Write
add domain <name> Create a new knowledge domain. add context "<text>" Add a context item to the wiki. add decision "<text>" Record an architectural or business decision. confirm <target> Mark an item as confirmed and trusted. deprecate <target> Mark an item as deprecated. rename-domain <old> <new> Rename an existing domain. import <folder> Import memory items from an external folder. Analyze
context --file <path> Surface relevant memory items for a specific file. check-diff [files] Check changed files against memory items for violations. detect-drift --file <path> Identify stale or mismatched items for a given file. validate Validate the integrity and consistency of all memory items. Maintain
rebuild Rebuild the wiki index from source files. index Update the search index for all memory items. graph Generate a dependency graph of domains and items. Candidates
generate-candidates Auto-generate potential memory items from codebase heuristics. promote <id> Promote a candidate to a full memory item. promote --next Promote the next candidate in the queue. reject <id> Reject a candidate item. Hooks
install-hooks Install Claude Code PreToolUse and PostToolUse hooks. uninstall-hooks Remove installed Claude Code hooks. Built for Claude Code
codefidence installs two hooks that make Claude Code aware of your project's institutional knowledge.
PreToolUse Hook
Before file edits, injects relevant memory items into the AI's context so it knows what to preserve.
PostToolUse Hook
After a file write, flags potential wiki drift and warns when changes may violate documented decisions.
Run codefidence init --full to set everything up automatically.
# Hooks installed in .claude/settings.json
{
"hooks": {
"PreToolUse": [{
"matcher": "Edit|Write",
"command": "codefidence context --hook"
}],
"PostToolUse": [{
"matcher": "Edit|Write",
"command": "codefidence detect-drift --hook"
}]
}
} Ready to preserve your project's knowledge?
Install codefidence in 60 seconds and stop losing institutional knowledge.