requirements.cli.skill_structure.refactor
Requirements index · View definition
Requirement
Under
, the
habeas-refactorskill MUST be the home of moving code, tests, and requirements to another file, chapter, or outline node, and of renaming requirements.
Rationale
The habeas-refactor skill states the topics in full, and no other skill restates them. A test checks both points.
Obligation 1: habeas-refactor is the home of moving code, tests, and requirements to another file, chapter, or outline node.
assets/skills/habeas-refactor/SKILL.mdgives the full workflow in its## Workflowsection.- Step 1 covers moving a file, moving a function, and moving the
{req}directive to a new chapter. - Step 2 records the move in the Git index.
- Step 3 gives the
--mapforms for a file or directory, a node, and a definition. - Steps 4 to 8 cover reviewing the report, running the command, checking status, committing, and reassessing what remains.
- Step 1 covers moving a file, moving a function, and moving the
- The
## Gotchassection adds that a rename is not a move, and that moved code or text must not be edited in the same step.
Obligation 2: it is the home of renaming requirements.
- The Gotchas state “Renaming a requirement’s ID is a definition mapping, and works when its text is otherwise unchanged.”
- Step 3 gives the example
--map requirements.cli.check=requirements.core.check.
Obligation 3 (from the cited skill_structure): each topic is stated in full in exactly one skill.
- I searched the other skills for
habeas refactor,--map, and move, rename, or split wording. - The other skills only route to
habeas-refactor. Examples are the task table inassets/skills/habeas/SKILL.md, the Fixing findings table and the Gotchas inassets/skills/habeas-evidence/SKILL.md, and the closing paragraph ofassets/skills/habeas-requirements/SKILL.md. - The
habeas-requirementsreview prompt says never to rename or move a committed requirement, and only raises it as a design question. That is not a full statement of the topic.
Test. tests/authoring_cli.rs#fn[the_refactor_skill_is_home_of_moves_and_requirement_renames] carries {test} for the subject.
- It asserts that the
## Workflowsection contains the phrases for moving the{req}directive and for the file, node, and definition--mapforms. - It asserts the rename phrase “Renaming a requirement’s ID is a definition mapping”.
- It calls
assert_home("habeas-refactor"). That checks that the refactor skill contains its home markers (habeas refactor --dry-run, the node--mapform, and the “Would leave … unchanged” sentence) and that no other skill’sSKILL.mdorreferences/text contains them.
No gaps found.
Inputs
Implementation
Input 4: outline assets/skills/habeas-refactor/SKILL.md (whole file)
- File:
assets/skills/habeas-refactor/SKILL.md - Selector:
(root) - Kind:
file assets/skills/habeas-refactor/SKILL.md:1–71
---
name: habeas-refactor
description: Use when a change moves code, tests, or requirements in a Habeas project to another file, chapter, or outline node, such as moving a function to another module, renaming or splitting a file, splitting or merging modules or chapters, or moving or renaming a requirement, so that evidence whose content is unchanged is not invalidated. Covers making the move and running `habeas refactor` to update evidence, references, and anchors. Not for changing what code or requirements say; use habeas-requirements.
---
# Habeas refactor
Evidence records where it read code and requirements: files, outline selectors
such as `fn[load]`, and full definition names. A move changes those addresses
without changing what was reviewed. `habeas refactor` rewrites the addresses,
so the evidence stays current without a model reassessing it.
## Workflow
Run commands from the project root, the directory with `book.toml` and
`Cargo.toml`.
- [ ] 1. Make the move with your own edits: move the file, cut and paste the
function, or move the `{req}` directive to its new chapter. Change
nothing else in this step. Keep the moved code's text, including doc
comments, and the moved requirement's text exactly as they were. Leave
`{impl}`, `{test}`, `{cite}`, `{fixme}`, and `{term}` references to a
moved definition, and `:impl:` and `:test:` anchors to a moved file,
as they are; the command rewrites them.
- [ ] 2. Record the move in the Git index: `git mv` for a moved file, or
`git add -A` on both the old and new paths. Reference discovery reads
only files in the Git index, so a stale old path still counts.
- [ ] 3. `habeas refactor --dry-run` with one `--map <old>=<new>` for every
moved file or directory, node, and definition name:
- a file or directory: `--map src/config.rs=src/settings.rs`, which also
covers every file under a directory;
- a node: `--map 'src/config.rs#fn[load]=src/config/load.rs#fn[load]'`,
which also covers the nodes inside it (quote it for the shell);
- a definition: `--map requirements.cli.check=requirements.core.check`,
which also covers the names beneath it, such as
`requirements.cli.check.case`.
To find a node's selector, `habeas info <name>` lists the inputs of a
requirement that reads it.
- [ ] 4. Review the report:
- "Would rewrite" lists the sources whose references or anchors change;
- "Would change" lists the records it updates, with each code span in
their rationales that still mentions an old path. The command leaves
rationale prose alone; show these spans to the user, and if they ask
for a record to be reassessed, run `habeas author --force <full-name>`
after step 7;
- "Would leave ... unchanged" lists records a mapping affects that fail a
check, with the reason. An unexpected one usually means the moved text
changed, or a mapping is missing; fix that and run the dry run again.
- [ ] 5. Run the same command without `--dry-run`.
- [ ] 6. `habeas status`. Only the records the report left unchanged, and any
that were stale before, should need attention.
- [ ] 7. Commit the move, the rewritten references, and the `evidence/` changes
together, before any change to behavior or text.
- [ ] 8. Next, reassess what remains stale with `habeas author --all`,
following the habeas-evidence skill, and if assessments disagree, its
"Disagreeing assessments"; then make any behavior or text changes as separate commits under
the habeas-requirements skill.
## Gotchas
- Never edit evidence files by hand to follow a move; `habeas refactor` updates
them only where it can check that nothing reviewed changed.
- A rename is not a move. Renaming a function, type, or other item changes its
code, and so its structural hash: its evidence needs reassessment with
habeas-evidence. Renaming a requirement's ID is a definition mapping, and
works when its text is otherwise unchanged.
- Editing moved code or text in the same step leaves every record that read it
stale. Move first, run the command, commit, then edit.
- A requirements input that selects a glob, such as `requirements.cli.*`, stays
stale when a definition moves out of it or into it: what it matches changed.
Tests
Input 3: outline tests/authoring_cli.rs fn[the_refactor_skill_is_home_of_moves_and_requirement_renames]
- File:
tests/authoring_cli.rs - Selector:
fn[the_refactor_skill_is_home_of_moves_and_requirement_renames] - Kind:
fn tests/authoring_cli.rs:3452–3470
// {test}`requirements.cli.skill_structure.refactor`
#[test]
fn the_refactor_skill_is_home_of_moves_and_requirement_renames() {
assert_text(
"habeas-refactor workflow",
§ion(skill_md("habeas-refactor"), "## Workflow"),
&[
"move the `{req}` directive to its new chapter",
"a file or directory: `--map src/config.rs=src/settings.rs`",
"a node: `--map",
"a definition: `--map requirements.cli.check=requirements.core.check`",
],
);
assert_phrases(
"habeas-refactor",
&["Renaming a requirement's ID is a definition mapping"],
);
assert_home("habeas-refactor");
}
Referenced definitions
Input 2: requirements selection requirements.cli.skill_structure
requirements.cli.skill_structure:md/requirements/cli.md:444–451
:::{req} skill_structure
Habeas's bundled agent skills MUST jointly give the direction that the requirements on them specify. A skill consists of its `SKILL.md` and the files under its `references/` directory. Each topic MUST be stated in full in exactly one skill, its home.
:::
Other sources
Input 1: requirements selection requirements.cli.skill_structure.refactor
requirements.cli.skill_structure.refactor:md/requirements/cli.md:488–491
:::{req} skill_structure.refactor
Under {cite}`requirements.cli.skill_structure`, the `habeas-refactor` skill MUST be the home of moving code, tests, and requirements to another file, chapter, or outline node, and of renaming requirements.
:::