Product Requirements Document — knife
Purpose and scope
This document specifies the requirements for knife, a command-line interface for managing a snackbox instance. It covers the CLI behavior, configuration model, output conventions, and non-functional constraints. It does not cover the snackbox server itself.
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
Definitions
| Term | Definition |
|---|---|
| knife | The CLI described by this document |
| snackbox | The headless CMS server that knife communicates with |
| operator | A person who installs and configures knife on a system or in a pipeline |
| user | A person who runs knife interactively to manage a snackbox instance |
| token | A short-lived JWT access token used to authenticate API requests |
| refresh token | A longer-lived token used to obtain a new access token without re-entering credentials |
Functional requirements
Authentication
- knife MUST provide a
logincommand that accepts an email address and password and stores the resulting tokens in the config file. - The
logincommand MUST prompt for the password interactively when it is not supplied as a flag, and MUST NOT echo the password to the terminal. - knife MUST provide a
logoutcommand that invalidates the current session token on the server. - knife MUST provide a
logout-allcommand that invalidates all sessions for the authenticated user. - The
logout-allcommand MUST prompt for confirmation before proceeding unless the--yesflag is supplied. - knife MUST provide a
refreshcommand that exchanges the stored refresh token for a new access/refresh token pair and updates the config file. - knife MUST provide a
change-passwordcommand that prompts for the current password and the new password.
User management
- knife MUST provide
users list,users get,users create,users update, andusers deletecommands. users listMUST support--pageand--limitflags for pagination.users createMUST accept--name,--email,--role, and--passwordflags.users updateMUST accept--name,--email, and--roleflags.users deleteMUST prompt for confirmation before deleting unless--yesis supplied.- The
--roleflag MUST accept the valuesadmin,author,editor, andmember.
Own profile (me)
- knife MUST provide
me getandme updatecommands that operate on the currently authenticated user's profile. me updateMUST accept--nameand--emailflags.
Settings
- knife MUST provide
settings getandsettings updatecommands. settings updateMUST accept flags for every field of the site settings resource:--title,--description,--slogan,--language,--brand-color,--logo-url,--icon-url,--theme,--announcement-text, and--announcement-active.settings updateMUST only modify the fields whose flags were explicitly provided; fields that were not specified MUST be preserved.- knife MUST provide
settings social list,settings social add, andsettings social deletecommands. settings social addMUST accept--nameand--urlflags.settings social deleteMUST prompt for confirmation before deleting unless--yesis supplied.
Output
- Every command MUST produce human-readable output by default.
- List commands MUST render a column-aligned table.
- Single-record commands MUST render a two-column key/value list.
- Mutating commands that succeed MUST print a short confirmation message.
- Every command MUST support a
--jsonglobal flag that causes the raw API response body to be written to stdout as indented JSON instead of the default format. - Error messages MUST be written to stderr.
Configuration
- knife MUST read configuration from
~/.config/knife/config.yaml, respecting theXDG_CONFIG_HOMEenvironment variable. - knife MUST support overriding any config key via an environment variable with the prefix
KNIFE_(e.g.KNIFE_SERVER). - knife MUST support a global
--serverflag that overrides the configured server URL for a single invocation. - knife MUST support a global
--jsonflag that overrides output format for a single invocation.
Non-functional requirements
Security
- Tokens MUST NOT be passed as command-line flags. They MUST be read from the config file only, to prevent leaking them via shell history or process listings.
- The config file MUST be created with mode
0700on its parent directory so that it is not readable by other users on the same system. - Passwords MUST be read via a terminal prompt that suppresses echo. Accepting a password via flag is OPTIONAL and, when offered, SHOULD be documented as suitable only for non-interactive automation.
Compatibility
- knife MUST produce a single statically-linked binary with no runtime dependencies.
- Released binaries MUST target Linux (amd64, arm64), macOS (amd64, arm64), and Windows (amd64).
Statefulness
- The config file MUST be the only persistent state that knife writes on the user's machine.
- knife MUST NOT require a running daemon or background service.
- knife SHOULD be safe to run concurrently from multiple terminals; config writes are best-effort and not required to be atomic.