Fabrik-Codek
A 7B model that knows you is worth more than a 400B that doesn't.
Fabrik-Codek is a personal cognitive architecture that runs locally with any Ollama model. It doesn't just retrieve documents — it builds a knowledge graph from how you work, measures your expertise per topic, routes tasks to the right model with the right retrieval strategy, observes whether its responses actually helped, and refines itself over time.
How It Works
- 1. You work — Fabrik-Codek captures code changes, session transcripts, decisions, and learnings in a local datalake
- Knowledge extraction — An 11-step pipeline extracts entities and relationships into a knowledge graph alongside a vector DB
- Personal profiling — Analyzes your datalake to learn your domain, stack, patterns, and tooling preferences
- Competence scoring — Measures how deep your knowledge is per topic (Expert / Competent / Novice / Unknown)
- Adaptive routing — Classifies each query by task type and topic, selects the right model, adapts retrieval depth, and builds a 3-layer system prompt
- Outcome tracking — Infers whether responses were useful from conversational patterns (zero friction, no manual feedback)
- Self-correction — Adjusts retrieval parameters for underperforming task/topic combinations
Every interaction feeds back into the system. Fabrik-Codek itself makes zero outbound network requests — it only connects to Ollama and optionally Meilisearch on localhost. Model downloads are handled by Ollama's own CLI (ollama pull), not by Fabrik-Codek.
Setup
Configure as an MCP server in your openclaw.json or ~/.claude/settings.json:
CODEBLOCK0
For network access (SSE transport):
CODEBLOCK1
First Run
After installing, initialize and build the knowledge base:
CODEBLOCK2
Available MCP Tools
fabrik_ask
Ask a question to the local LLM with optional context from the knowledge base. The Task Router automatically classifies your query, selects the right model based on your competence, adapts retrieval strategy, and builds a personalized system prompt.
- -
use_rag=true — vector search context - INLINECODE4 — hybrid context (vector + graph + full-text)
Example: "How should I handle database connection pooling?"
fabrik_search
Semantic vector search across your accumulated knowledge. Returns the most relevant documents, patterns, and examples by meaning — not just keywords.
Example: "Find examples of retry logic with exponential backoff"
fabrikgraphsearch
Traverse the knowledge graph to find entities (technologies, patterns, strategies) and their relationships. Useful for understanding how concepts connect in your experience.
- -
depth — how many hops to traverse (default: 2)
Example: "What technologies are related to FastAPI in my knowledge graph?"
fabrikfulltextsearch
Full-text keyword search via Meilisearch. Use this for exact keyword or phrase matching when you know the specific terms. Optional — the system works without Meilisearch installed.
Example: "Search for 'EXPLAIN ANALYZE' in my knowledge base"
fabrikgraphstats
Knowledge graph statistics: entity count, edge count, connected components, type breakdown, and relation types.
fabrik_status
System health check: Ollama availability, RAG engine, knowledge graph, full-text search, and datalake status.
Available MCP Resources
| URI | Description |
|---|
| INLINECODE6 | System component status |
| INLINECODE7 |
Knowledge graph statistics |
|
fabrik://config | Current configuration (sanitized) |
When to Use Each Tool
| Scenario | Tool | Why |
|---|
| Coding question needing context | INLINECODE9 with INLINECODE10 | Gets hybrid retrieval + personalized prompt |
| Find similar patterns or examples |
fabrik_search | Semantic similarity across all knowledge |
| Understand how concepts relate |
fabrik_graph_search | Graph traversal shows entity relationships |
| Find exact terms or phrases |
fabrik_fulltext_search | BM25 keyword matching |
| Check if knowledge base is healthy |
fabrik_status | Component health check |
| Understand knowledge distribution |
fabrik_graph_stats | Entity/edge counts and types |
The Cognitive Loop
The system gets smarter the more you use it:
CODEBLOCK3
- - Personal Profile learns your domain, stack, and preferences from your datalake
- Competence Model scores expertise per topic using 4 signals (entry count, graph density, recency, outcome rate)
- Task Router classifies queries into 7 task types, detects topic, selects model, adapts retrieval
- Outcome Tracker infers response quality from conversational patterns (topic change = accepted, reformulation = rejected)
- Strategy Optimizer adjusts retrieval parameters for weak spots
- Graph Temporal Decay fades stale knowledge, reinforces recent activity
- Semantic Drift Detection alerts when an entity's context shifts between graph builds
- Context Gate decides whether to inject RAG context at all (skips for generic queries where context would be noise)
- Relevance Filter drops retrieved chunks with low query-text token overlap, preventing domain-specific knowledge from contaminating generic answers
Requirements
- - Fabrik-Codek installed from source (
git clone + pip install -e ".[dev]") - Ollama running locally with any model (e.g.,
ollama pull qwen2.5-coder:7b) - Optional: Meilisearch for full-text search (system works without it)
Note on installation: Fabrik-Codek is an instruction-only skill — there is no automated installer. You install it manually from the GitHub repository via git clone + pip install -e ".[dev]". This lets you audit the full source code before installing. The skill itself contains documentation and MCP server configuration, not executable code.
Security & Privacy
No external network calls
Fabrik-Codek makes zero outbound network requests. It connects only to services running on your own machine:
- - Ollama at
localhost:11434 — your locally running LLM server (for inference and embeddings) - Meilisearch at
localhost:7700 (optional) — your locally running search engine
No telemetry, no analytics, no phone-home. Verify in the source: grep -r "requests\.\|httpx\.\|urllib" src/ — all HTTP calls target localhost only. The only network activity that occurs during setup is ollama pull, which is Ollama's own CLI downloading models from ollama.ai/library — Fabrik-Codek does not initiate or control these downloads.
What fabrik init does
INLINECODE27 performs these local-only operations:
- 1. Checks Python version (>= 3.11)
- Detects if Ollama is running at INLINECODE28
- Creates a
.env config file in the current directory - Creates local data directories (
./data/embeddings/, ./data/graphdb/, ./data/profile/) - Pulls Ollama models via
ollama pull — models are downloaded by Ollama itself from ollama.ai/library, not by Fabrik-Codek
Fabrik-Codek does not download any files from any server. Model downloads are handled entirely by Ollama's own CLI.
Data access scope
Reads (all local, all opt-in, never automatic):
| Path | What | When | Why |
|---|
| INLINECODE34 | Session transcript JSONL files (already on disk from Claude Code) | Only when you explicitly run fabrik learn process or INLINECODE36 | Extracts entities and reasoning patterns to build the knowledge graph. This path is NOT in configPaths because Fabrik-Codek does not write to it — it is read-only and user-initiated. |
| INLINECODE38 or INLINECODE39 |
Your datalake (training pairs, captures, metadata) | During
graph build,
rag index,
profile build,
competence build | Source data for building the knowledge base and personal profile |
Writes (all local):
| Path | What |
|---|
| INLINECODE44 | LanceDB vector index |
| INLINECODE45 |
NetworkX knowledge graph (JSON) |
|
./data/profile/ | Personal profile, competence map, strategy overrides (JSON) |
|
./data/01-raw/outcomes/ | Outcome tracking records (JSONL) |
All paths are declared in the skill metadata configPaths. The skill never writes outside these directories.
Network transport
- - Default:
stdio — no network listener, no ports opened, no exposure - Optional:
sse — starts an HTTP server bound to 127.0.0.1:8421 by default (localhost only, not reachable from other machines) - If you change the SSE bind address to
0.0.0.0, your indexed data would be accessible over the network. Do not do this without proper firewall/ACL rules
Session transcript privacy
The fabrik learn command reads Claude Code session transcripts, which may contain sensitive data (code, credentials, conversation history). This command is opt-in — you must run it manually. It does not run in the background or on a schedule unless you explicitly configure fabrik learn watch. Review what's in your ~/.claude/projects/ before indexing.
Source verification
Fully open source at github.com/ikchain/Fabrik-Codek (MIT license). Clone the repo and audit before installing.
Fabrik-Codek
一个了解你的7B模型,胜过不了解你的400B模型。
Fabrik-Codek 是一种个人认知架构,可在本地与任何 Ollama 模型一起运行。它不仅仅检索文档——它从你的工作方式中构建知识图谱,衡量你在每个主题上的专业水平,将任务路由到具有正确检索策略的模型,观察其响应是否真正有帮助,并随着时间的推移不断自我优化。
工作原理
- 1. 你工作 — Fabrik-Codek 在本地数据湖中捕获代码变更、会话记录、决策和所学知识
- 知识提取 — 一个11步的流水线将实体和关系提取到知识图谱以及向量数据库中
- 个人画像 — 分析你的数据湖以了解你的领域、技术栈、模式及工具偏好
- 能力评分 — 衡量你在每个主题上的知识深度(专家/熟练/新手/未知)
- 自适应路由 — 按任务类型和主题对每个查询进行分类,选择合适的模型,调整检索深度,并构建三层系统提示
- 结果追踪 — 从对话模式推断响应是否有用(零摩擦,无需手动反馈)
- 自我修正 — 针对表现不佳的任务/主题组合调整检索参数
每一次交互都会反馈到系统中。Fabrik-Codek 本身不发出任何出站网络请求——它仅连接到 Ollama 以及可选的本地 Meilisearch。模型下载由 Ollama 自己的 CLI(ollama pull)处理,而非 Fabrik-Codek。
设置
在 openclaw.json 或 ~/.claude/settings.json 中配置为 MCP 服务器:
json
{
mcpServers: {
fabrik-codek: {
command: fabrik,
args: [mcp]
}
}
}
如需网络访问(SSE 传输):
json
{
mcpServers: {
fabrik-codek: {
command: fabrik,
args: [mcp, --transport, sse, --port, 8421]
}
}
}
首次运行
安装后,初始化并构建知识库:
bash
fabrik init # 设置配置,下载模型
fabrik graph build --include-transcripts # 从会话构建知识图谱
fabrik rag index # 将数据湖索引到向量数据库
fabrik profile build # 构建你的个人画像
fabrik competence build # 构建能力地图
可用的 MCP 工具
fabrik_ask
向本地 LLM 提问,可选择从知识库中获取上下文。任务路由器会自动分类你的查询,根据你的能力选择合适的模型,调整检索策略,并构建个性化的系统提示。
- - userag=true — 向量搜索上下文
- usegraph=true — 混合上下文(向量 + 图谱 + 全文)
示例:我应该如何处理数据库连接池?
fabrik_search
在你积累的知识中进行语义向量搜索。按含义返回最相关的文档、模式和示例——而不仅仅是关键词。
示例:查找带有指数退避的重试逻辑示例
fabrikgraphsearch
遍历知识图谱以查找实体(技术、模式、策略)及其关系。有助于理解概念在你的经验中如何相互关联。
示例:在我的知识图谱中,哪些技术与 FastAPI 相关?
fabrikfulltextsearch
通过 Meilisearch 进行全文关键词搜索。当你确切知道特定术语时,使用此功能进行精确关键词或短语匹配。可选——系统无需安装 Meilisearch 即可运行。
示例:在我的知识库中搜索 EXPLAIN ANALYZE
fabrikgraphstats
知识图谱统计:实体数量、边数量、连通分量、类型分布和关系类型。
fabrik_status
系统健康检查:Ollama 可用性、RAG 引擎、知识图谱、全文搜索和数据湖状态。
可用的 MCP 资源
| URI | 描述 |
|---|
| fabrik://status | 系统组件状态 |
| fabrik://graph/stats |
知识图谱统计 |
| fabrik://config | 当前配置(已脱敏) |
何时使用每个工具
| 场景 | 工具 | 原因 |
|---|
| 需要上下文的编码问题 | fabrikask 配合 usegraph=true | 获取混合检索 + 个性化提示 |
| 查找相似模式或示例 |
fabrik_search | 跨所有知识的语义相似性 |
| 理解概念如何关联 | fabrik
graphsearch | 图谱遍历显示实体关系 |
| 查找确切术语或短语 | fabrik
fulltextsearch | BM25 关键词匹配 |
| 检查知识库是否健康 | fabrik_status | 组件健康检查 |
| 了解知识分布 | fabrik
graphstats | 实体/边数量和类型 |
认知循环
系统使用得越多就越智能:
你工作 → 飞轮捕获 → 流水线提取知识
↑ ↓
策略优化器 ← 结果追踪器 ← LLM 在上下文中响应
↓ ↑
└──── 调整检索 ──→ 任务路由器 ─┘
↓
画像 + 能力 + 任务特定提示
- - 个人画像 从你的数据湖中学习你的领域、技术栈和偏好
- 能力模型 使用4个信号(条目数量、图谱密度、时效性、结果率)对每个主题的专业水平进行评分
- 任务路由器 将查询分类为7种任务类型,检测主题,选择模型,调整检索
- 结果追踪器 从对话模式推断响应质量(话题改变=接受,重新表述=拒绝)
- 策略优化器 针对薄弱环节调整检索参数
- 图谱时间衰减 淡化过时知识,强化近期活动
- 语义漂移检测 当实体的上下文在图谱构建之间发生变化时发出警报
- 上下文门控 决定是否注入 RAG 上下文(对于通用查询跳过,因为上下文会成为噪音)
- 相关性过滤器 丢弃查询与文本之间令牌重叠度低的检索块,防止领域特定知识污染通用答案
要求
安装说明:Fabrik-Codek 是一个仅提供指令的技能——没有自动安装程序。你需要从 GitHub 仓库 通过 git clone + pip install -e .[dev] 手动安装。这让你可以在安装前审计完整的源代码。该技能本身包含文档和 MCP 服务器配置,而非可执行代码。
安全与隐私
无外部网络调用
Fabrik-Codek 不发出任何出站网络请求。它仅连接到你自己机器上运行的服务:
- - Ollama 在 localhost:11434 — 你本地运行的 LLM 服务器(用于推理和嵌入)
- Meilisearch 在 localhost:7700(可选)— 你本地运行的搜索引擎
无遥测、无分析、无回传。在源码中验证:grep -r requests\.\|httpx\.\|urllib src/ — 所有 HTTP 调用仅针对 localhost。设置期间唯一的网络活动是 ollama pull,这是 Ollama 自己的 CLI 从 ollama.ai/library 下载模型——Fabrik-Codek 不发起也不控制这些下载。
fabrik init 的作用
fabrik init 执行以下仅限本地的操作:
- 1. 检查 Python 版本(>= 3.11)
- 检测 Ollama 是否在 localhost:11434 运行
- 在当前目录创建 .env 配置文件
- 创建本地数据目录(./data/embeddings/、./data/graphdb/、./data/profile/)
- 通过 ollama pull 拉取 Ollama 模型——模型由 Ollama 自身 从 ollama.ai/library 下载,而非 Fabrik-Codek
Fabrik-Codek 不从任何服务器下载任何文件。模型下载完全由 Ollama 自己的 CLI 处理。
数据访问范围
读取(全部本地、全部可选加入、从不自动):
| 路径 | 内容 | 时机 | 原因 |
|------|------