Refactor single commit setup into a generic deployment mechanism for Claude commands, allowing easy addition of new commands. Add todo_add_command template and an option to list installed custom commands with their dates. Generated by Claude Code 2.1.74 model claude-opus-4-6 Co-Authored-By: Mathieu Benoit <mathben@technolibre.ca>
4.4 KiB
4.4 KiB
| name | description | allowed-tools | |||||||
|---|---|---|---|---|---|---|---|---|---|
| todo_add_command | Add a new menu command to script/todo/todo.py with i18n support and optional todo.json entry. |
|
Context
- Current todo.py menu structure: !
grep -n "def prompt_execute" script/todo/todo.py | head -20 - Current todo.json sections: !
python3 -c "import json; d=json.load(open('script/todo/todo.json')); print('\n'.join(d.keys()))" - Current i18n keys count: !
grep -c fr.: script/todo/todo_i18n.py
Architecture Reference
Files to modify
| File | Role |
|---|---|
script/todo/todo.py |
Main CLI — menu methods, business logic |
script/todo/todo_i18n.py |
Translations dict TRANSLATIONS with "fr" and "en" keys |
script/todo/todo.json |
Config-driven entries (optional, for bash_command or makefile_cmd) |
Pattern A — Hardcoded menu entry (interactive logic)
Used when the command needs Python logic (user prompts, conditionals, API calls).
- Add i18n keys in
todo_i18n.pyTRANSLATIONSdict:
"my_feature_description": {
"fr": "Description en français",
"en": "English description",
},
- Add choice in the parent menu method (e.g.
prompt_execute_git):
choices = [
...,
{"prompt_description": t("my_feature_description")},
]
- Add elif branch in the same menu's while loop:
elif status == "N":
self._my_feature()
- Add method to the
TODOclass:
def _my_feature(self):
# Implementation here
pass
Pattern B — Config-driven entry (simple bash command)
Used when the command just runs a bash command or a make target.
-
Add i18n key in
todo_i18n.py(useprompt_description_key). -
Add entry in
todo.jsonunder the appropriate*_from_makefilesection:
{
"prompt_description_key": "my_i18n_key",
"bash_command": "my-command --flag"
}
Or for make targets:
{
"prompt_description_key": "my_i18n_key",
"makefile_cmd": "my_make_target"
}
These are automatically picked up by execute_from_configuration().
Available menu sections
| Menu | Method | JSON key |
|---|---|---|
| Automation | prompt_execute_function |
function |
| Code | prompt_execute_code |
code_from_makefile |
| Config | prompt_execute_config |
— |
| Database | prompt_execute_database |
— |
| Doc | prompt_execute_doc |
— |
| Git | prompt_execute_git |
git_from_makefile |
| GPT code | prompt_execute_gpt_code |
— |
| Network | prompt_execute_network |
— |
| Process | prompt_execute_process |
— |
| Run | prompt_execute_instance |
instance |
| Security | prompt_execute_security |
— |
| Test | prompt_execute_test |
— |
| Update | prompt_execute_update |
update_from_makefile |
Key conventions
- i18n keys:
snake_case, grouped by section with a comment header - Method names:
_private_methodfor actions,prompt_execute_*for submenus - All user-facing strings must use
t("key")— never hardcoded text - Use
self.execute.exec_command_live(cmd, source_erplibre=False)to run bash - Use
input(t("prompt_key")).strip()for user input - Use
click.prompt(help_info)for menu navigation - Menu methods return
Falseon back, useself.fill_help_info(choices)for formatting
Task
Add a new command to the todo.py menu system. The user will describe what they want.
Steps
- Determine the target menu section from the user's description
- Choose Pattern A or B based on complexity:
- Simple bash/make command → Pattern B (todo.json entry)
- Needs user interaction or logic → Pattern A (hardcoded method)
- Add i18n translations in
todo_i18n.py— always both"fr"and"en" - Implement the feature following the appropriate pattern
- Validate syntax:
python3 -m py_compile script/todo/todo.py python3 -m py_compile script/todo/todo_i18n.py python3 -c "import json; json.load(open('script/todo/todo.json'))"
Rules
- Keep menu numbering sequential — update all
elifbranches if inserting - Group i18n keys with a
# Section namecomment - Match existing code style (Black, 79 char lines for Odoo modules)
- Do not break existing menu entries or their numbering
- Test that
fill_help_infoandexecute_from_configurationhandle the new entry
User Request
$ARGUMENTS