Output Modes
codeknit supports three output modes, controlled by the --output-mode flag. Each mode determines how the extracted code structure is written to disk (or stdout).
Output mode is separate from output format. The default format is .skt; pass --format json to emit the same parse result as machine-readable JSON. In directory modes, JSON is written to codeknit.json. In inline mode, JSON is written to stdout.
directory-flat (default, recommended)
Section titled “directory-flat (default, recommended)”- Behavior: Writes chunked
.sktfiles such asmap_001.skt,map_002.skt, etc. - Output directory:
./skeleton/by default - Splitting: Files are split when they exceed the
--max-lineslimit (default: 500 lines) - Use case: Best for most projects. Keeps output organized and readable by limiting file size. You can read only the chunks relevant to your task.
- Minification: When
--minifyis enabled, adict.sktfile is also generated in the output directory, containing token mappings for compressed values.
Example:
codeknit parse ./src# Output: ./skeleton/map_001.skt, map_002.skt, ...directory-tree
Section titled “directory-tree”- Behavior: Mirrors the source directory structure exactly.
- Output directory:
./skeleton/by default - Mapping: One
.sktfile is created per source file, at a corresponding path. - Use case: Ideal when you want to quickly look up the structure of a specific file. Useful for navigation alongside the original codebase.
Example:
codeknit parse ./src --output-mode directory-tree# Output: ./skeleton/src/handler.skt, ./skeleton/pkg/db.skt, etc.inline
Section titled “inline”- Behavior: Dumps all output to stdout.
- Output directory: None created
- Use case: Only recommended for single files or very small projects (fewer than 5 files). Useful when piping output to another tool or inspecting a single file interactively.
Example:
codeknit parse ./src/main.go --output-mode inline# Output: printed directly to terminalJSON format
Section titled “JSON format”- Behavior: Emits a single JSON document containing
files,symbols, optionaledges, and optionalerrors. - Output location:
codeknit.jsonin directory modes, or stdout ininlinemode. - Use case: Best for scripts, editor integrations, CI checks, and tools that need structured data.
Example:
codeknit parse ./src --output-mode inline --format json --edgesSample output:
{ "files": ["app.go"], "symbols": [ { "id": "app.go::User", "short_id": "S1", "name": "User", "file": "app.go", "category": "type", "kind": "struct", "signature": "type User struct", "span": [3, 3] }, { "id": "app.go::Save", "short_id": "S2", "name": "Save", "file": "app.go", "category": "callable", "kind": "function", "signature": "Save(u: S1)", "span": [5, 5] } ], "edges": [ { "from": "app.go::Save", "from_short": "S2", "to": "app.go::User", "to_short": "S1", "kind": "references" } ]}Decision Table
Section titled “Decision Table”| Mode | Best for | Output location |
|---|---|---|
directory-flat |
Most projects (default, recommended) | ./skeleton/map_001.skt, map_002.skt, … |
directory-tree |
Navigating output alongside source code | ./skeleton/<mirrored path>.skt |
inline |
Single file, piping to another tool | stdout — only use for single files or tiny projects |
| Format | Best for | Output |
|---|---|---|
skt |
LLM context and human inspection | .skt files or stdout |
json |
Scripts and structured integration | codeknit.json in directory modes, or stdout in inline |
Rules of Thumb
Section titled “Rules of Thumb”- When unsure → use
directory-flat(the default) - Single file inspection →
inlineis acceptable - More than a few files → prefer
directory-flatordirectory-tree - Large codebases → add
--minifyto reduce token usage - Re-running on same output → use
--cleanto remove stale.sktfiles
Minification
Section titled “Minification”The --minify flag enables dictionary-based compression of repeated tokens (e.g., property keys like exported, async, or common type names). When enabled:
- Repeated values are replaced with short codes (
d0,d1,d2, …) - A
dict.sktfile is written to the output directory, mapping codes to original values - Significantly reduces output size for large codebases
- Works in both
directory-flatanddirectory-treemodes
Example minified output:
[dict]- d0: exported- d1: callable/function
[symbols]## src/main.pyS1 d1 L1-L5 main() {d0}This format preserves full information while minimizing token footprint, making it ideal for LLM-based analysis.