Skip to main content
ClaudeWave
ES, Spanish
Slash Command215 estrellas del repoactualizado 4mo ago

new-bt-node

The `new-bt-node` command scaffolds a BehaviorTree node (sync, stateful, condition, or ROS-wrapped action/service/topic variant) into an existing ROS2 package, generating header and implementation files with ports, lifecycle overrides, registration boilerplate, and XML usage examples. Use this when adding a discrete decision or action node to a behavior tree architecture, selecting the node kind based on whether it completes in one tick, requires async state management, checks a condition, or wraps a ROS interface.

Instalar en Claude Code
Copiar
mkdir -p ~/.claude/commands && curl -fsSL https://raw.githubusercontent.com/harunkurtdev/ros2-claude-code-template/HEAD/.claude/commands/new-bt-node.md -o ~/.claude/commands/new-bt-node.md
Después abre una sesión nueva de Claude Code; el slash command carga automáticamente.

new-bt-node.md

Scaffold a behavior-tree node inside an existing package.

Argument handling (`$ARGUMENTS`):
1. `<package>` — existing package under `src/` (required).
2. `<ClassName>` — CamelCase node class (required).
3. `<kind>` — one of:
   * `sync` → `BT::SyncActionNode` (finishes in one tick)
   * `stateful` → `BT::StatefulActionNode` (async; onStart/onRunning/onHalted)
   * `condition` → `BT::ConditionNode`
   * `ros-action` → `BT::RosActionNode<ActionT>`
   * `ros-service` → `BT::RosServiceNode<ServiceT>`
   * `ros-topic-pub` → `BT::RosTopicPubNode<MsgT>`
   * `ros-topic-sub` → `BT::RosTopicSubNode<MsgT>`

For the `ros-*` kinds, also ask for the interface type (e.g.
`btcpp_ros2_interfaces/action/Sleep`). For Nav 2-specific BT nodes, use
`/new-nav2-plugin bt_node` instead.

If anything is missing, ask before scaffolding.

Process:
1. Read the skill `behaviortree_node_creation` and the rules
   `behaviortree_cpp.md` (plain) / `behaviortree_ros2.md` (ros-*). Mirror
   the closest sample (`~/nav2_ws/src/BehaviorTree.CPP/sample_nodes/` or
   `~/nav2_ws/src/BehaviorTree.ROS2/btcpp_ros2_samples/src/`).
2. Create:
   * `include/<package>/<snake_class>.hpp` — the class deriving from the
     chosen base, with `static providedPorts()` (use `providedBasicPorts`
     for ros-* wrappers) and the required overrides:
     - sync/condition: `tick()`
     - stateful: `onStart()`, `onRunning()`, `onHalted()`
     - ros-action: `setGoal()`, `onResultReceived()`, `onFeedback()`,
       `onFailure()`, `onHalt()`
     - ros-service: `setRequest()`, `onResponseReceived()`, `onFailure()`
     - ros-topic-pub/sub: `setMessage()` / message handler
   * `src/<snake_class>.cpp` — implementation (non-blocking ticks!).
3. Registration:
   * plain → `BT_REGISTER_NODES(factory){ factory.registerNodeType<Class>("Name"); }`
   * ros-* → `CreateRosNodePlugin(Class, "Name")` (uses `RosNodeParams`).
   * Or register directly in the executor with `registerNodeType<Class>(...)`.
4. `CMakeLists.txt` / `package.xml`: dep `behaviortree_cpp` (+
   `behaviortree_ros2` and the message package for ros-*); build the
   plugin as a shared lib if registering via plugin.
5. Add an XML usage snippet (`BTCPP_format="4"`) and, where useful, a
   gtest that ticks the node.
6. `pre-commit run --files <touched files>`.
7. Print: files created and the XML tag + how to register it.

Never block inside `tick()`/`onRunning()`; return `RUNNING` and resume on
the next tick. `onFeedback()` must not return `IDLE`.
behaviortree_node_creationSkill

Scaffold a Behavior Tree leaf node — plain BehaviorTree.CPP (SyncActionNode / StatefulActionNode / ConditionNode) or a BehaviorTree.ROS2 wrapper (RosActionNode / RosServiceNode / RosTopicPubNode / RosTopicSubNode) — with ports, factory/plugin registration, and XML v4 usage. Trigger when the user asks to write a behavior-tree node (not Nav 2-specific).

behaviortree-reviewerSubagent

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.

buildSlash Command

Build the colcon workspace (optionally a single package) and report the outcome.

clean-arch-architectSubagent

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.

commandsSkill

Author a new skill under .claude/skills/<name>/SKILL.md with valid frontmatter, following the template conventions, and index it in CLAUDE.md + README.md.

ecs-architectSubagent

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.

extending_claude_configSkill

Author a new asset for this .claude/ template — a rule, skill, slash command, or sub-agent — following the project's conventions and wiring it into the CLAUDE.md / README.md indexes. Trigger when the user wants to add or extend a command, skill, agent, or rule (make the template itself extensible).

gz-buildSkill

Configure and build gz-sim from source using either CMake/Ninja directly or a colcon workspace. Trigger when the user asks to build, recompile, configure, or set up the gz-sim binary tree.