Create a new Python invoke task for the dda CLI
Create a new invoke task accessible via dda inv <namespace>.<task-name>.
Use AskUserQuestion to collect the following. If $ARGUMENTS provides values, skip those questions.
Task name: The function name (e.g. build, refresh_assets). Underscores become hyphens in the CLI.
Namespace: Which task module does it belong to?
tasks/ (e.g. agent, linter, dogstatsd). Check tasks/__init__.py for the full list.tasks/<name>.py file and register it.What does the task do?: Brief description (becomes the docstring / help text).
Parameters: What CLI flags does the task need? (name, type, default value, description)
Read an existing task file matching the desired complexity:
tasks/auth.pytasks/agent.py or tasks/linter.pytasks/__init__.py — to see how modules and tasks are registeredAdd the @task decorated function to the appropriate file. Follow the patterns from Step 2.
Key rules:
ctx (the invoke Context)ctx.run("command") to execute shell commandsdda inv --listinvoke: task, Exit (for errors), ContextIf you created a new module file, edit tasks/__init__.py:
from tasks import (...) block (alphabetical order)ns.add_collection(<module>) — creates dda inv <module>.<task>ns.add_task(<task>) — creates dda inv <task>If adding to an existing module, no registration is needed — invoke auto-discovers @task functions.
Test the task:
dda inv <namespace>.<task-name> --help
/create-invoke-task — Interactive: prompts for all details/create-invoke-task agent my-task — Pre-fills namespace and name