From Chaos to Clarity: Building OKF — an Open Knowledge Framework for AI Agents
TL;DR — Replaced a messy knowledge base with OKF — a structured system using YAML frontmatter, consistent directory layout, and trigger-based updates. The result: context bootstrapping became a 5-step flow with full documentation coverage.
The Problem: AI-KB Was Not a System
This workspace manages 7 projects — each with its own tech stack (Next.js, Astro, Vite, Express), its own database (Supabase, Neon, Redis), its own authentication strategy, and its own deployment pipeline. That's a lot of context for a human — let alone an AI agent that starts from zero on every conversation.
The old system was called AI-KB. It was a directory of Markdown files parked at ~/AI-KB/, and it worked in the loose sense that the files existed. But it had no structure:
- No frontmatter — files were plain Markdown with no metadata. You couldn't tell when a file was last updated, what type of document it was, or what project it belonged to without reading the whole thing.
- No standard schema — every project described itself differently. One profile had a table for tech stack, another used bullet points, a third was a wall of prose. Machine parsing was impossible.
- No directory convention — files were scattered. Agent profiles sat next to changelogs next to random notes. Finding anything meant spelunking.
- No automation — there were no triggers, no sync commands, no way to programmatically update the KB. Keeping it current was entirely manual, and so it naturally fell out of date.
- No cross-project view — you couldn't compare tech stacks, architectures, or statuses across projects without manually opening 7 files and squinting.
Every time an AI agent started a task, it had to read AI-KB files, guess at their format, piece together the context, and hope nothing was stale. This wasn't a knowledge base. It was a pile of notes that happened to share a directory.
What OKF Is
OKF — Open Knowledge Framework — is the replacement. It lives at ~/OKF/ and it's designed from the ground up for programmatic consumption by AI agents.
The core ideas are simple:
- Every file has a YAML frontmatter block with
type,id, andlast_updated. That's it — three fields that make every document self-describing and machine-readable. - A fixed directory layout —
projects/,system/,skills/,templates/. Every project withinprojects/gets the same set of files:agent.md,profile.md,status.md,structure.md,dependencies.md,commands.md, and optionallydecisions.mdandassets.md. - Consistent schemas across all projects — every
profile.mdlooks the same regardless of the project. Same sections, same table structure, same data. Cross-project comparison isn't just possible — it's trivial. - Trigger-based automation — three commands (
update .md,cleanup,wrap-day) let agents sync the KB with live project state. No manual upkeep. - A bootstrap flow — agents follow a 5-step sequence (read INDEX → read AGENTS.md → follow KB links → read conventions → start task) and have full context every time.
How It Works — A Look Under the Hood
Think of OKF as a filing cabinet with labeled drawers. Every drawer has the same dividers, so you always know where to find things.
Here's the actual directory tree:
OKF/
├── index.md ← the map: every project, its stack, its status
├── projects/
│ └── <project-name>/
│ ├── agent.md ← who: personality, tools, triggers
│ ├── profile.md ← what: stack, deps, architecture
│ ├── status.md ← where: routes, components, changelog
│ ├── structure.md ← layout: directory tree w/ responsibilities
│ ├── commands.md ← how: dev, build, test, lint
│ └── dependencies.md
├── system/ ← shared rules
│ ├── conventions.md ← communication, setup, git rules
│ └── inventory.md ← triggers: update .md, cleanup, blog-post
├── skills/ ← pluggable skill files
└── templates/ ← template for adding new projects
Every file starts with three lines of metadata:
---
type: project-status # what kind of document this is
id: my-project-status # unique id for linking
last_updated: 2026-07-04 # so agents know if it's fresh
---
That's it. An AI agent reads the index.md, picks a project, opens its folder, and finds every piece of context in the same place every time. No guessing, no hunting.
When something changes — a new route, a dependency bump — an agent runs update .md and the status file gets synced automatically.
AI-KB vs OKF: A Comparison
| Aspect | AI-KB (Old) | OKF (New) |
|---|---|---|
| Metadata | None — plain Markdown | YAML frontmatter (type, id, last_updated) |
| Directory layout | Flat, arbitrary | Standardized: projects/<name>/, system/, skills/, templates/ |
| Per-project structure | Inconsistent | Uniform: agent.md, profile.md, status.md, structure.md, dependencies.md, commands.md |
| Cross-project view | Manual comparison | index.md table + workspace.md comparison matrix |
| Automation | None | 3 triggers: update .md, cleanup, wrap-day |
| Skill registry | Not present | skills/INDEX.md with 9 registered skills |
| Sync mechanism | None | manage-okf skill for discovery + normalization + population |
| Machine readability | Low — prose-only | High — frontmatter + consistent tables |
| Context bootstrap | Read random files, guess | Standard 5-step flow |
| Coverage | Partial, uneven | 100% for profiles, structure, deps, commands, status |
| File count | ~15 files, no organization | ~50+ files across 4 directories |
| Last-updated tracking | Not possible | last_updated in every frontmatter |
| Glossary | No | system/glossary.md — 12 terms |
| Templates | No | templates/project-template.md |
The Migration
The migration from AI-KB to OKF happened in three phases over July 3–4, 2026.
Phase 1: Discovery and Design
First, we scanned the workspace to inventory every project — 7 in total, 6 codebases plus the writer service itself. For each one, we documented its tech stack, architecture, dependencies, and commands using a consistent project template.
We also designed the OKF schema: what goes in profile.md vs agent.md vs status.md, what frontmatter fields are required, and how the directory tree should look. The template file at templates/project-template.md became the contract — every project follows it.
Phase 2: Population
We created all the structural files first — profile.md, structure.md, dependencies.md, and commands.md for every project. These were generated from live source files (package.json, directory trees, config files), so they were accurate from day one.
Then we built the system layer: conventions.md (communication rules, Node.js setup for Termux), workspace.md (cross-project comparison table), inventory.md (trigger definitions), and glossary.md (shared terminology).
Phase 3: Migration and Deprecation
The rich content from AI-KB — agent personalities, behavioral triggers, architectural patterns — was migrated into agent.md and status.md files for each project. AI-KB had valuable content buried in inconsistent formats; we extracted it, normalized it, and fit it into the OKF schema.
Once everything was verified, ~/AI-KB/ was removed. All content was accounted for in OKF, and the old path became a symlink to nowhere.
Total time from first scan to full deprecation: roughly 24 hours.
What We Gained
The benefits showed up immediately.
Zero-guess context. An AI agent following the bootstrap flow goes from cold start to fully informed in under 5 reads. No more hunting for the right file, no more guessing if something is up to date.
Cross-project insight. The workspace.md comparison table lets us see at a glance which projects use which stacks — React 19 + Vite 8 here, Astro 7 + Alpine.js there, Next.js 16 + Drizzle over there. That kind of comparison was impossible before.
Automated maintenance. The three triggers — update .md, cleanup, and wrap-day — mean the KB doesn't drift. When a project adds a route or changes its data flow, a single command syncs the status.md. When a day of development wraps up, wrap-day captures the changelog and commits it.
Machine-readable metadata. The YAML frontmatter enables tooling. You could write a script that scans every status.md across all projects, extracts the last_updated field, and alerts when anything is stale. You couldn't do that with AI-KB.
A skill system that works. With skills/INDEX.md, agents can discover available capabilities — code audit, frontend dev, Supabase optimization, design reasoning — and load the relevant skill for the task. This turns the KB from a passive reference into an active tool.
Consistency across every project. Every project has the same files, same sections, same format. If you've read one project's KB, you know the shape of every other one. Cognitive overhead drops to near zero.
What's Next
OKF isn't finished. The next step is building automated validation — a CI step that checks frontmatter freshness, verifies that every file in the directory tree has a matching entry in index.md, and flags projects where status.md hasn't been updated in N days. There's also work to do on the skills system, making skill invocation more automatic based on task analysis.
But the foundation is solid. AI-KB taught us that even bad documentation is better than none. OKF taught us that structured documentation is better by an order of magnitude — especially when the consumers are AI agents that need to understand your entire workspace in seconds.
If you're managing multiple projects with AI assistance, don't settle for a pile of Markdown files. Build yourself a framework. The ROI kicks in on day one.
From Chaos to Clarity: Building OKF — an Open Knowledge Framework for AI Agents
TL;DR — แทนที่ knowledge base ที่รกด้วย OKF — ระบบ structured ที่ใช้ YAML frontmatter, directory layout ที่ consistent, และ trigger-based updates ผลลัพธ์: context bootstrapping กลายเป็น 5-step flow ที่มี documentation coverage ครบ 100%
ปัญหา: AI-KB ไม่ใช่ระบบ
workspace นี้จัดการ 7 โปรเจกต์ — แต่ละอันมี tech stack ของตัวเอง (Next.js, Astro, Vite, Express), ฐานข้อมูลของตัวเอง (Supabase, Neon, Redis), authentication strategy ของตัวเอง, และ deployment pipeline ของตัวเอง นั่นคือ context ปริมาณมากสำหรับมนุษย์ — ไม่ต้องพูดถึง AI agent ที่เริ่มจากศูนย์ทุกครั้งที่คุย
ระบบเก่าเรียกว่า AI-KB มันคือ directory ของ Markdown files ที่วางไว้ที่ ~/AI-KB/, และมันทำงานในแง่ที่ว่าไฟล์มีอยู่ แต่มันไม่มีโครงสร้าง:
- No frontmatter — ไฟล์เป็น Markdown เปล่าไร้ metadata คุณไม่รู้ว่าไฟล์อัปเดตล่าสุดเมื่อไหร่, เป็น document ประเภทไหน, หรือเป็นของโปรเจกต์อะไร โดยไม่ต้องอ่านทั้งหมด
- No standard schema — ทุกโปรเจกต์อธิบายตัวเองต่างกัน บาง profile มีตาราง tech stack, บางอันใช้ bullet points, บางอันเป็น prose กำแพง Machine parsing เป็นไปไม่ได้
- No directory convention — ไฟล์กระจายกัน Agent profiles วางติดกับ changelogs ติดกับ random notes การหาอะไรสักอย่างต้อง spelunking
- No automation — ไม่มี triggers, ไม่มี sync commands, ไม่มีทางอัปเดต KB ด้วยโปรแกรม การรักษาให้มัน current ต้องทำด้วยมือทั้งหมด และมันก็ล้าสมัยไปเอง
- No cross-project view — คุณไม่สามารถเปรียบเทียบ tech stacks, architectures, หรือ statuses ข้ามโปรเจกต์โดยไม่ต้องเปิด 7 ไฟล์และ squinting
ทุกครั้งที่ AI agent เริ่มงาน มันต้องอ่าน AI-KB files, เดารูปแบบ, ประกอบ context, และหวังว่าไม่มีอะไร stale นี่ไม่ใช่ knowledge base มันคือกองโน้ตที่บังเอิญอยู่ใน directory เดียวกัน
OKF คืออะไร
OKF — Open Knowledge Framework — คือตัวแทน มันอยู่ที่ ~/OKF/ และถูกออกแบบจากพื้นเพื่อการบริโภคโดยโปรแกรมของ AI agents
แนวคิดหลักง่ายมาก:
- ทุกไฟล์มี YAML frontmatter block พร้อม
type,id, และlast_updatedแค่นั้น — สามฟิลด์ที่ทำให้ทุก document อธิบายตัวเองและ machine-readable - Fixed directory layout —
projects/,system/,skills/,templates/ทุกโปรเจกต์ในprojects/ได้ไฟล์ชุดเดียวกัน:agent.md,profile.md,status.md,structure.md,dependencies.md,commands.md, และ optionaldecisions.mdกับassets.md - Consistent schemas ข้ามทุกโปรเจกต์ — ทุก
profile.mdหน้าตาเหมือนกันไม่ว่าโปรเจกต์อะไร section เดียวกัน, structure เดียวกัน, ข้อมูลเดียวกัน การเปรียบเทียบข้ามโปรเจกต์ไม่ใช่แค่ทำได้ — มัน trivial - Trigger-based automation — สามคำสั่ง (
update .md,cleanup,wrap-day) ให้ agents sync KB กับ live project state โดยไม่ต้อง upkeep ด้วยมือ - Bootstrap flow — agents ตาม 5-step sequence (อ่าน INDEX → อ่าน AGENTS.md → ตาม KB links → อ่าน conventions → เริ่ม task) และมี full context ทุกครั้ง
มันทำงานยังไง — ลองดูใต้ฝา
คิดถึง OKF เหมือนตู้เก็บเอกสารที่มีลิ้นชักติดป้าย ทุกลิ้นชักมีตัวแบ่งเดียวกัน ดังนั้นคุณรู้เสมอว่าของอยู่ตรงไหน
นี่คือ directory tree จริง:
OKF/
├── index.md ← แผนที่: ทุกโปรเจกต์, stack, status
├── projects/
│ └── <project-name>/
│ ├── agent.md ← ใคร: personality, tools, triggers
│ ├── profile.md ← อะไร: stack, deps, architecture
│ ├── status.md ← ไหน: routes, components, changelog
│ ├── structure.md ← layout: directory tree w/ responsibilities
│ ├── commands.md ← ยังไง: dev, build, test, lint
│ └── dependencies.md
├── system/ ← กติการ่วม
│ ├── conventions.md ← communication, setup, git rules
│ └── inventory.md ← triggers: update .md, cleanup, blog-post
├── skills/ ← pluggable skill files
└── templates/ ← template สำหรับเพิ่มโปรเจกต์ใหม่
ทุกไฟล์เริ่มด้วย metadata สามบรรทัด:
---
type: project-status # document ประเภทไหน
id: my-project-status # unique id สำหรับ linking
last_updated: 2026-07-04 # ให้ agents รู้ว่ายังสดหรือไม่
---
แค่นั้น AI agent อ่าน index.md, เลือกโปรเจกต์, เปิดโฟลเดอร์ของมัน, และเจอ context ทุกชิ้นที่เดิมทุกครั้ง ไม่ต้องเดา, ไม่ต้องล่า
เมื่อมีอะไรเปลี่ยน — route ใหม่, dependency bump — agent รัน update .md และ status file ถูก sync อัตโนมัติ
AI-KB vs OKF: เปรียบเทียบ
| ด้าน | AI-KB (เก่า) | OKF (ใหม่) |
|---|---|---|
| Metadata | ไม่มี — Markdown เปล่า | YAML frontmatter (type, id, last_updated) |
| Directory layout | Flat, ไร้ระบบ | Standardized: projects/<name>/, system/, skills/, templates/ |
| Per-project structure | ไม่ consistent | Uniform: agent.md, profile.md, status.md, structure.md, dependencies.md, commands.md |
| Cross-project view | เปรียบเทียบด้วยมือ | index.md table + workspace.md comparison matrix |
| Automation | ไม่มี | 3 triggers: update .md, cleanup, wrap-day |
| Skill registry | ไม่มี | skills/INDEX.md พร้อม 9 registered skills |
| Sync mechanism | ไม่มี | manage-okf skill สำหรับ discovery + normalization + population |
| Machine readability | ต่ำ — prose-only | สูง — frontmatter + consistent tables |
| Context bootstrap | อ่าน random files, เดา | Standard 5-step flow |
| Coverage | บางส่วน, ไม่เท่ากัน | 100% สำหรับ profiles, structure, deps, commands, status |
| File count | ~15 files, ไม่มีองค์กร | ~50+ files ข้าม 4 directories |
| Last-updated tracking | เป็นไปไม่ได้ | last_updated ในทุก frontmatter |
| Glossary | ไม่มี | system/glossary.md — 12 terms |
| Templates | ไม่มี | templates/project-template.md |
การย้ายระบบ
การย้ายจาก AI-KB ไป OKF เกิดขึ้นในสามช่วง ข้ามวันที่ July 3–4, 2026
Phase 1: Discovery และ Design
แรก, scan workspace เพื่อ inventory ทุกโปรเจกต์ — 7 ทั้งหมด, 6 codebases บวก writer service เอง สำหรับแต่ละอัน, document tech stack, architecture, dependencies, และ commands โดยใช้ project template ที่ consistent
แล้วออกแบบ OKF schema: อะไรไปใน profile.md vs agent.md vs status.md, frontmatter fields ไหนที่ต้องมี, และ directory tree ควรเป็นยังไง template file ที่ templates/project-template.md กลายเป็นสัญญา — ทุกโปรเจกต์ตามมัน
Phase 2: Population
สร้าง structural files ก่อน — profile.md, structure.md, dependencies.md, และ commands.md สำหรับทุกโปรเจกต์ สร้างจาก live source files (package.json, directory trees, config files) ดังนั้นมัน accurate ตั้งแต่วันแรก
แล้วสร้าง system layer: conventions.md (กติกาการสื่อสาร, Node.js setup สำหรับ Termux), workspace.md (ตารางเปรียบเทียบข้ามโปรเจกต์), inventory.md (นิยาม triggers), และ glossary.md (ศัพท์ที่ใช้ร่วมกัน)
Phase 3: Migration และ Deprecation
content หนาจาก AI-KB — agent personalities, behavioral triggers, architectural patterns — ถูกย้ายเข้า agent.md และ status.md files ของแต่ละโปรเจกต์ AI-KB มี content มีค่าฝังอยู่ใน format ที่ไม่ consistent; เราสกัดมัน, normalize, และใส่ใน OKF schema
เมื่อทุกอย่าง verified แล้ว ~/AI-KB/ ถูกลบ content ทั้งหมด accounted ใน OKF, และ path เก่ากลายเป็น symlink ไปที่ไหนก็ไม่รู้
เวลาจาก scan แรกถึง full deprecation: ประมาณ 24 ชั่วโมง
สิ่งที่ได้มา
ประโยชน์ปรากฏทันที
Zero-guess context. AI agent ที่ทำตาม bootstrap flow ไปจาก cold start สู่ fully informed ในแค่ 5 reads ไม่ต้องล่าไฟล์ที่ถูก, ไม่ต้องเดาว่าอะไร up to date
Cross-project insight. ตารางเปรียบเทียบใน workspace.md ให้เราเห็นได้ทันทีว่าโปรเจกต์ไหนใช้ stack อะไร — React 19 + Vite 8 ตรงนี้, Astro 7 + Alpine.js ตรงนั้น, Next.js 16 + Drizzle โน่น การเปรียบเทียบแบบนี้เป็นไปไม่ได้ก่อน
Automated maintenance. สาม triggers — update .md, cleanup, และ wrap-day — หมายความว่า KB ไม่ drift เมื่อโปรเจกต์เพิ่ม route หรือเปลี่ยน data flow, คำสั่งเดียว sync status.md เมื่อวัน development จบ, wrap-day จับ changelog และ commit
Machine-readable metadata. YAML frontmatter เปิดทางให้ tooling คุณเขียน script ที่ scan ทุก status.md ข้ามทุกโปรเจกต์, extract last_updated field, และแจ้งเตือนเมื่ออะไร stale ทำแบบนั้นกับ AI-KB ไม่ได้
Skill system ที่ทำงานได้. ด้วย skills/INDEX.md, agents สามารถค้นพบ capabilities ที่มี — code audit, frontend dev, Supabase optimization, design reasoning — และโหลด skill ที่เกี่ยวข้องกับงาน สิ่งนี้เปลี่ยน KB จาก passive reference เป็น active tool
Consistency ข้ามทุกโปรเจกต์. ทุกโปรเจกต์มีไฟล์เดียวกัน, section เดียวกัน, format เดียวกัน ถ้าคุณอ่าน KB ของโปรเจกต์หนึ่ง, คุณรู้ shape ของโปรเจกต์อื่นๆ ความคิด overhead ลดลงจนเกือบศูนย์
อะไรต่อไป
OKF ยังไม่จบ ขั้นต่อไปคือการสร้าง automated validation — CI step ที่ตรวจ frontmatter freshness, verify ว่าทุกไฟล์ใน directory tree มี matching entry ใน index.md, และ flag โปรเจกต์ที่ status.md ไม่ได้อัปเดตใน N วัน ยังมีงานต่อใน skills system, ทำให้ skill invocation อัตโนมัติมากขึ้นโดยวิเคราะห์จาก task
แต่ foundation แข็งแรง AI-KB สอนเราว่า documentation แย่ยังดีกว่าไม่มี OKF สอนเราว่า documentation ที่มีโครงสร้าง ดีกว่าเป็นเท่าตัว — โดยเฉพาะเมื่อผู้บริโภคคือ AI agents ที่ต้องเข้าใจทั้ง workspace ของคุณในไม่กี่วินาที
ถ้าคุณจัดการหลายโปรเจกต์ด้วย AI assistance อย่าพอใจกับกอง Markdown files สร้าง framework ให้ตัวเอง ROI เริ่มตั้งแต่วันแรก