The Problem: The "Regression Loop"
I use Cursor and Copilot daily. They are incredible, but they suffer from Goldfish Memory. If I tell Cursor: "Don't use fs.readFileSync in the frontend," it listens... for that chat session. Three days later, in a new file, it suggests fs.readFileSync again.
I found myself reviewing code for the same bugs repeatedly:
Hallucinated imports
Leaked API keys (regex patterns)
Inefficient React useEffect loops
Deprecated internal functions
The Solution: A "Shadow Guard"
I didn't want another AI wrapper. I wanted a Guardrail System. I built Engram to act as a "Hippocampus" (Memory) for the AI's "Cortex" (Reasoning).
How it works (Technical)
Observation: Engram listens to vscode.workspace.onDidChangeTextDocument.
Fingerprinting: When I reject code (or manually add a rule), Engram stores a "Mistake Fingerprint" (Regex or Vector).
Interception: As the AI streams text into the buffer, Engram scans the incoming characters against its local database.
Latency: <10ms (Local Regex).
Enforcement: If a match is found, it triggers a vscode.Diagnostic (Red Squiggle) immediately.
// Simplified Logic
export class ShadowScanner {
public scan(document: TextDocument) {
// Runs in <2ms
const mistakes = this.detector.findMatches(document.getText());
const diagnostics = mistakes.map(m => new Diagnostic(
m.range,
`Engram Guard: ${m.message}`,
DiagnosticSeverity.Error
));
this.collection.set(document.uri, diagnostics);
}
}
The "AI Whisperer" (Context Injection)
Blocking code is good, but teaching the AI is better. Engram hooks into the configuration files of your AI tools to prevent mistakes before they are generated.
Cursor: It automatically appends rules to
.cursorrules.
Copilot: It updates .github/copilot-instructions.md.
When you mark a pattern as "Forbidden", Engram whispers to Cursor:
[System Context] User strictly forbids 'console.log' in production files.
Open Source & Community Rules
I realized I couldn't find every bad pattern myself. So I open-sourced the rule definitions. You can now pull "Community Packs" for various stacks:
React Pack: Blocks common hook infinite loops.
Security Pack: Blocks AWS/Stripe key patterns.
Python Pack: Blocks reckless pandas iterators.
Engram: [https://github.com/kwstx/engram-rules]
Try it out
It's open source, local-first, and designed to keep you in the flow state. If you are tired of fixing the same AI bugs twice, give it a shot.
[https://marketplace.visualstudio.com/items?itemName=use-engram.engram] [https://github.com/kwstx/Engram]
Top comments (0)