indexion-kgf
Skill2 starsChanged 7 months agoApache-2.0View on GitHub
Debug and inspect KGF specs — view tokenization results, parse trees, and extracted edges from source files. Use when adding/fixing language support or when indexion's analysis output looks wrong.
In this repository9 other files it gives its agents.
- indexion-agent-orientSkill
- indexion-documentationSkill
- indexion-identitySkill
- indexion-readmeSkill
- indexion-refactorSkill
- indexion-sddSkill
- indexion-searchSkill
- indexion-segmentSkill
- indexion-wikiSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 2 are distinctive, and 3 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.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Debugging grep patterns: when a grep pattern doesn't match, use kgf tokens to see the actual token kinds
- Distinctive: line 88
When a grep pattern doesn't match as expected:
- Very specific: line 111
Run indexion kgf inspect <file> to see the full processing pipeline
- Very specific: line 112
If something looks wrong, drill down with tokens, events, or edges
- Distinctive: line 180
After modifying a KGF, always verify doc appears in declares edges:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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.
Files
indexion kgf
Inspect and debug KGF language specs by viewing tokens, parse events, and extracted edges.
When to Use
- User wants to debug how indexion processes a specific file
- User is developing or modifying a KGF spec
- User asks "how does indexion parse this file?"
- Verifying that tokenization/parsing works correctly for a language
- Debugging grep patterns: when a grep pattern doesn't match, use
kgf tokensto see the actual token kinds
Subcommands
indexion kgf list — List Installed Specs
indexion kgf listindexion kgf update — Update All Specs
Download the latest specs from GitHub.
indexion kgf updateindexion kgf add — Install a Single Spec
indexion kgf add <spec-name>indexion kgf inspect — Full Inspection
Show tokens, events, and edges all at once.
indexion kgf inspect <file>
indexion kgf inspect --spec=typescript src/app.tsindexion kgf tokens — Tokenization Only
Show how a file is tokenized.
indexion kgf tokens <file>
indexion kgf tokens --spec=go-mod go.modindexion kgf events — Parse Events Only
Show parse events generated from tokens.
indexion kgf events <file>indexion kgf edges — Extracted Edges Only
Show the dependency edges extracted from a file.
indexion kgf edges <file>
indexion kgf edges fixtures/project/npm/package.jsonOptions
| Option | Default | Description |
--spec=NAME | auto-detect | KGF spec name to use |
--kgf-dir=PATH | kgfs | KGF specs directory |
Relationship to grep
indexion grep uses KGF tokenization under the hood. Pattern aliases
(pub → KW_pub) are derived from the === lex section of KGF specs.
When a grep pattern doesn't match as expected:
# 1. See the actual tokens for a file
indexion kgf tokens src/config/paths.mbt
# 2. Check which token kinds exist
indexion kgf tokens src/config/paths.mbt | head -20
# 3. Then adjust your grep pattern to match the actual token kinds
indexion grep "KW_pub KW_fn Ident" src/config/paths.mbtCommon token kinds (MoonBit):
KW_pub,KW_fn,KW_struct,KW_enum,KW_type,KW_trait,KW_let,KW_forIdent(lowercase identifiers),TypeIdent(PascalCase type names)LPAREN,RPAREN,LBRACE,RBRACE,LBRACKET,RBRACKETNL(newline),SKIP(whitespace — filtered from grep patterns)DocComment,DocLine,DocSection,LineComment,BlockCommentString,Number,Char
Workflow
- Run
indexion kgf inspect <file>to see the full processing pipeline - If something looks wrong, drill down with
tokens,events, oredges - Compare with the KGF spec file (
kgfs/<lang>.kgf) to diagnose issues
KGF Development Pitfalls
Common bugs found when writing or modifying KGF specs:
PEG Item Ordering (first-match-wins)
KGF uses PEG parsing. In Item -> A / B / C, if A matches, B and C are
never tried. DocComment as a standalone alternative before declaration
rules will consume doc comments that should be attached to declarations.
# BAD: DocComment before FuncDecl — doc is consumed as standalone item
Item -> NL / DocComment / FuncDecl / Other
# GOOD: DocComment after declarations — FuncDecl's doc:DocComment? gets it
Item -> NL / FuncDecl / DocComment / OtherNL Between Doc and Keyword
Source code has newlines between doc comments and declarations. Without
NL? or NL*, the optional doc capture fails silently:
# BAD: DocComment immediately followed by keyword — NL breaks the match
FuncDecl -> doc:DocComment? KW_fn id:Ident ...
# GOOD: NL? allows the typical newline between doc and keyword
FuncDecl -> doc:DocComment? NL? KW_fn id:Ident ...Bottom-Up Event Order (bind/scope)
Events fire bottom-up: child rules before parent rules. If ExportDecl
wraps FunctionDecl, FunctionDecl fires first. Use bind/$scope to
pass data from child to parent:
on FunctionDecl {
bind ns "value" name "child_decl_id" to $id
edge declares from $file to sym_id attrs obj(...)
}
on ExportDecl when $doc {
let id = $scope("value", "child_decl_id")
edge declares from $file to sym_id attrs obj("doc", $doc, ...)
}Token Priority Conflicts
Tokens defined earlier take priority. A generic Operator /[=+\-*]+/
before EQ /=/ will consume = as Operator. Define specific tokens first:
# BAD: Operator matches = before EQ can
TOKEN Operator /[!$%&*+\-.\/:<=>?@^|~]+/
TOKEN EQ /=/
# GOOD: EQ defined first, takes priority
TOKEN EQ /=/
TOKEN Operator /[!$%&*+\-.\/:<=>?@^|~]+/Verifying Doc Extraction
After modifying a KGF, always verify doc appears in declares edges:
# Must show doc="..." in the declares edge
indexion kgf edges test_file.ts --spec=typescript | grep declares
# If doc is missing, check events to see where the DocComment went
indexion kgf events test_file.ts --spec=typescript | grep DocCommentDoes 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
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.

