Tasks in hardhat
Everything you can do in Hardhat is defined as a task. The default actions that come out of the box are built-in tasks and they are implemented using the same APIs that are available to you as a user.
A task is a JavaScript async function with some associated metadata. This metadata is used by Hardhat to automate some things for you. Arguments parsing, validation, and help messages are taken care of.
Some common examples of the tasks that we use daily are the tasks for compile deploy test etc..
We can see the list of all the available tasks using the command npx hardhat

We can also create our own tasks inside the hardhat.config.js file
The basic syntax for creating a task is:
