Add Task

Add a new task to the project.

vadimpiven updated 5mo ago
Claude CodeGeneric
View source ↗
Add a new task to the project.

`$ARGUMENTS` contains either a task name (snake_case) or a free-form task brief. If it looks like a brief (contains spaces, is a sentence/description), infer a short `snake_case` task name from it. If it looks like a bare name (no spaces, valid identifier), use it directly and ask the user for the task brief before proceeding.

Reference files:

- Template directory: @tasks/hello_world
- Task list: @tasks/CMakeLists.txt
- clang-tidy wrapper: @scripts/clang-tidy.sh
- Analyst agent: @.claude/agents/requirements-analyst.md
- Project conventions: @CLAUDE.md

## Phase 1 — Scaffold

1. Determine the task name (`$NAME`):
    - If `$ARGUMENTS` is a valid `snake_case` C++ identifier (lowercase letters, digits, underscores; starts with a letter; no spaces): use it as `$NAME` and ask the user for the task brief.
    - Otherwise: treat `$ARGUMENTS` as a task brief, infer a short descriptive `snake_case` name from it, and confirm with the user: "I'll name this task `$NAME` — ok?"
2. Validate: `$NAME` must be a valid C++ identifier in `snake_case`. If invalid, report an error and stop.
3. Check that `tasks/$NAME` does not already exist. If it does, report an error and stop.
4. Copy `tasks/hello_world` to `tasks/$NAME`.
5. In `tasks/$NAME`:
    - Rename `include/hello_world.hpp` → `include/$NAME.hpp`
    - Rename `src/hello_world.cpp` → `src/$NAME.cpp`
    - Rename `tests/hello_world.cpp` → `tests/$NAME.cpp`
    - Replace all occurrences of `hello_world` with `$NAME` in all files (CMakeLists.txt, README.md, .hpp, src .cpp, test .cpp).
6. Add `add_subdirectory($NAME)` to @tasks/CMakeLists.txt (append after existing `add_subdirectory` entries).
7. Write the task brief into `tasks/$NAME/README.md` under a `# $NAME` heading with a `## Brief` section containing the user's original text.
8. Run `clang-format -i` on all new `.hpp` and `.cpp` files.
9. Reconfigure: `make configure` (so CMake picks up the new subdirectory).
10. Build: `cmake --build --preset default --target ${NAME}_tests`
11. Run tests: `ctest --preset default -R ${NAME}_tests --output-on-failure`
12. Lint: `./scripts/clang-tidy.sh tasks/$NAME/src/$NAME.cpp tasks/$NAME/tests/$NAME.cpp`

## Phase 2 — Requirements Analysis

Run the analyst agent in a loop until requirements are clear:

13. Run: `claude --agent requirements-analyst --print "Analyze tasks/$NAME/README.md"`
14. Show the analyst's output to the user.
15. Check the status line at the end of the output:
    - If `STATUS: NEEDS_CLARIFICATION`: present the open questions to the user, collect answers, append the answers to `tasks/$NAME/README.md` under a `## Clarifications` section, and go back to step 13.
    - If `STATUS: CLEAR`: proceed to step 16.
16. Replace the contents of `tasks/$NAME/README.md` with the analyst's final structured output (Summary, Requirements, Edge Cases sections). Remove the Brief and Clarifications sections — they served their purpose.

## Phase 3 — TDD Implementation

17. **Tests first**: Write tests in `tasks/$NAME/tests/$NAME.cpp` based on the finalized README requirements, following the 0/1/many pattern with `TEST_F` fixtures. Write minimal declarations in the header so tests compile. Do NOT implement yet.
18. **Red phase**: Build and confirm all tests fail.
19. **Green phase**: Write the implementation in `tasks/$NAME/src/$NAME.cpp` to make all tests pass.
20. **Verify**: Run `make check` to ensure format, lint, build, and tests all pass.
21. **Review**: Run `make review` to ensure no code quality issues.
22. Commit the new task.

Maintain Add Task?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Add Task on getagentictools](https://getagentictools.com/loops/vadimpiven-add-task?ref=badge)