Skip to content
Back to skills

Cli View Layer

ASecurity

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/.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 19, 2026
ai-agentsgonode

Works with

  • cli

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add lbdremy/phax --skill cli-view-layer --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Cli View Layer?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Cli View Layer
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/lbdremy-cli-view-layer/badge)](https://www.skillsdirectory.com/skills/lbdremy-cli-view-layer)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: cli-view-layer
description: 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/.
---

# 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:

1. Declares its input: `args` and `flags` as Effect Schemas, plus `stdin` when it
   reads a document. The runner decodes them; a call that does not decode is
   refused with exit 64 before `run`.
2. Calls one `app/` use case in `run`, providing its layers.
3. Answers data: `output` is the schema of the answer `--json` prints.
4. 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 `--json` live in the runner, the same for every command.
- `phax <command> --json-schema` and `phax.usage.kdl` are 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.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.