DEV Community

Hopkins Jesse
Hopkins Jesse

Posted on

I Built a Knowledge Base for AI Agents Using Docsify (Here's What I Learned)

I Built a Knowledge Base for AI Agents Using Docsify (Here's What I Learned)

Three months ago, I had a problem: six AI agents were generating reports, logs, and findings every day, and I had no idea what any of them were doing. Agent01 would discover something useful on Monday, Agent03 would trip over the same problem on Wednesday, and nobody would be the wiser.

The solution wasn't more sophisticated tooling. It was a simple docs site running on Docsify, serving markdown files from a local folder. Total setup time: maybe two hours. Total value: way more than I expected.

The Problem

Each of my agents has a specific role:

  • 武松 (Wu Song) — Quantitative trading strategy backtesting
  • 萧让 (Xiao Rang) — Strategy audit and review
  • 戴宗 (Dai Zong) — Real-time data collection
  • 特工 X — General task execution

They all write reports to /root/.openclaw/workspace/reports/. Before the knowledge base, these were just... sitting there. I'd have to manually open files, search through them with grep, and hope I remembered which agent wrote what.

The agents themselves had no way to access each other's work. Agent05 could spend hours researching something that Agent02 already figured out last week.

The Setup

Docsify is a lightweight documentation generator that serves markdown files as a static site. No build step, no compilation — just drop markdown files in a folder and it renders them.

Here's the entire setup:

# Install docsify globally
npm install -g docsify-cli

# Create the docs folder
mkdir -p /root/.openclaw/workspace/docs

# Initialize docsify (creates index.html and .docsify/config.js)
cd /root/.openclaw/workspace/docs
docsify init .
Enter fullscreen mode Exit fullscreen mode

The index.html that docsify generates is basically a single-page app that fetches markdown files on demand. I modified it to point to the reports folder:

<!-- docs/index.html -->
<div id="app"></div>
<script>
  window.$docsify = {
    name: 'Agent Knowledge Base',
    repo: '',
    loadSidebar: true,
    subMaxLevel: 2,
    search: {
      paths: 'auto',
      placeholder: 'Search reports...',
      noData: 'No results found',
    },
    // Point to the reports folder
    homepage: '../reports/README.md',
  }
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/docsify.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.min.js"></script>
Enter fullscreen mode Exit fullscreen mode

Then I created a simple script to auto-generate the sidebar:

# tools/kb-update.py
import os

REPORTS_DIR = '/root/.openclaw/workspace/reports'
SIDEBAR_PATH = '/root/.openclaw/workspace/docs/_sidebar.md'

def generate_sidebar():
    files = sorted([f for f in os.listdir(REPORTS_DIR) if f.endswith('.md')])

    with open(SIDEBAR_PATH, 'w') as f:
        f.write('* [Home](README.md)\n')
        f.write('\n## Agent Reports\n\n')
        for file in files:
            name = file.replace('.md', '')
            f.write(f'* [{name}]({file})\n')

if __name__ == '__main__':
    generate_sidebar()
    print('Sidebar updated!')
Enter fullscreen mode Exit fullscreen mode

Now whenever an agent finishes a report, it runs python3 tools/kb-update.py and the sidebar updates automatically.

What Made It Actually Useful

The knowledge base could've been just another folder of forgotten files. Three things made it stick:

1. Mandatory Reading Files

I created two files that every agent is required to read before starting work:

reports/blacklist.md — A list of scams, fake airdrops, and bounty programs that waste time. Before an agent pursues an opportunity, it checks this list first.

## Bounty Blacklist

| Project | Reason | Date Added |
|---------|--------|------------|
| CryptoKitties Clone | Fake airdrop, phishing site | 2026-04-01 |
| DeFi Yield Farm | Rug pull, liquidity removed | 2026-04-02 |
| NFT Minting Bot | Gas fee scam, no actual NFT | 2026-04-03 |
Enter fullscreen mode Exit fullscreen mode

reports/lessons-learned.md — Accumulated wisdom from mistakes. This is where agents write up what they learned the hard way.

## Income Iron Laws

1. **No upfront payments** — If a bounty requires payment to participate, it's a scam.
2. **Verify contract addresses** — Always cross-reference with official sources.
3. **Test with small amounts first** — Never go all-in on an untested strategy.
4. **Document everything** — Screenshots, transaction hashes, timestamps.
Enter fullscreen mode Exit fullscreen mode

2. Agent-Specific Reports

Each agent writes to its own file: reports/武松.md, reports/agent05.md, etc. This creates a chronological log of what each agent did, what worked, and what didn't.

Here's a snippet from 武松's report:

## 2026-04-04 16:18 - Strategy Validation

**Task**: Check backtest results and strategy performance

**Execution**:
- Read `reports/武松.md` — last verified 2026-04-03 20:17
- Read `data/minute/hft_eval_results.json` — confirmed core metrics unchanged
- Checked live data sources — 5 markets still collecting

**Core Metrics Confirmed**:
| Metric | Value | Status |
|--------|-------|--------|
| Total Trades | 2,296 | ✅ |
| Win Rate | 53.70% | ✅ (vs break-even 51.02%) |
| Edge | +2.68% | ✅ |
| Sharpe (annualized) | +3.82 | ✅ |
| Sortino (annualized) | +3.73 | ✅ |
| Profit Factor | 1.114 | ✅ |
| Daily PnL | $+1.05 | ✅ |
| MC p-value | 0.000 | ✅ |

**Conclusion**: Strategy passes HFT validation, ready for small live positions.
Enter fullscreen mode Exit fullscreen mode

3. Search That Actually Works

Docsify's built-in search plugin indexes all markdown files. Agents can search for specific topics before starting work:

Agent: "Let me search for 'rate limiting' in the knowledge base..."
[Searches docs site]
Agent: "Found it! 萧让 wrote about rate limit errors last week. Let me check what they learned."
Enter fullscreen mode Exit fullscreen mode

This sounds trivial, but it's the difference between an agent wasting two hours on a solved problem versus standing on the shoulders of... well, other agents.

The Unexpected Benefits

I expected the knowledge base to help with information retrieval. What I didn't expect:

It forced better documentation habits. When you know other agents will read your reports, you write them more carefully. You include more context. You explain your reasoning.

It created accountability. If an agent makes a mistake, it's documented. If it discovers something useful, that's documented too. There's a paper trail.

It enabled async collaboration. Agent01 can work on something Monday, write it up, and Agent03 can pick it up Wednesday without needing a handoff meeting. (Yes, I'm aware I'm anthropomorphizing AI agents. Sue me.)

It became a debugging tool. When something goes wrong, I can trace back through the reports to see when things started diverging from expected behavior.

The Technical Details Nobody Asks About

Running this in production (well, "production" for a home lab) required some boring but necessary work:

Port forwarding — The docs site runs on port 3800. I set up a simple nginx reverse proxy to serve it over HTTPS with a real domain.

File permissions — Agents need write access to the reports folder, but the docs server only needs read access. Separated these with Unix permissions.

Backup strategy — The reports folder is git-tracked and pushed to a private repo daily. Lost data is worse than no data.

Update automation — Every agent runs kb-update.py after writing a report. This is enforced by the agent skill definitions — if they don't update the index, their report won't appear in the sidebar.

What I'd Do Differently

If I started over:

  1. Add tags/categories — Right now it's just a flat list. Tagging reports by topic (trading, security, data-collection) would make navigation easier.

  2. Auto-generate summaries — Each report could have a one-line summary at the top for quick scanning.

  3. Add RSS feeds — So I can subscribe to report updates in my feed reader.

  4. Better diff tracking — When a report updates, show what changed since the last version.

The Verdict

This knowledge base cost almost nothing to set up and has paid for itself many times over. The agents are more efficient because they can learn from each other. I'm more efficient because I can see what's happening at a glance.

The best part? It's just markdown files and a lightweight static site generator. No databases, no complex indexing, no machine learning. Sometimes the boring solution is the right one.

If you're running multiple AI agents (or even just managing a complex project yourself), give this a try. Docsify is free, setup takes an afternoon, and the payoff is immediate.


Docsify docs: https://docsify.js.org/
My setup scripts are in the workspace at `/root/.openclaw/workspace/tools/kb-`. Not polished, but they work.*

Top comments (0)