new-node
Scaffold a Node inside an existing package — standard, lifecycle, or component, in Python or C++.
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/harunkurtdev/ros2-claude-code-template/HEAD/.claude/commands/new-node.md -o ~/.claude/commands/new-node.mdnew-node.md
Add a new ROS 2 node to an existing package.
Argument handling (`$ARGUMENTS`):
1. `<package>` — existing package under `src/` (required).
2. `<node_name>` — `snake_case` for Python files / `CamelCase` for C++ class.
3. `<kind>` — one of `standard`, `lifecycle`, `component`.
4. `<lang>` — `python` or `cpp`.
If anything is missing, ask the user before scaffolding.
Process:
1. Verify the package exists and matches the requested language
(look at the build type in `package.xml`).
2. Read the relevant skill:
* `ros2_node_creation` for `standard`.
* `ros2_lifecycle` for `lifecycle`.
3. Place files following Clean Architecture:
* **Infrastructure** layer hosts the ROS 2 adapter (the actual Node).
* **Application** layer hosts the use-case the node orchestrates.
* **Domain** stays ROS-free.
4. Wire entry points:
* Python: `setup.py` `entry_points={'console_scripts': [...]}` and
`setup.cfg` if needed.
* C++: add the executable / component target to `CMakeLists.txt`
with `rclcpp_components_register_nodes(...)` for component nodes.
5. Add a parameters YAML stub at `config/<node_name>.yaml` and a minimal
launch fragment at `launch/<node_name>.launch.py` that loads it.
6. Add a smoke test (`test/test_<node_name>.py` or
`test/<NodeName>_test.cpp`) that just constructs the node and shuts
it down — guards against import errors.
7. `pre-commit run --files <touched files>`.
8. Print: files created, the launch command to try it
(`ros2 launch <package> <node_name>.launch.py`).
Never just dump a Node subclass into `__main__` — it must follow the
Clean Architecture layout enforced by `.claude/rules/clean_architecture.md`.Use proactively before opening a PR that adds or changes BehaviorTree.CPP nodes or BehaviorTree.ROS2 wrappers (RosActionNode/RosServiceNode/RosTopicPub/SubNode, TreeExecutionServer). Reviews a diff against BT.CPP v4 conventions — node base-class choice, non-blocking ticks, ports/blackboard typing, factory/plugin registration, XML v4, and the ROS 2 wrapper contract. Returns a punch list with file:line anchors, not a rewrite.
Use when a design decision touches Clean Architecture boundaries in a ROS 2 project — which layer a new behaviour belongs to, whether a port belongs in domain or application, whether a new node should be lifecycle-managed, whether to compose nodes or split packages. Returns an architectural recommendation with trade-offs, not implementation.
Use when a design decision touches the gz-sim ECS — where new state should live, which system phase should write it, how to avoid coupling, whether to add a component vs. a member variable, whether a new system should be split or merged with an existing one. Returns an architectural recommendation with trade-offs, not implementation.
Use proactively before opening any gz-sim PR. Reviews a diff against the project's C++17 style, ECS conventions, plugin registration patterns, CMake structure, test placement, Migration.md / Changelog.md expectations, and pre-commit configuration. Returns a punch list, not a rewrite.
Use proactively before opening a PR that adds or changes a ros2_control controller, broadcaster, or hardware component (incl. URDF <ros2_control> bringup). Reviews a diff against ros2_controllers / ros2_control_demos conventions — controller & hardware lifecycle, command/state interface configuration, real-time safety of update()/read()/write(), generate_parameter_library usage, pluginlib registration, chainable-controller correctness, URDF wiring, and tests. Returns a punch list with file:line anchors, not a rewrite.
Use proactively before opening any ROS 2 / Nav 2 PR. Reviews a diff against this template's Clean Architecture, ROS 2 communication, lifecycle, testing, and Nav 2 plugin conventions. Returns a punch list with file:line anchors, not a rewrite.
Use proactively before opening a PR that touches a VDA 5050 connector / fleet bridge. Reviews a diff against VDA 5050 v3.0.0 protocol compliance (topics, QoS, header rules, base/horizon, action state machine, schema validation) and the template's Clean Architecture for the MQTT↔Nav 2 bridge. Returns a punch list with file:line anchors, not a rewrite.
Build the colcon workspace (optionally a single package) and report the outcome.