Skip to content

feat(cli): scaffold a command and a test to project form #3204

Closed

Description

@dan-petty

Problem or Motivation

A new devops command or test touches several places, and the rules for them are scattered. In the last days, agents that added a command or a docs page broke CI for places they did not know of:

Proposed Solution & Architectural Design

  • Add devops new command <group> <name>. It writes the files a command needs, in project form: the command function in the group's module, the help and message entries in lang/en/ (with a command help of at most three sentences that names a page), a test in the mirror folder with a failing first test and match= already in place, and a docs page entry when the group has one. It prints the places it cannot edit safely, as a checklist: the MCP exposed or excluded entry, the docs inventory glob, and the regenerate command.
  • Add devops new test <module>. It makes the test file at the mirror path of a source module, from a template that uses the edge fakes and the naming of docs/TESTING.md, and refuses a flat path that the mirror rule refuses.
  • Where an entry in a shared list can be computed instead of written (the MCP list, the docs inventory), the refine step should make the list derive from the command tree or the folder, so no scaffold has to edit it. A check, not a template, is then the safeguard.
  • Output is deterministic and never overwrites a file. --dry-run prints the files and their paths.
  • The same skill pattern as the change-folder scaffold: a short skill calls the command.
  • First decide the test-location rule: update docs/TESTING.md so the mirror rule and the scaffold agree. The scaffold must encode one rule.

Open questions for the refine step: Copier against a built-in template set (the project has few templates and wants offline runs); which shared lists can be derived (MCP list, docs inventory) and which stay manual; whether new command belongs in the devops tree or under devops dev.

Target Subsystem

A new devops new group in src/devops_cli/commands/, templates under src/devops_cli/, docs/TESTING.md, tests/ai/mcp/test_mcp.py, src/devops_cli/config/constants.py (CONST_DOCS_INVENTORY).

Existing Tool Considered

Copier and Cookiecutter generate files from templates and can update them later. They do not edit a Python list or know the project's guard tests. devops ai generate makes failing test scaffolds for a function, but not the mirror path or the command files. Cost to build: about 150k tokens and 8 hours for both commands. To keep: the templates, which change when a rule changes, and the guard tests that keep them in step. Deriving the shared lists lowers the upkeep.

Related: the scaffold of the change folder (feat(openspec): scaffold the change folder of an issue to project form), #3202 (prompt against rules), #3015 (mirror folder rule), #3188.

Proposed design

Problem statement

Agents that add a devops command or a test must edit several scattered places. A missed place breaks CI, as #3182 and #3190 show. This change adds devops new command and devops new test to write the project-form files. The scaffold refuses to overwrite a file, prints the manual steps that remain, and derives the shared lists that can be computed.

Acceptance criteria

Requirement: New group lists scaffold commands

The devops new command group SHALL list the command and test subcommands.

Scenario: Help lists both subcommands

  • WHEN A user runs devops new --help.
  • THEN The output names command and test.

Requirement: Command scaffold writes command files

devops new command SHALL write the command function in the group module, the help and message entries in lang/en/, and the group's docs page entry when that page exists.

Scenario: Command function and language entries are written

  • WHEN A user runs devops new command sample hello in a temporary repository.
  • THEN The sample group module holds the hello function, lang/en/ holds its help and message entries, and the existing docs page names the command.

Requirement: Command scaffold writes the mirror-path test

devops new command SHALL write a test at the mirror path of the group module with a failing first test and match= in its error check.

Scenario: Command test uses the mirror path and match

  • WHEN A user runs devops new command sample hello.
  • THEN The test file sits at the mirror path of the sample module and holds a failing first test and pytest.raises(..., match=...).

Requirement: Command help has three sentences and a page

The generated command help SHALL have at most three sentences and SHALL name a documentation page.

Scenario: Generated help obeys the guard

  • WHEN The scaffold writes the help for a command.
  • THEN The help text has at most three sentences and contains the path of its documentation page.

Requirement: Command scaffold prints remaining manual steps

The command scaffold SHALL print a checklist of the manual steps that remain, including devops docs generate --sync-readme.

Scenario: Checklist names the regeneration command

  • WHEN A user runs devops new command sample hello.
  • THEN The output contains devops docs generate --sync-readme and names each manual step that remains.

Requirement: Test scaffold uses the mirror path

devops new test SHALL write the test file at the mirror path of the source module.

Scenario: Mirror path is used

  • WHEN A user runs devops new test src/devops_cli/config/constants.py.
  • THEN The scaffold writes tests/config/test_constants.py.

Requirement: Test scaffold refuses a flat path

devops new test SHALL refuse a path outside src/devops_cli/ and a target that is not the mirror path.

Scenario: Flat test path is refused

  • WHEN A user runs devops new test tests/test_constants.py.
  • THEN The command exits nonzero and names the required mirror path.

Requirement: Test template uses a shared fake and a behaviour name

The generated test SHALL use the shared fake of an edge it reaches and SHALL name the behaviour in docs/TESTING.md terms.

Scenario: Generated test uses the GitHub fake

  • WHEN A user runs devops new test src/devops_cli/github/issues.py.
  • THEN The test asks for the github_api fixture and its function name states the behaviour it checks.

Requirement: Scaffold refuses to overwrite a file

The scaffold SHALL refuse to write when any target file exists and SHALL name the existing path.

Scenario: Existing target is refused

  • WHEN A user runs devops new test src/devops_cli/config/constants.py twice.
  • THEN The second run exits nonzero, names the test path, and leaves the file unchanged.

Requirement: Dry run writes nothing

--dry-run SHALL print every target path and SHALL write no file.

Scenario: Dry run lists target paths

  • WHEN A user runs devops new command sample hello --dry-run.
  • THEN The output lists the group module, the lang/en/ file and the test file, and no file changes on disk.

Requirement: MCP exclusion list derives from the command tree

The MCP coverage test SHALL derive the excluded command set from the command tree and CONST_MCP_EXPOSURE_TABLE, and SHALL fail on an exposure entry that names no command.

Scenario: New command needs no exclusion entry

  • WHEN A new command joins the command tree and no exclusion entry is added.
  • THEN The MCP coverage test passes, and an exposure entry for a missing command fails it.

Requirement: Docs inventory hand-written class derives as a complement

CONST_DOCS_INVENTORY SHALL classify a Markdown file that no other class matches as hand-written without a per-file entry.

Scenario: New hand-written page needs no inventory entry

  • WHEN A new docs/example.md page is added.
  • THEN The docs inventory check passes with no change to CONST_DOCS_INVENTORY.

Requirement: TESTING.md states the mirror rule

docs/TESTING.md SHALL state that a new test file sits at the mirror path of its source module and SHALL remove the flat-file fallback.

Scenario: Layout section states one rule

  • WHEN A reader opens the layout section of docs/TESTING.md.
  • THEN The section names the mirror path and holds no instruction to add a new flat test file.

Requirement: Skill names both scaffold commands

A skill document under .claude/skills/ SHALL name devops new command and devops new test.

Scenario: Skill names both commands

  • WHEN A test reads every SKILL.md under .claude/skills/.
  • THEN At least one skill names devops new command and devops new test.

Existing Tool Considered

No alternatives check has run. Copier and Cookiecutter are open and maintained, and both render local templates offline. They do not edit a Python command module, update lang/en/ entries, derive CONST_MCP_EXPOSURE_TABLE or CONST_DOCS_INVENTORY, or know the project's guard tests. devops ai generate makes a failing test for a function only. Cost to build both commands with built-in templates: about 150k tokens and 8 hours. Keep the templates in step with the rules and the guard tests.

Key questions

  • Which test-location rule does the scaffold encode?: The mirror rule. A new test file sits at the mirror path of its source module. docs/TESTING.md removes the flat-file fallback. (best practice) [sources: docs/TESTING.md, AGENTS.md]
    • Chosen: Mirror path only. The target layout and the stage gate use the mirror; one rule removes the conflict.
    • Rejected: Keep the flat-file fallback. It contradicts the mirror target and lets a new test break the stage gate.
    • Rejected: Mirror for new packages and flat for existing files. Two rules keep the ambiguity that the issue reports.
  • Which template mechanism does the scaffold use?: A built-in template set in src/devops_cli/ renders the files. The scaffold computes every path, refuses an existing file, and writes only after the checks. (best practice) [sources: AGENTS.md, CONTRIBUTING.md]
    • Chosen: Built-in template set. The project has few templates, needs offline runs, and must edit a Python module and lang/en/; Copier and Cookiecutter do not do that.
    • Rejected: Copier. It renders and updates files, but cannot insert a command function or edit the shared lists; its update mode conflicts with no-overwrite.
    • Rejected: Cookiecutter. It renders files only, adds a dependency, and cannot edit the command module or the shared lists.
  • Where does the new command group live?: Top-level devops new, under src/devops_cli/commands/. (best practice) [sources: CONTRIBUTING.md]
    • Chosen: Top-level devops new. The target names it, and it keeps the scaffold beside the other developer commands.
    • Rejected: Under devops dev. No dev group exists, and it adds a level that the issue does not need.
  • How does the MCP coverage test treat a new command?: It derives the excluded set as every command in the command tree minus CONST_MCP_EXPOSURE_TABLE. MCP exposure stays an explicit opt-in table. The test fails on an exposure entry that names no command. (best practice) [sources: tests/ai/mcp/test_mcp.py, src/devops_cli/config/constants.py]
    • Chosen: Derive excluded set, keep exposure table manual. A new command is not exposed by default, so no exclusion entry is needed; the table still names every exposed command.
    • Rejected: Derive exposure table from command tree. The tree does not say which commands are safe or useful over MCP.
    • Rejected: Keep both lists manual. This is the failure that feat(roadmap): the stage job verifies its plan with a model #3182 records.
  • How does the docs inventory treat a new hand-written page?: The hand-written class becomes the complement of every other class. A Markdown file that no other class matches is hand-written without a per-file entry. (best practice) [sources: src/devops_cli/config/constants.py, tests/docs/test_docs_inventory.py]
    • Chosen: Hand-written as complement. A new hand-written page needs no inventory edit, and the check still finds a file that no class matches.
    • Rejected: Keep explicit hand-written paths. A new page under a new path fails the check and needs an edit that the scaffold cannot make.
    • Rejected: Add a catch-all docs/**/*.md to hand-written. It hides a generated or prompt document that a class should own; the complement keeps the classes distinct.
  • What does the command scaffold print when a shared list is derived?: It prints only the manual steps that remain, such as devops docs generate --sync-readme. It prints no step for a derived list. (best practice) [sources: CONTRIBUTING.md, src/devops_cli/config/constants.py]
    • Chosen: Print only remaining manual steps. A derived list needs no scaffold edit, so a checklist entry would send the agent to the wrong place.
    • Rejected: Print the original checklist. It tells the agent to edit a list that the change derives.
    • Rejected: Print no checklist. The agent still must regenerate the docs.
  • Where does the scaffold skill live?: A short skill under .claude/skills/ calls both commands and names no template path. (best practice) [sources: src/devops_cli/config/constants.py]
    • Chosen: Skill under .claude/skills/. The project already keeps skills there, and a short skill calls the commands.
    • Rejected: No skill. The issue asks for the same skill pattern as the change-folder scaffold.
    • Rejected: Separate skills for each command. One skill covers both scaffold commands and keeps the guidance short.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/feature
    scope/cli
    status/new
    value/medium
    effort/high
    on Nov 2, 2026
  2. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/cli. The (cli) scope of the title gives the scope.
    • Priority: P2-Medium. It reduces CI breakage for new commands and tests but does not block current work.
    • Value: Medium. It removes scattered rules from memory and prevents repeated CI failures for agents and developers.
    • Effort: High. The body estimates 150k tokens and 8 hours for both commands, plus template design and shared-list decisions.
    • Related: feat(openspec): scaffold the change folder of an issue to project form #3203, which asks for a different change. Both scaffold an artifact to project form, but #3203 targets the OpenSpec change folder while this candidate targets a CLI command and its test.
  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 2, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at ff9ad06 (see proposed design in issue body).

  5. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch feat/3204-scaffold-a-command-and-a-test, draft pull request #3277. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. State the mirror path as the one test-location rule: 18495 tokens
    2. Classify an unmatched docs page as hand-written: 14150 tokens
    3. Derive the MCP excluded commands from the command tree: 10491 tokens
    4. Add the devops new test subcommand: 28680 tokens
    5. Add the devops new command subcommand and its templates: 19101 tokens
    6. Add the skill that calls both scaffold commands: 10441 tokens

    The plan run made 4 model request(s), and used 306078 input tokens and 36051 output tokens. The model made no tool call.

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • criterion_dropped at specs (new-command-scaffold) and group 5: The issue requires the command scaffold to write the group's docs page entry when that page exists. The plan spec, the tasks and the test of group 5 leave out this entry, and the plan lists no criteria. Evidence: "and the group's docs page entry when that page exists."
  6. added 3 commits that reference this issue on Nov 3, 2026
  7. added
    status/planned
    and removed
    status/ready
    on Nov 3, 2026
  8. added
    owner/agent
    status/in-progress
    and removed
    status/planned
    on Nov 6, 2026
  9. removed
    status/in-progress
    owner/agent
    on Nov 6, 2026
  10. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 00:45 UTC

  11. added a commit that references this issue on Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/highpriority/p2-mediumscope/clitype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions