Does the Instagit CLI Support Standard Input (STDIN)?
Yes, the Instagit CLI supports reading DESIGN.md documents from standard input by passing - (hyphen) as the file argument to any command.
The Instagit CLI, part of the google-labs-code/design.md repository, provides robust support for Unix-style piping workflows. According to the source code, every command that processes DESIGN.md files can accept input from stdin instead of a file path, enabling seamless integration with shell pipelines and automated workflows.
How STDIN Support Is Implemented
The readInput Utility Function
The core stdin handling logic resides in the readInput function located in packages/cli/src/utils.ts at lines 18-28. This utility checks whether the supplied file path equals the string "-", and when it detects this special character, it consumes the entire stream from process.stdin rather than reading from the filesystem.
According to the implementation in packages/cli/src/utils.ts, the function treats the hyphen as a signal to switch input sources, making it possible to pipe content directly into the tool without writing temporary files.
Command-Level STDIN Integration
All Instagit CLI commands that expect a DESIGN.md file explicitly document this behavior in their argument descriptions. For example:
- In
packages/cli/src/commands/lint.tsat line 27, the positional argument is described as "Path to DESIGN.md (use-for stdin)" - In
packages/cli/src/commands/export.tsat line 31, the same documentation pattern appears
The top-level README.md at line 219 confirms this capability, stating that "All commands accept a file path or - for stdin".
Practical Usage Examples
Standard File Input
instagit lint path/to/DESIGN.md
Piping from STDIN
cat path/to/DESIGN.md | instagit lint -
Git Integration Pipeline
git show HEAD:DESIGN.md | instagit export - --format=json
All examples work because the readInput function in packages/cli/src/utils.ts (lines 21-28) automatically detects the - argument and reads from process.stdin.
Summary
- The
readInputfunction inpackages/cli/src/utils.tsprovides centralized stdin handling when the file argument is- - All Instagit CLI commands support stdin input for DESIGN.md files, as documented in the README.md at line 219
- The
lintandexportcommands inpackages/cli/src/commands/explicitly declare this capability in their argument descriptions - Shell pipelines like
cat design.md | instagit lint -work natively without additional flags
Frequently Asked Questions
How do I use stdin with the Instagit CLI?
Pass - (hyphen) as the file path argument. The readInput utility in packages/cli/src/utils.ts detects this character and reads the entire stream from process.stdin instead of the filesystem. For example: cat design.md | instagit lint -.
Which commands support reading from stdin?
All commands that accept a DESIGN.md file path support stdin input, including lint and export. The argument descriptions in packages/cli/src/commands/lint.ts and packages/cli/src/commands/export.ts explicitly document this behavior for users.
Is there a specific flag required for stdin mode?
No special flag is needed. Simply use - as the file argument. The CLI automatically switches to stdin mode when it encounters this character, as implemented in the readInput function at lines 18-28 of packages/cli/src/utils.ts.
Where is the stdin handling logic implemented?
The logic resides in the readInput function within packages/cli/src/utils.ts (lines 18-28). This function checks if the input path equals "-" and conditionally reads from process.stdin rather than loading a file from disk.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →