Great! There's a `--command` option. So you could run `opencode run --command script -- "create a Python script to scrape website"`. That would invoke the custom command. Also you can use `--agent general` to force agent.
But the markdown command already specifies agent: general and subtask: true. So using `--command script` should work.
Thus the command line could be:
```
opencode run --command script -- "your script requirements"
```
That's two lines if you include the description. But the user asked for "a command of no more than a couple of lines, that invokes a subagent". They might mean a single command to type in the TUI, which is `/script`. That's one line.
I'll present both options. Let me also check if there's a way to run a subagent directly via task tool from CLI. Actually the `--agent` flag likely sets the primary agent, not a subagent. The subtask flag in the command will trigger a subagent invocation.
I think the markdown file is the solution. Let me also add an example of usage. I'll create a brief documentation.
But first, let me ensure the command file is correct. The frontmatter uses `subtask: true`. According to the docs, `subtask` boolean forces the command to trigger a subagent invocation. That's exactly what we want. The `agent: general` specifies which agent to use.
The prompt tells the agent to ignore project context. However, the general agent still has access to tools like read, grep, etc., which might read project files. But we can't restrict that; we just ask it to ignore project context. That's fine.
Alternatively, we could create a custom agent configuration that restricts tools to only question, webfetch, websearch, codesearch, write, bash (for testing). But that's more complex.
Let me also consider using the `explore` agent which has limited tools (grep, glob, bash, webfetch, websearch, codesearch, read). It doesn't have edit or write tools though. So can't write files. So general is better.
I think the command is ready. Let me output the final answer with the command details.
Command created: /script
File: ~/.config/opencode/commands/script.md
---
description: Write a one-off script ignoring project context
agent: general
subtask: true
---
Ignore any project context. You are writing a standalone one-off script or program.
Ask clarifying questions about:
- Language/technology preference (Python, JavaScript, Shell, etc.)
- Purpose and requirements
- Dependencies and environment constraints
- Input/output format
- Any specific libraries or frameworks
Research documentation if needed. Deliver a complete, working script with clear instructions for execution.
Use $ARGUMENTS as initial requirements if provided.
Usage:
- In TUI:
/script or /script "create a Python script to scrape website"
- CLI:
opencode run --command script -- "your requirements"
The command invokes a general subagent that will ask questions, research documentation, and deliver a working script independent of the current project context.