Tier: Opt-In | Priority: P2
Source: §4 Verbosity & Token Cost
Addresses: Severity: Medium / Token Spend: High / Time: Low / Context: High
The framework MUST provide a --fields <comma-separated-names> flag on all commands. When specified, the JSON data object MUST contain only the listed top-level fields. Framework-level fields (ok, error, meta, warnings, pagination) MUST always be present regardless of --fields. This filtering MUST occur at the serialization layer, not requiring per-command implementation.
--fields id,namereturns adataobject with onlyidandnamekeysok,error,metaare always present even with--fields- An unknown field name in
--fieldsis silently ignored (not an error) --fieldsis available on every command
Type: response-envelope.md
The data field is projected to contain only the requested fields. The envelope shape (ok, error, warnings, meta) is unaffected.
$ tool list-users --fields id,name --output json{
"ok": true,
"data": [
{ "id": "u1", "name": "alice" },
{ "id": "u2", "name": "bob" }
],
"error": null,
"warnings": [],
"meta": { "duration_ms": 42 }
}The framework registers --fields globally at opt-in time. Projection is applied at the serialization layer.
app = Framework("tool")
app.enable_fields_flag()
# tool list-users --fields id,name → data projected to id and name only
# tool get-user --id 1 --fields email → data contains only email
| Requirement | Tier | Relationship |
|---|---|---|
| REQ-O-001 | O | Composes: --fields filters within the --output json envelope |
| REQ-F-004 | F | Provides: envelope shape that --fields projects into |
| REQ-F-021 | F | Enforces: meta is never filtered by --fields |