cli-view-layer
Skill2 starsChanged 5 months agoApache-2.0View on GitHub
Keep CLI command definitions thin — declare the input, call one app/ use case, answer data and render it as text — no business logic in src/cli/definitions/.
In this repository16 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- boundariesSkill
- effect-servicesSkill
- find-docsSkill
- infrastructure-adaptersSkill
- model-routingSkill
- observabilitySkill
- phax-cliSkill
- phax-decide-planSkill
- phax-decide-reviewSkill
- phax-decide-specSkill
- phax-planningSkill
- phax-reviewSkill
- phax-specSkill
- state-machinesSkill
- validation-boundariesSkill
The file
Files
CLI view layer
The rule
Each command is a definition under src/cli/definitions/, and it stays thin.
A definition built with defineCommand (from src/cli/commandLibrary/contract/)
only:
- Declares its input:
argsandflagsas Effect Schemas, plusstdinwhen it reads a document. The runner decodes them; a call that does not decode is refused with exit 64 beforerun. - Calls one
app/use case inrun, providing its layers. - Answers data:
outputis the schema of the answer--jsonprints. - Renders that answer as today's text in
render, and declares each failure as a tagged error with its exit code and sentence.
A definition must not contain business logic, nor chain unrelated use cases (that
belongs in app/). What src/cli/commands/ still holds is shared plumbing the
definitions import (layers, usage, stop and session-failure text), not commands.
Output
A definition never writes to the process. While it runs, it writes through its
context: say (stdout, a note line under --json) and progress (stderr, a
note line under --json). A use case that prints as it goes takes an
OutputPort (src/ports/output.ts); outputPortOf(call) in
src/cli/definitions/runOutcome.ts builds one from the context. The runner owns
stdout and stderr under --json: a line written around it breaks the answer.
Why
- The use cases are testable without a CLI harness.
- Exit codes, refusals and
--jsonlive in the runner, the same for every command. phax <command> --json-schemaandphax.usage.kdlare generated from the definitions, so they cannot drift from the code.
Guards
tests/unit/architecturalGuards.test.ts enforces the boundaries: the cli imports
only layer composition from infra/, no direct Node I/O outside its allowlist,
only the runner's adapter imports commander, and no file under src/app/ writes
to process.stdout, process.stderr or the console.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

