<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Qmd on KnightLi Blog</title>
        <link>https://www.knightli.com/en/tags/qmd/</link>
        <description>Recent content in Qmd on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Fri, 01 May 2026 03:12:57 +0800</lastBuildDate><atom:link href="https://www.knightli.com/en/tags/qmd/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>qmd: Local Markdown Document Search for AI Agents</title>
        <link>https://www.knightli.com/en/2026/05/01/qmd-markdown-search-for-ai-agents/</link>
        <pubDate>Fri, 01 May 2026 03:12:57 +0800</pubDate>
        
        <guid>https://www.knightli.com/en/2026/05/01/qmd-markdown-search-for-ai-agents/</guid>
        <description>&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; is a search tool for local Markdown documents, with AI Agents as its main target users.&lt;/p&gt;
&lt;p&gt;It solves a specific problem: when a project contains many &lt;code&gt;.md&lt;/code&gt; documents, AI coding assistants often do not know which file to read, which section to cite, or which instructions are current. Full-text grep can find keywords, but it does not understand meaning well. Putting all documentation into the context wastes window space and easily introduces irrelevant content.&lt;/p&gt;
&lt;p&gt;The idea behind &lt;code&gt;qmd&lt;/code&gt; is to index Markdown documents first, then return the most relevant snippets through a search interface for AI to use. It can be used as a command-line tool, integrated through an SDK, or exposed as an MCP Server for clients that support MCP.&lt;/p&gt;
&lt;h2 id=&#34;what-problem-it-solves&#34;&gt;What Problem It Solves
&lt;/h2&gt;&lt;p&gt;Real projects usually have more than one or two README files.&lt;/p&gt;
&lt;p&gt;You may have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Architecture notes&lt;/li&gt;
&lt;li&gt;API documentation&lt;/li&gt;
&lt;li&gt;Development conventions&lt;/li&gt;
&lt;li&gt;Deployment procedures&lt;/li&gt;
&lt;li&gt;Architecture decision records&lt;/li&gt;
&lt;li&gt;Troubleshooting notes&lt;/li&gt;
&lt;li&gt;Requirement documents&lt;/li&gt;
&lt;li&gt;AI usage instructions&lt;/li&gt;
&lt;li&gt;Toolchain notes and reminders&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Humans can browse documents through directories, but AI Agents need a clear retrieval entry point. Otherwise, they may:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Read the wrong document&lt;/li&gt;
&lt;li&gt;Miss key constraints&lt;/li&gt;
&lt;li&gt;Use outdated instructions&lt;/li&gt;
&lt;li&gt;Put irrelevant content into context&lt;/li&gt;
&lt;li&gt;Invent rules in answers based on experience&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is where &lt;code&gt;qmd&lt;/code&gt; is useful. It turns local Markdown documents into a searchable knowledge source, so AI can search first when it needs context, then answer or act based on matched snippets.&lt;/p&gt;
&lt;h2 id=&#34;search-approach&#34;&gt;Search Approach
&lt;/h2&gt;&lt;p&gt;The README says &lt;code&gt;qmd&lt;/code&gt; combines several retrieval methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;BM25 keyword search&lt;/li&gt;
&lt;li&gt;Vector search&lt;/li&gt;
&lt;li&gt;LLM reranking&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;BM25 is good for clear keywords. If you search for a function name, configuration key, error code, or file name, it is usually direct and effective.&lt;/p&gt;
&lt;p&gt;Vector search is better for semantic questions. For example, if you ask “how does this project handle permission validation,” the documentation may not contain that exact phrase, but it may contain related descriptions about authentication, access control, and role checks.&lt;/p&gt;
&lt;p&gt;LLM reranking is used to reorder candidate results. The first two steps find potentially relevant content, and the model then judges which snippets best match the current question.&lt;/p&gt;
&lt;p&gt;This combination is more suitable for AI Agents than plain keyword search, because Agent questions are often task intentions rather than fixed keywords.&lt;/p&gt;
&lt;h2 id=&#34;why-markdown&#34;&gt;Why Markdown
&lt;/h2&gt;&lt;p&gt;Markdown is the most common documentation format in development projects.&lt;/p&gt;
&lt;p&gt;It is simple enough to store in Git and structured enough to include headings, lists, code blocks, links, and tables. For AI, Markdown is also easier to parse than PDFs, web snapshots, or screenshots.&lt;/p&gt;
&lt;p&gt;Because &lt;code&gt;qmd&lt;/code&gt; focuses on Markdown, it can process developer documentation more directly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Split content by headings and paragraphs&lt;/li&gt;
&lt;li&gt;Preserve code blocks&lt;/li&gt;
&lt;li&gt;Preserve document paths&lt;/li&gt;
&lt;li&gt;Return snippets suitable for citation&lt;/li&gt;
&lt;li&gt;Let the Agent know which document an answer comes from&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is more stable than asking AI to randomly scan a repository, and it saves more context than putting every document into a prompt at once.&lt;/p&gt;
&lt;h2 id=&#34;three-entry-points&#34;&gt;Three Entry Points
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; provides three entry points: CLI, SDK, and MCP Server.&lt;/p&gt;
&lt;h3 id=&#34;1-cli&#34;&gt;1. CLI
&lt;/h3&gt;&lt;p&gt;The CLI is suitable for direct terminal use and for scripts.&lt;/p&gt;
&lt;p&gt;You can index a documentation directory and then search related content with commands. For developers, the CLI is the easiest way to validate the tool: first see whether it can find the correct documents, then consider integrating it into more complex workflows.&lt;/p&gt;
&lt;p&gt;This kind of tool is useful inside local projects. For example, before changing code you can search design documents; before debugging, search troubleshooting notes; before writing an API, search API conventions.&lt;/p&gt;
&lt;h3 id=&#34;2-sdk&#34;&gt;2. SDK
&lt;/h3&gt;&lt;p&gt;The SDK is suitable for integrating &lt;code&gt;qmd&lt;/code&gt; into your own tools.&lt;/p&gt;
&lt;p&gt;If you are building an internal development assistant, documentation Q&amp;amp;A system, code review bot, or project knowledge base, you can call the search capability through the SDK instead of asking users to run commands directly.&lt;/p&gt;
&lt;p&gt;The SDK gives more control over:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Search directories&lt;/li&gt;
&lt;li&gt;Query content&lt;/li&gt;
&lt;li&gt;Number of returned results&lt;/li&gt;
&lt;li&gt;Result format&lt;/li&gt;
&lt;li&gt;Whether to pass results to a model for summarization&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This fits scenarios that need deeper integration.&lt;/p&gt;
&lt;h3 id=&#34;3-mcp-server&#34;&gt;3. MCP Server
&lt;/h3&gt;&lt;p&gt;MCP is the most valuable entry point for AI Agents.&lt;/p&gt;
&lt;p&gt;Through MCP Server, clients that support MCP can call &lt;code&gt;qmd&lt;/code&gt; as a document search tool. This lets an Agent search local Markdown documents before acting, instead of guessing project rules.&lt;/p&gt;
&lt;p&gt;A typical workflow could be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The user asks AI to modify a feature&lt;/li&gt;
&lt;li&gt;AI calls &lt;code&gt;qmd&lt;/code&gt; to search related design documents&lt;/li&gt;
&lt;li&gt;&lt;code&gt;qmd&lt;/code&gt; returns the most relevant Markdown snippets&lt;/li&gt;
&lt;li&gt;AI modifies code based on those document constraints&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This is more natural than manually pasting all rules into a new session, and it is better suited to long-term projects.&lt;/p&gt;
&lt;h2 id=&#34;suitable-scenarios&#34;&gt;Suitable Scenarios
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; is suitable for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Projects with many Markdown documents&lt;/li&gt;
&lt;li&gt;AI Agents that often need to look up project rules&lt;/li&gt;
&lt;li&gt;Teams that want AI answers to cite local documents&lt;/li&gt;
&lt;li&gt;Documentation spread across multiple directories&lt;/li&gt;
&lt;li&gt;Reusing the same retrieval capability across CLI, SDK, and MCP&lt;/li&gt;
&lt;li&gt;Reducing AI coding assistants’ tendency to guess project conventions&lt;/li&gt;
&lt;li&gt;Connecting local knowledge bases to Claude Desktop, Claude Code, or other MCP clients&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If your project only has one short README, directly asking AI to read the file is enough.&lt;/p&gt;
&lt;p&gt;But if the documentation has grown to dozens or hundreds of files, or if you want the Agent to search documents before acting, this type of indexing tool becomes meaningful.&lt;/p&gt;
&lt;h2 id=&#34;difference-from-grep&#34;&gt;Difference from grep
&lt;/h2&gt;&lt;p&gt;Tools such as &lt;code&gt;grep&lt;/code&gt; and &lt;code&gt;rg&lt;/code&gt; are excellent for exact search.&lt;/p&gt;
&lt;p&gt;If you know you need &lt;code&gt;DATABASE_URL&lt;/code&gt;, &lt;code&gt;authMiddleware&lt;/code&gt;, &lt;code&gt;404&lt;/code&gt;, or &lt;code&gt;docker compose&lt;/code&gt;, keyword search is usually the fastest.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; is better when you do not know the exact words.&lt;/p&gt;
&lt;p&gt;For example, you may ask:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is the release process for this project?&lt;/li&gt;
&lt;li&gt;What conventions apply when adding a new API?&lt;/li&gt;
&lt;li&gt;Was the caching strategy documented before?&lt;/li&gt;
&lt;li&gt;Which documents should AI read before changing code?&lt;/li&gt;
&lt;li&gt;Where is the design background for a module?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These questions usually require semantic retrieval rather than matching one word. The BM25 + vector + reranking combination in &lt;code&gt;qmd&lt;/code&gt; is intended to make these questions find the right context more easily.&lt;/p&gt;
&lt;h2 id=&#34;relationship-with-rag&#34;&gt;Relationship with RAG
&lt;/h2&gt;&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; can be seen as a lightweight RAG component for Markdown documents.&lt;/p&gt;
&lt;p&gt;It does not try to build a full Q&amp;amp;A system for you. It focuses on one step: finding relevant document snippets. How those snippets are used afterward can be handled by CLI, SDK, an MCP client, or your own Agent workflow.&lt;/p&gt;
&lt;p&gt;This positioning is practical. Many projects do not need a large knowledge base system; they only need AI to search local documents more accurately and quickly, then bring the results back into the current task.&lt;/p&gt;
&lt;h2 id=&#34;notes-for-use&#34;&gt;Notes for Use
&lt;/h2&gt;&lt;p&gt;First, documentation quality still matters.&lt;/p&gt;
&lt;p&gt;A retrieval tool can only find existing content. If the documents are outdated, duplicated, or contradictory, AI may still receive wrong context. Before connecting &lt;code&gt;qmd&lt;/code&gt; to an Agent, clean up the key documents first.&lt;/p&gt;
&lt;p&gt;Second, do not make the index scope too broad.&lt;/p&gt;
&lt;p&gt;Indexing every Markdown file in the repository is not always better. Dependency documentation, temporary notes, and old draft solutions can pollute results. A better approach is to define which directories are trusted documentation sources.&lt;/p&gt;
&lt;p&gt;Third, search results should preserve sources.&lt;/p&gt;
&lt;p&gt;When AI uses document snippets, it should know which file and section they came from. This makes human review traceable and reduces the risk of “this looks like a document conclusion, but it is only a model summary.”&lt;/p&gt;
&lt;p&gt;Fourth, do not replace human judgment completely.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;qmd&lt;/code&gt; can improve context recall quality, but it is not a replacement for the source of truth. Important changes still require current code, test results, and the latest requirements.&lt;/p&gt;
&lt;h2 id=&#34;suitable-teams&#34;&gt;Suitable Teams
&lt;/h2&gt;&lt;p&gt;If your team has already started putting AI Agents into daily development workflows, tools like &lt;code&gt;qmd&lt;/code&gt; can be valuable.&lt;/p&gt;
&lt;p&gt;They are especially suitable for teams that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write a lot of documentation&lt;/li&gt;
&lt;li&gt;Have a long project history&lt;/li&gt;
&lt;li&gt;Need both new people and AI to quickly understand context&lt;/li&gt;
&lt;li&gt;Maintain architecture decision records&lt;/li&gt;
&lt;li&gt;Have many Markdown convention documents&lt;/li&gt;
&lt;li&gt;Want AI to check rules before modifying code&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Its goal is not to make AI all-knowing. It is to make AI guess less and look things up more.&lt;/p&gt;
&lt;h2 id=&#34;reference&#34;&gt;Reference
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://github.com/tobi/qmd&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;tobi/qmd&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;final-thought&#34;&gt;Final Thought
&lt;/h2&gt;&lt;p&gt;The value of &lt;code&gt;qmd&lt;/code&gt; is that it turns local Markdown documents into a search entry point that AI Agents can reliably call.&lt;/p&gt;
&lt;p&gt;When project documentation moves from “instructions for humans” to “a context source searchable by both humans and AI,” AI coding assistants can follow project rules more easily.&lt;/p&gt;
</description>
        </item>
        
    </channel>
</rss>
