agentleFS
UmairBaig8UmairBaig8/okf-generator/CLAUDE.md

okf-generator

CLAUDE.md106 starsChanged 5 months agoMITView on GitHub

Generates OKF v0.2 knowledge bundles from codebases. 18 languages, 20 manifest formats, ~100× fewer tokens than raw source. LspEnricher and LlmEnricher both implement this. Wrapped in try/finally by run_enrich(). 4 servers mapped: pyright (Python), gopls (Go), rust-analyzer (Rust), typescript-language-server (TS/JS). Hand-rolled JSON-RPC client over stdio (~150 lines). 3s startup timeout per server. All 4 prompts in _llm_prompts.py. Shared _SECURITY_FIELD_SPEC. Body truncated at 120 lines. Runs after scan, before write. Two passes: 1. link_dependencies() — import statements → manifest dependency edges…

  • Installs packages

The file

We split this CLAUDE.md into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All 4 prompts in _llm_prompts.py.

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

OKF Generator

Generates OKF v0.2 knowledge bundles from codebases. 18 languages, 20 manifest formats, ~100× fewer tokens than raw source.

Quick commands

pip install -e ".[dev]"       # editable install
pytest tests/ -q               # 415 tests
okf generate ./src ./bundle    # generate bundle
okf lookup <Name>              # look up concept
okf enrich --lsp               # LSP enrichment (needs pyright on $PATH)

Architecture

okf/
├── enrich/          # Enricher contract → LspEnricher + LlmEnricher
│   ├── base.py      # Enricher ABC (start/run/stop), EnrichResult
│   ├── lsp.py       # LspEnricher — hand-rolled LSP client over stdio
│   ├── llm.py       # LlmEnricher — base/deep/security LLM modes
│   ├── _lsp_map.py  # LSP server registry (pyright, gopls, rust-analyzer, typescript)
│   └── _llm_prompts.py
├── cli.py            # 19 commands
├── generator.py      # Core scanner + bundle writer
├── linker.py          # Cross-reference pass (deps + call graph)
├── parsers/           # 18 language parsers
│   ├── base.py       # Concept dataclass + TreeSitterParser ABC
│   └── python.js go java rust ruby c cpp csharp dart kotlin php scala julia swift sql yaml
├── domains/           # Domain classification engine
├── lsp.py             # `okf lsp status|resolve|map` CLI
├── mcp_server.py      # MCP server (stdio/HTTP)
├── visualize.py       # HTML graph explorer (Cytoscape.js + tree-sitter WASM)
├── config.py          # Config from .okfconfig + env
└── pairs.py           # JSONL training pair generator

Enricher contract

class Enricher(ABC):
    def start(self, bundle_dir, concepts) -> bool    # prepare; return False to skip
    def run(self, bundle_dir, concepts) -> EnrichResult  # execute; never raise on partial failure
    def stop(self) -> None                             # always safe to call

LspEnricher and LlmEnricher both implement this. Wrapped in try/finally by run_enrich().

LSP enrichment

okf enrich --lsp                # LSP only
okf enrich --full               # LSP + LLM deep (shortcut)
okf enrich --lsp --llm          # LSP + LLM base
okf lsp status                  # table: which servers installed
okf lsp resolve file.py:42:5    # one-shot definition lookup

4 servers mapped: pyright (Python), gopls (Go), rust-analyzer (Rust), typescript-language-server (TS/JS). Hand-rolled JSON-RPC client over stdio (~150 lines). 3s startup timeout per server.

LLM enrichment

okf enrich --llm               # base mode (description/docstring, no source code sent)
okf enrich --llm --mode deep   # deep (reads source body)
okf enrich --llm --mode security

All 4 prompts in _llm_prompts.py. Shared _SECURITY_FIELD_SPEC. Body truncated at 120 lines.

Linker

Runs after scan, before write. Two passes:

  1. link_dependencies() — import statements → manifest dependency edges
  2. link_calls() — function calls → caller/callee edges (conservative: same-file → same-domain → unique → ambiguous)

Project files

  • AGENTS.md — agent instructions
  • TEST.md — integration test spec
  • RELEASE.md — release checklist
  • FUTURE.md — roadmap (SAST enrichment, MkDocs replacement, IDE plugins)
  • CHANGELOG.md — versions
  • tests/ — 415 tests (pytest), 17-phase test.sh, realworld fixtures

Config

.okfconfig or ~/.config/okf/config.json. Sections: llm, providers, enrich, serve, lookup, mcp, pairs.

Version

0.1.51 — MIT License — OKF v0.2 schema

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.