A fully-tested Microsoft To Do command-line client for managing tasks and lists via Microsoft Graph API.
This skill uses OAuth authorization-code login through Microsoft Graph. The script has built-in fallback Azure app credentials, but agents should prefer caller-provided credentials when available. Treat any committed client secret as public and rotate or revoke it before distributing this skill for sensitive accounts.
Credential precedence:
--client-id, --client-secret, --tenant-idMS_TODO_CLIENT_ID, MS_TODO_CLIENT_SECRET, MS_TODO_TENANT_IDscripts/ms-todo-oauth.pyRecommended handling:
Tasks.ReadWrite; add Tasks.ReadWrite.Shared only if shared-list access is needed.MS_TODO_CLIENT_ID and MS_TODO_CLIENT_SECRET, or pass --client-id and --client-secret before the subcommand.Do not print or paste client secrets in user-facing responses or logs.
requirements.txt: msal and requests~/.mstodo_token_cache.json (persists across sessions, auto-refreshed)Before using this skill for the first time, dependencies must be installed. This repository does not include pyproject.toml or uv.lock, so do not use uv sync unless those files are added later.
# Navigate to skill directory
cd <path-to-ms-todo-oauth>
# Install dependencies into the active Python/Conda environment
python -m pip install -r requirements.txt
# Optional: set your own Azure app credentials for the current PowerShell session
$env:MS_TODO_CLIENT_ID = "<your-client-id>"
$env:MS_TODO_CLIENT_SECRET = "<your-client-secret>"
$env:MS_TODO_TENANT_ID = "consumers"
# Optional uv one-shot without a project file
uv run --with-requirements requirements.txt python scripts/ms-todo-oauth.py --help
Dependencies:
msal (Microsoft Authentication Library) - Official Microsoft OAuth libraryrequests - HTTP client for API callsrequirements.txtAfter installation, verify the setup:
# Check if Python can import dependencies and load the script
python scripts/ms-todo-oauth.py --help
# Expected: Command help text should be displayed
Troubleshooting:
Python not found, install Python 3.9 or higher or activate the environment where dependencies were installed.python -m pip install -r requirements.txt in the same environment used to run the script.Verify all functionality works correctly:
# Run comprehensive automated test suite (33 tests)
python scripts/test_ms_todo_oauth.py
# Run only non-destructive CLI/configuration checks
python scripts/test_ms_todo_oauth.py --preflight-only
# Expected: All tests pass (100% pass rate)
See Testing section for details.
msal library~/.mstodo_token_cache.jsonAll commands follow this pattern:
python scripts/ms-todo-oauth.py [GLOBAL_OPTIONS] <command> [COMMAND_OPTIONS]
| Option | Description |
|---|---|
| ----------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
-v, --verbose | Show detailed information (IDs, dates, notes).Must be placed BEFORE the subcommand. |
--debug | Enable debug mode to display API requests and responses. Useful for troubleshooting.Must be placed BEFORE the subcommand. |
--reauth | Force re-authentication by clearing the token cache and starting fresh login |
--client-id | Azure app client ID. Overrides MS_TODO_CLIENT_ID and the built-in fallback. Must be placed BEFORE the subcommand. |
--client-secret | Azure app client secret. Overrides MS_TODO_CLIENT_SECRET and the built-in fallback. Must be placed BEFORE the subcommand. |
--tenant-id | Azure tenant ID or account type. Defaults to MS_TODO_TENANT_ID or consumers. Must be placed BEFORE the subcommand. |
> ⚠️ Common mistake: Global options MUST come before the subcommand.
>
> - ✅ python scripts/ms-todo-oauth.py -v lists
> - ✅ python scripts/ms-todo-oauth.py --debug add "Task"
> - ✅ python scripts/ms-todo-oauth.py --client-id "
> - ❌ python scripts/ms-todo-oauth.py lists -v
Authentication uses OAuth2 authorization code flow, designed for both interactive and automated environments.
login get — Get OAuth2 authorization URLpython scripts/ms-todo-oauth.py login get
Output example:
======================================================================
🔐 OAuth2 Authorization Required
======================================================================
Please visit the following URL to authorize the application:
https://login.microsoftonline.com/consumers/oauth2/v2.0/authorize?...
After authorization, you will be redirected to a callback URL.
Copy the `code` parameter from the callback URL and run:
python scripts/ms-todo-oauth.py login verify <authorization_code>
======================================================================
What to do:
http://localhost:8000/callback?code=M.R3_BAY.abc123...localhost:8000 cannot be reached, that is expected.code value after code=.Agent behavior: Present the URL to the user and explain they need to:
login verify — Complete login with authorization codepython scripts/ms-todo-oauth.py login verify "<authorization_code_or_callback_url>"
Example:
python scripts/ms-todo-oauth.py login verify "M.R3_BAY.abc123def456..."
python scripts/ms-todo-oauth.py login verify "http://localhost:8000/callback?code=M.R3_BAY.abc123def456..."
Output on success:
✓ Authentication successful!
✓ Login information saved, you will be logged in automatically next time.
Output on failure:
❌ Token acquisition failed
Error: invalid_grant
Description: AADSTS54005: OAuth2 Authorization code was already redeemed...
Exit code: 0 on success, 1 on failure.
Important notes:
login get again to get a new codelogout--reauthlogout — Clear saved loginpython scripts/ms-todo-oauth.py logout
Output: ✓ Login information cleared
Only use when the user explicitly asks to switch accounts or clear login data. Under normal circumstances, the token is cached and login is automatic.
lists — List all task listspython scripts/ms-todo-oauth.py lists
python scripts/ms-todo-oauth.py -v lists # with IDs and creation dates
Output example:
📋 Task Lists (3 total):
1. 任务
ID: AQMkADAwATYwMAItYTQwZC04OThhLTAwAi0wMAoALgAAA0QJKpxW32BIsIlHaM...
Created: 2024-12-15T08:30:00Z
2. Work
3. Shopping
create-list — Create a new listpython scripts/ms-todo-oauth.py create-list "<name>"
| Argument | Required | Description |
|---|---|---|
| -------- | -------- | ----------------------------------------------- |
name | Yes | Name of the new list (supports Unicode/Chinese) |
Example:
python scripts/ms-todo-oauth.py create-list "项目 A"
Output: ✓ List created: 项目 A
delete-list — Delete a listpython scripts/ms-todo-oauth.py delete-list "<name>" [-y]
| Argument/Option | Required | Description |
|---|---|---|
| --------------- | -------- | -------------------------- |
name | Yes | Name of the list to delete |
-y, --yes | No | Skip confirmation prompt |
> ⚠️ This is a destructive operation. Without -y, the command will prompt for confirmation. All tasks in the list will be deleted. Consider asking the user before deleting important lists.
Output: ✓ List deleted:
Exit code: 1 if list not found, 0 on success
add — Add a new taskpython scripts/ms-todo-oauth.py add "<title>" [options]
| Option | Required | Default | Description |
|---|---|---|---|
| --------------------- | -------- | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
title | Yes | — | Task title (positional argument, supports Unicode/Chinese/emojis) |
-l, --list | No | (default list) | Target list name. If not specified, uses your Microsoft To Do default list. |
-p, --priority | No | normal | Priority:low, normal, high |
-d, --due | No | — | Due date. Accepts days from now (3 or 3d) or date (2026-02-15). Note: Only date is supported by Microsoft To Do API, not time. |
-r, --reminder | No | — | Reminder datetime. Formats:3h (hours from now), 2d (days from now), 2026-02-15 14:30 (date+time with space, needs quotes), 2026-02-15T14:30:00 (ISO format), 2026-02-15 (date only, defaults to 09:00). |
-R, --recurrence | No | — | Recurrence pattern. Formats:daily (every day), weekdays (Mon-Fri), weekly (every week), monthly (every month). With interval: daily:2 (every 2 days), weekly:3 (every 3 weeks), monthly:2 (every 2 months). |
-D, --description | No | — | Task description/notes (supports multiline with quotes) |
-t, --tags | No | — | Comma-separated tags/categories (e.g.,"work,urgent") |
--create-list | No | False | Create the list if it doesn't exist (deprecated, lists auto-create now) |
Auto-created lists: If the specified list doesn't exist, it will be automatically created.
Output example:
✓ Task added: Complete report
With recurrence:
✓ Task added: Daily standup
🔄 Recurring task created
Examples:
# Simple task
python scripts/ms-todo-oauth.py add "Buy milk" -l "Shopping"
# High priority task due in 3 days
python scripts/ms-todo-oauth.py add "Submit report" -l "Work" -p high -d 3
# Task with reminder in 2 hours
python scripts/ms-todo-oauth.py add "Call client" -r 2h
# Task with specific date and time reminder
python scripts/ms-todo-oauth.py add "Meeting" -d 2026-03-15 -r "2026-03-15 14:30"
# Daily recurring task
python scripts/ms-todo-oauth.py add "Daily standup" -l "Work" -R daily
# Weekday recurring task
python scripts/ms-todo-oauth.py add "Gym" -R weekdays -l "Personal"
# Task with all options
python scripts/ms-todo-oauth.py add "Project Review" \
-l "Work" \
-p high \
-d 7 \
-r "2026-02-20 14:00" \
-D "Review Q1 deliverables and prepare presentation" \
-t "work,important,meeting"
# Chinese task with emoji
python scripts/ms-todo-oauth.py add "🎉 完成项目" -l "任务" -p high
complete — Mark a task as completedpython scripts/ms-todo-oauth.py complete "<title>" [-l "<list>"]
| Option | Required | Default | Description |
|---|---|---|---|
| -------------- | -------- | -------------- | -------------------------------- |
title | Yes | — | Exact task title |
-l, --list | No | (default list) | List name where the task resides |
Title matching: Requires exact match. If unsure of exact title, use search first.
Output: ✓ Task completed:
Exit code: 1 if task not found, 0 on success
delete — Delete a taskpython scripts/ms-todo-oauth.py delete "<title>" [-l "<list>"] [-y]
| Option | Required | Default | Description |
|---|---|---|---|
| -------------- | -------- | -------------- | -------------------------------- |
title | Yes | — | Exact task title |
-l, --list | No | (default list) | List name where the task resides |
-y, --yes | No | — | Skip confirmation prompt |
> ⚠️ Destructive operation. Without -y, will prompt for confirmation.
Output: ✓ Task deleted:
Exit code: 1 if task not found, 0 on success
tasks — List tasks in a specific listpython scripts/ms-todo-oauth.py tasks "<list>" [-a]
| Option | Required | Description |
|---|---|---|
| ------------- | -------- | -------------------------------------------------- |
list | Yes | List name (exact match) |
-a, --all | No | Include completed tasks (default: incomplete only) |
Output example:
📋 Tasks in list "Work" (2 total):
1. [In Progress] Write documentation ⭐
2. [In Progress] Review PR
With -a flag:
📋 Tasks in list "Work" (3 total):
1. [In Progress] Write documentation ⭐
2. [Completed] Submit report
3. [In Progress] Review PR
Exit code: 1 if list not found, 0 on success
pending — All incomplete tasks across all listspython scripts/ms-todo-oauth.py pending [-g]
| Option | Required | Description |
|---|---|---|
| --------------- | -------- | --------------------- |
-g, --group | No | Group results by list |
Output example (with -g):
📋 All incomplete tasks (3 total):
📂 Work:
[In Progress] Write documentation ⭐
[In Progress] Review PR
📂 Shopping:
[In Progress] Buy groceries
Without -g:
📋 All incomplete tasks (3 total):
[In Progress] Write documentation ⭐
List: Work
[In Progress] Review PR
List: Work
[In Progress] Buy groceries
List: Shopping
today — Tasks due todaypython scripts/ms-todo-oauth.py today
Lists incomplete tasks with due date matching today's date.
Output example:
📅 Tasks due today (2 total):
[In Progress] Submit report ⭐
List: Work
[In Progress] Buy groceries
List: Shopping
If no tasks: 📅 No tasks due today
overdue — Overdue taskspython scripts/ms-todo-oauth.py overdue
Lists incomplete tasks past their due date, sorted by days overdue.
Output example:
⚠️ Overdue tasks (1 total):
[In Progress] Submit report ⭐
List: Work
Overdue: 3 days
If no overdue tasks: ✓ No overdue tasks
detail — View full task detailspython scripts/ms-todo-oauth.py detail "<title>" [-l "<list>"]
| Option | Required | Default | Description |
|---|---|---|---|
| -------------- | -------- | -------------- | -------------------------------------------------- |
title | Yes | — | Task title (supportspartial/fuzzy match) |
-l, --list | No | (default list) | List name |
Fuzzy matching: Matches tasks containing the search string (case-insensitive).
When multiple tasks match:
Output example:
============================================================
📌 Task Details
============================================================
📋 Title: Complete Q1 Report
🔖 Status: [In Progress]
⚡ Priority: ⭐ High
📅 Created: 2026-01-15 08:30:00
📝 Modified: 2026-02-10 14:22:00
⏰ Due: 2026-02-20 00:00:00
🔔 Reminder: 2026-02-20 09:00:00
📝 Notes:
- Review sales figures
- Include charts
- Prepare for board meeting
🏷️ Categories: work, important, Q1
🔄 Recurrence:
Every week on Monday
Start date: 2026-02-17
No end date
============================================================
search — Search tasks by keywordpython scripts/ms-todo-oauth.py search "<keyword>"
Searches across all lists in both task titles and descriptions (case-insensitive).
Output example:
🔍 Search results for "report" (2 found):
[In Progress] Complete Q1 Report ⭐
List: Work
Notes: Review sales figures...
[Completed] Submit weekly report
List: Work
stats — Task statisticspython scripts/ms-todo-oauth.py stats
Shows aggregate statistics across all lists.
Output example:
📊 Task Statistics:
Total lists: 3
Total tasks: 15
Completed: 10
Pending: 5
High priority: 2
Overdue: 1
Completion rate: 66.7%
export — Export all tasks to JSONpython scripts/ms-todo-oauth.py export [-o "<filename>"]
| Option | Required | Default | Description |
|---|---|---|---|
| ---------------- | -------- | -------------------- | ---------------- |
-o, --output | No | todo_export.json | Output file path |
Exports complete task data from all lists in JSON format.
Output: ✓ Tasks exported to:
JSON structure:
{
"Work": [
{
"id": "AQMkADAwATYwMAItYTQw...",
"title": "Complete report",
"status": "notStarted",
"importance": "high",
"createdDateTime": "2026-01-15T08:30:00Z",
"dueDateTime": {
"dateTime": "2026-02-20T00:00:00.0000000",
"timeZone": "UTC"
},
"body": {
"content": "Review Q1 numbers",
"contentType": "text"
},
"categories": ["work", "important"]
}
],
"Shopping": [...]
}
| Code | Meaning |
|---|---|
| ----- | ------------------------------------------------------------------------- |
0 | Success |
1 | Failure (not logged in, API error, invalid arguments, resource not found) |
2 | Invalid command-line arguments |
| Error | Cause | Resolution |
|---|---|---|
| ----------------------------------------------- | --------------------------------- | --------------------------------------------------------------------------- |
❌ Not logged in | No cached token or token expired | Run login get then login verify |
ModuleNotFoundError: No module named 'msal' | Dependencies not installed | Run python -m pip install -r requirements.txt or pip install -r requirements.txt |
❌ List not found: | Specified list does not exist | Check list name with lists command. Note: exact match required. |
❌ Task not found: | No task with exact matching title | Use search to find exact title, or tasks " to list all tasks |
❌ Error: Invalid isoformat string | DateTime parsing error | This should not occur in the current unreleased maintenance state. If you see this, report as bug. |
❌ Error: Unsupported HTTP method | Internal API error | This should not occur in the current unreleased maintenance state. If you see this, report as bug. |
❌ Error: | Microsoft Graph API error | Retry; check network; use --debug for full details |
Network error / Connection timeout | No internet or API unreachable | Check network connection; verify access to graph.microsoft.com |
This skill includes a comprehensive test suite to ensure reliability.
Run the full test suite:
cd <skill-directory>
python scripts/test_ms_todo_oauth.py
Run only non-destructive CLI/configuration checks:
python scripts/test_ms_todo_oauth.py --preflight-only
Prerequisites:
Test Coverage (33 tests):
Expected output:
========================================================================
TEST SUMMARY
========================================================================
Total tests: 33
Passed: 29
Failed: 0
Pass rate: 100.0%
========================================================================
🎉 ALL TESTS PASSED! 🎉
========================================================================
For manual verification, see MANUAL_TEST_CHECKLIST.txt which provides:
The automated test suite:
🧪 Test List 14:23:45)If tests are interrupted, you may need to manually delete leftover test lists.
cd to the directory containing this SKILL.md before running commands.python -m pip install -r requirements.txt to ensure all dependencies are installed.```bash
python scripts/ms-todo-oauth.py lists
```
If this returns "Not logged in" error (exit code 1), initiate the login flow.
lists to see available task listsdelete and delete-list:-y flag ONLY when:-y-v, --debug, --reauth, --client-id, --client-secret, and --tenant-id must come BEFORE the subcommand:python scripts/ms-todo-oauth.py -v listspython scripts/ms-todo-oauth.py --client-id "" --client-secret "" lists python scripts/ms-todo-oauth.py lists -vlogin verify until user confirms they've completed browser authenticationlogin get again for a new code--debug flag when troubleshooting API issuesStep 1: Setup and Authentication Check
---------------------------------------
cd <skill_directory>
python -m pip install -r requirements.txt # Ensure dependencies (first time only)
python scripts/ms-todo-oauth.py lists # Test auth & see available lists
If exit code is 1 and output contains "Not logged in":
a. python scripts/ms-todo-oauth.py login get
b. Present URL to user
c. Explain: "Visit this URL, login, and copy the 'code' parameter from callback URL"
d. Wait for user to provide authorization code
e. python scripts/ms-todo-oauth.py login verify "<code>"
f. Verify success (exit code 0)
Step 2: Task Analysis and List Selection
-----------------------------------------
When user requests to add task(s):
a. Analyze task context from user's description
b. Review available lists (from Step 1 output)
c. Choose appropriate list or use default:
- Work-related → "Work"
- Personal errands → "Personal" or default
- Shopping items → "Shopping"
- Project-specific → "<ProjectName>"
d. If list doesn't exist, it will be auto-created
Step 3: Execute Operation
--------------------------
Add task with appropriate options:
python scripts/ms-todo-oauth.py add "Task Title" \
-l "Work" \
-p high \
-d 3 \
-r 2h \
-D "Detailed description" \
-t "tag1,tag2"
Step 4: Verify and Report
--------------------------
Check exit code:
- 0: Success → Confirm to user
- 1: Failure → Parse error, provide guidance
- 2: Invalid args → Fix command syntax
Optionally verify:
python scripts/ms-todo-oauth.py tasks "<list>" # Show updated list
complete, delete commandsdetail, search commandssearch first to find exact title, then use it in subsequent commandsExample workflow:
# Find task with fuzzy search
python scripts/ms-todo-oauth.py search "report"
# Output shows: "Complete Q1 Report"
# Use exact title from search results
python scripts/ms-todo-oauth.py complete "Complete Q1 Report" -l "Work"
-l is not specified, operations use the Microsoft To Do default list-l "" User request: "Add these tasks: buy milk, finish report, call dentist"
Agent approach:
# First check available lists
python scripts/ms-todo-oauth.py lists
# Categorize intelligently:
python scripts/ms-todo-oauth.py add "Buy milk" -l "Shopping"
python scripts/ms-todo-oauth.py add "Finish report" -l "Work" -p high -d 2
python scripts/ms-todo-oauth.py add "Call dentist" -l "Personal"
# Or use default list if no specific context: add "Call dentist"
Daily task review:
python scripts/ms-todo-oauth.py today # Check today's tasks
python scripts/ms-todo-oauth.py overdue # Check overdue tasks
python scripts/ms-todo-oauth.py -v pending -g # Review all pending, grouped
Adding various task types:
# Simple task (default list)
python scripts/ms-todo-oauth.py add "Buy milk"
# Work task with priority and deadline
python scripts/ms-todo-oauth.py add "Quarterly review" -l "Work" -p high -d 7
# Task with reminder
python scripts/ms-todo-oauth.py add "Call client" -r 3h
# Detailed task with all options
python scripts/ms-todo-oauth.py add "Project meeting" \
-l "Work" \
-p high \
-d 2026-03-15 \
-r "2026-03-15 14:30" \
-D "Discuss Q1 goals and resource allocation" \
-t "meeting,important,Q1"
# Recurring tasks
python scripts/ms-todo-oauth.py add "Daily standup" -R daily -l "Work"
python scripts/ms-todo-oauth.py add "Weekly review" -R weekly -d 7
python scripts/ms-todo-oauth.py add "Gym" -R weekdays -l "Personal"
python scripts/ms-todo-oauth.py add "Monthly report" -R monthly -p high
Task completion workflow:
# Search for task
python scripts/ms-todo-oauth.py search "report"
# Complete using exact title from search results
python scripts/ms-todo-oauth.py complete "Quarterly review" -l "Work"
Data management:
# Export for backup
python scripts/ms-todo-oauth.py export -o "backup_$(date +%Y%m%d).json"
# View statistics
python scripts/ms-todo-oauth.py stats
login verify input so URL-encoded codes and full callback URLs work--preflight-only mode for safe local verification without live To Do changesrequirements.txt-only package layoutuv sync guidance with active Python/Conda installation commandsstart_date parameter in create_task()complete_task() methodProblem: ❌ Not logged in
login get, complete browser flow, then login verify Problem: ❌ Token acquisition failed: invalid_grant
login get again to get a fresh codeProblem: Login worked but now getting "Not logged in" again
--reauth to force fresh login:```bash
python scripts/ms-todo-oauth.py --reauth lists
```
Problem: ModuleNotFoundError: No module named 'msal'
python -m pip install -r requirements.txt or pip install -r requirements.txtProblem: uv: command not found
pip install uvProblem: Connection timeout or network errors
--debug flag to see full API request/responseProblem: Unexpected API errors
python scripts/ms-todo-oauth.py --reauth listspython scripts/ms-todo-oauth.py --debug Problem: ❌ Task not found:
search to find exact titlecomplete and delete require exact title matchProblem: ❌ List not found:
lists to see exact list namesProblem: Tests failing with datetime errors
_parse_ms_datetime() helper function existsProblem: Tests failing with "Not logged in"
```bash
python scripts/ms-todo-oauth.py login get
# Complete browser flow
python scripts/ms-todo-oauth.py login verify "
# Then run tests
python scripts/test_ms_todo_oauth.py
```
scripts/test_ms_todo_oauth.py - Automated testsscripts/MANUAL_TEST_CHECKLIST.txt - Step-by-step testing guidescripts/QUICK_REFERENCE.txt - Command cheat sheetReporting Issues:
--debug flag if applicablepython3 --versionTesting New Features:
scripts/test_ms_todo_oauth.py for new featuresMANUAL_TEST_CHECKLIST.txt with manual test proceduresMIT License - See LICENSE file for details
Version: 1.0.5
Last Updated: 2026-02-13
Status: ✅ Fully Tested & Production Ready
共 2 个版本