Argument Passing
Cognitive Modules supports the $ARGUMENTS placeholder, allowing runtime parameter passing.
Basic Usage
In MODULE.md
## Input
User requirement: $ARGUMENTS
Generate output based on the above requirement.
Runtime Passing
cog run my-module --args "your requirement description"
Placeholder Syntax
| Placeholder | Description | Example |
|---|---|---|
$ARGUMENTS | Complete input text | "health product homepage" |
$ARGUMENTS[0] | First word (space-separated) | "health" |
$ARGUMENTS[1] | Second word | "product" |
$0, $1, ... | Shorthand form | Same as above |
Example
MODULE.md
---
name: page-designer
version: 1.0.0
---
# Page Designer
Design a $1 page for $0 type product.
Product type: $ARGUMENTS[0]
Page type: $ARGUMENTS[1]
Invocation
cog run page-designer --args "health-product homepage"
Replacement Result
Design a homepage page for health-product type product.
Product type: health-product
Page type: homepage
With JSON Input
When using --args:
- Skip input Schema validation
- Create
{"$ARGUMENTS": "...", "query": "..."}input
When using JSON file:
- Normal input Schema validation
$ARGUMENTSis obtained from JSON's$ARGUMENTSorqueryfield
{
"$ARGUMENTS": "custom argument",
"other_field": "other value"
}
Best Practices
- Simple tasks: Use
$ARGUMENTSdirectly - Complex input: Define complete input Schema
- Mixed use: Include
$ARGUMENTSfield in Schema
{
"input": {
"type": "object",
"properties": {
"$ARGUMENTS": { "type": "string" },
"options": { "type": "object" }
}
}
}