An action definition in ROS uses a .action file with three parts separated by '---'. The first part defines the Goal, which is the input data sent to the action server. The second part defines the Result, which is the output data returned when the action finishes. The third part defines Feedback, which is data sent periodically to show progress. After writing these sections, you save the file. Then, ROS build tools generate code to handle these messages. This code is used by action servers and clients to communicate asynchronously. The example shows a factorial calculation with an integer order as goal, the factorial result as output, and progress as feedback. Understanding these parts helps you create custom actions for your robots.