agentleFS
UmairBaig8UmairBaig8/okf-generator/SKILL.md

okf-generator

Skill106 starsChanged 5 months agoMITView on GitHub

Generate OKF (Open Knowledge Format) v0.2 knowledge bundles from codebases, and look up exact concepts for AI agent context injection. Use this skill whenever the user wants to: index a codebase, generate OKF bundles, extract code knowledge into structured markdown, convert codebases into training data, look up functions/classes/modules by name, prime an AI agent with codebase context, or integrate codebase knowledge with OpenCode or other AI coding agents. Also trigger for phrases like "index my code", "generate knowledge bundle", "extract codebase concepts", "what does X class do", or "look up X in OKF".

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    All features via single okf CLI (installed from PyPI).

    line 35
  2. Very specific:

    Default bundle path: ./okf_bundle.

    line 129
  3. Distinctive:

    Use after enrichment finishes to refresh the summary without re-scanning.

    line 172
  4. Very specific:

    No concepts found: Check that source dir is not inside a SKIP_DIRS name (node_modules, .venv, dist, etc).

    line 214
  5. Distinctive:

    JS/TS concepts missing: Ensure tree-sitter-typescript is installed.

    line 222
  6. Very specific:

    Lookup wrong result: Add --type or --file to narrow the search scope.

    line 225

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill 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
SKILL.md

OKF Generator & Lookup Skill

Generates structured OKF v0.2 knowledge bundles from codebases (18 languages via tree-sitter AST + stdlib ast), and provides fast concept lookup for AI agents like OpenCode.

Pipeline Overview

codebase
   |
   v
okf generate  -->  okf_bundle/          (domain/resource-path layout)
                       |
                okf lookup               (zero-LLM concept search)
                       |
                okf pairs          -->  okf_pairs.jsonl  (training data)

CLI Reference

All features via single okf CLI (installed from PyPI).

CommandPurpose
okf generateScan codebase and write OKF bundle
okf lookupSearch bundle and return exact concept
okf pairsConvert bundle to JSONL training pairs
okf summarizeRegenerate SUMMARY.md from existing bundle

Dependencies

pip install okf-generator
# With LLM enrichment:
pip install "okf-generator[llm]"

Task: Generate OKF Bundle

When: user says "index my codebase", "generate OKF bundle", "extract knowledge from code"

Static extraction (no LLM — always run this first)

okf generate <source_dir> <output_dir>

With LLM enrichment (fills missing docstrings and descriptions)

Configure enrichment in .okfconfig (JSON), then run:

okf generate <source_dir> <output_dir> --enrich
# or run enrichment standalone on an existing bundle:
okf enrich <output_dir>
// .okfconfig
{
  "llm": { "enabled": true, "base_url": "http://localhost:8080/v1", "api_key": "llamabarn" },
  "providers": {
    "default": { "model": "ggml-org/gemma-3-4b-it-qat-GGUF:Q4_0", "max_workers": 2 }
  }
}

Enrichment is resumable — rerun safely if interrupted. Already-enriched concepts are skipped automatically (checks disk on every run).

Output layout (mirrors source tree)

okf_bundle/
├── SUMMARY.md              <- bird's-eye view for AI agents
├── index.md                <- root index
├── log.md                  <- generation history
└── <domain>/
    └── <module>/
        ├── index.md        <- lists all concepts in folder
        ├── <module>.md     <- Module concept
        └── <ClassName>.md  <- Class / Function concepts

Task: Look Up a Concept

When: user asks "what does X do", "find class X", "look up X", or needs to prime OpenCode with exact concept context before editing code.

# Full detail — signature, docstring, params, returns, related
okf lookup WorldBankConnector

# All concepts from one source file
okf lookup --file StockAI/RnD/python/connectors/economic_data.py

# Filter by type
okf lookup --type Class connector

# Filter by tag
okf lookup --tag lang:python --tag type:Function fetch

# Compact list (many results)
okf lookup --compact connector

# JSON output (programmatic / agent use)
okf lookup --json WorldBankConnector

# Custom bundle path
okf lookup --bundle ./Knowlege/okf_bundle WorldBankConnector

Default bundle path: ./okf_bundle. Also auto-tries ./Knowlege/okf_bundle and ./knowledge/okf_bundle.


Task: Generate Training Pairs

When: user wants JSONL training data from the OKF bundle.

# Static only (instant, no LLM)
SKIP_SYNTH=1 okf pairs <bundle_dir> output.jsonl

# With LLM (QA, doc, summarize pairs)
SYNTH_BASE_URL="http://localhost:8080/v1" \
SYNTH_API_KEY="llamabarn" \
SYNTH_MODEL="ggml-org/gemma-3-4b-it-qat-GGUF:Q4_0" \
MAX_WORKERS=2 \
QA_PER_CONCEPT=3 \
okf pairs <bundle_dir> output.jsonl

# Specific pair types only
PAIR_TYPES="codegen,qa" okf pairs <bundle_dir> output.jsonl

Pair types

TypeStaticLLMCovers
codegenyesyesFunctions, Classes
qanoyesAll (purpose/params/return/edge)
docnoyesFunctions, Classes
summarizeyesyesModules, Classes
crosslinkyesnoAll with related concepts

Task: Regenerate SUMMARY.md Only

okf summarize <bundle_dir>

Use after enrichment finishes to refresh the summary without re-scanning.


OpenCode Integration

See references/opencode-integration.md for full setup.

Quick setup:

# 1. Add to AGENTS.md (auto-loaded by OpenCode)
echo "OKF bundle at ./okf_bundle — use: okf lookup <Name>" >> AGENTS.md

# 2. Add lookup command
mkdir -p .opencode/commands
echo "RUN okf lookup --bundle ./okf_bundle \$NAME" \
  > .opencode/commands/lookup.md

Supported Languages

LanguageParserExtracts
Pythonstdlib astfunctions, classes, params, return types, docstrings
JS / TStree-sitterfunctions, arrow fns, classes, JSDoc
Gotree-sitterfuncs, methods, structs, interfaces, GoDoc
Javatree-sitterclasses, methods, constructors, Javadoc
Rusttree-sitterfns, structs, enums, traits, impl blocks, doc comments
Rubytree-sitterdefs, classes, modules, hash comments
C / C++ / C#tree-sitterfuncs, structs, classes, headers, XML-doc
Swift / Kotlintree-sitterfuncs, classes, protocols, visibility
PHP / Darttree-sitterclasses, functions, docblocks
Scala / Juliatree-sitterdefs, classes, traits, objects
SQLtree-sittertables, views, functions
YAMLPyYAMLdocuments, keys, anchors

Troubleshooting

No concepts found: Check that source dir is not inside a SKIP_DIRS name (node_modules, .venv, dist, etc). Leading path components like /tmp are no longer skipped (fixed in v0.1.3).

Enrichment slow: Set max_workers: 1 in the provider config. Local models process ~1 request at a time. At 32 tok/sec expect ~3-5s per concept.

Enrichment interrupted: Rerun same command. Enriched files are skipped.

JS/TS concepts missing: Ensure tree-sitter-typescript is installed. TypeScript uses a separate grammar from JavaScript.

Lookup wrong result: Add --type or --file to narrow the search scope.

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.