How to Use in Command Line
IWE provides a powerful command-line interface for managing markdown-based knowledge graphs. The CLI enables you to initialize projects, normalize documents, explore connections, export visualizations, and create consolidated documents.
Quick Start
- Initialize a project:
iwe init - Create a new document:
iwe create --template default --var title="My Note" - Retrieve a document with context:
iwe retrieve -k my-note - Find and search documents:
iwe find "search term" - Count matching documents:
iwe count --filter 'status: draft' - Normalize all documents:
iwe normalize - View document hierarchy:
iwe tree - Analyze your knowledge base:
iwe stats - Export graph visualization:
iwe export -f dot - Rename a document:
iwe rename old-key new-key - Delete a document:
iwe delete document-key - Bulk delete by filter:
iwe delete --filter 'status: archived' - Extract a section:
iwe extract document --section "Title" - Inline a reference:
iwe inline document --reference "other-doc" - Overwrite a document body:
iwe update -k document-key -c "new content" - Mutate frontmatter:
iwe update --filter 'status: draft' --set reviewed=true - Attach via configured action:
iwe attach --to today -k document-key
Installation & Setup
Before using the CLI, ensure IWE is installed and available in your PATH. Initialize any directory as an IWE project:
cd your-notes-directory
iwe initThis creates a .iwe/ directory with configuration files.
Global Usage
iwe [OPTIONS] <COMMAND>Global Options
-V,--version: Display version information-v,--verbose <LEVEL>: Set verbosity level (default: 0)1: Minimal output (INFO level messages to stderr)2or higher: Debug-level information to stderr
-h,--help: Show help information
Configuration
Commands respect settings in .iwe/config.toml:
[library]
path = "" # Subdirectory containing markdown files
[markdown]
refs_extension = ""
refs_path = "relative"
date_format = "%b %d, %Y"See Configuration for all available options.
Querying
find, count, update, and delete accept the same YAML-based filter language. Read-only commands (retrieve, tree, export) accept the filter flags as a selector to narrow what they operate on.
The two entry points:
--filter "EXPR"— inline YAML filter document.- Structural anchor flags —
-k,--includes,--included-by,--references,--referenced-by(all repeatable, ANDed at the top level), with optionalKEY[:DEPTH]/KEY[:DIST]colon-suffix.
See the Query Language reference for the YAML syntax, operators, and examples.
Command Categories
Document Management
| Command | Description | Documentation |
|---|---|---|
init | Initialize a new IWE project | IWE Init |
create | Create a document from complete content, or from a template | IWE Create |
new | Create a new document from a title | IWE New |
update | Overwrite a document body, or mutate frontmatter via filter | IWE Update |
normalize | Normalize all documents | IWE Normalize |
Document Retrieval
| Command | Description | Documentation |
|---|---|---|
retrieve | Retrieve document with context | IWE Retrieve |
find | Search and discover documents | IWE Find |
count | Count documents matching a filter | IWE Count |
tree | Display document hierarchy | IWE Tree |
Refactoring Operations
| Command | Description | Documentation |
|---|---|---|
rename | Rename a document and update references | IWE Rename |
delete | Delete a document and clean up references | IWE Delete |
extract | Extract a section to a new document | IWE Extract |
inline | Inline a referenced document | IWE Inline |
Analysis & Export
| Command | Description | Documentation |
|---|---|---|
schema | Infer and display frontmatter schema | IWE Schema |
stats | Analyze knowledge base statistics | IWE Stats |
export | Export graph visualization | IWE Export |
squash | Squash documents | IWE Squash |
Exit Codes
| Code | Meaning |
|---|---|
0 | Success - command completed without errors |
1 | Error - invalid arguments, missing files, operation failed |
All commands return exit code 0 on success. On error, commands print a message to stderr and return exit code 1.
# Check exit code
iwe find "nonexistent-query"
echo $? # Returns 0 (empty result is not an error)
iwe retrieve --key "missing-doc"
echo $? # Returns 1 (document not found is an error)