← 返回
开发者工具 中文

ms-todo-sync

A CLI skill to manage Microsoft To Do tasks via Microsoft Graph API. Supports listing, creating, completing, deleting, searching tasks and lists, viewing overdue/today/pending tasks, and exporting data.
一种通过 Microsoft Graph API 管理 Microsoft To Do 任务的 CLI 技能。支持任务的列出、创建、完成、删除、搜索,列表管理,查看逾期/今日/待办任务,以及数据导出。
xiaoski
开发者工具 clawhub v1.0.2 1 版本 99825.2 Key: 无需
★ 0
Stars
📥 1,713
下载
💾 26
安装
1
版本
#latest

概述

ms-todo-sync

A Microsoft To Do command-line client for managing tasks and lists via Microsoft Graph API.

Prerequisites

  1. Python >= 3.9 must be installed.
  2. uv (Python package manager) must be installed. Install via pip install uv or see https://docs.astral.sh/uv/.
  3. Working directory: All commands MUST be run from the root of this skill (the directory containing this SKILL.md file).
  4. Network access: Requires internet access to Microsoft Graph API endpoints.
  5. Authentication: First-time use requires interactive login via browser. See Authentication section.
    • Token cache: ~/.mstodo_token_cache.json (persists across sessions, auto-refreshed)
    • Device flow cache: ~/.mstodo_device_flow.json (temporary)

Installation & Setup

First-Time Setup

Before using this skill for the first time, dependencies must be installed:

# Navigate to skill directory
cd <path-to-ms-todo-sync>

# Install dependencies using uv (recommended - creates isolated environment)
uv sync

# Alternative: Install dependencies with pip (uses global/active Python environment)
pip install -r requirements.txt

Dependencies:

  • Requires msal (Microsoft Authentication Library) and requests
  • Specified in requirements.txt
  • uv creates an isolated virtual environment to avoid conflicts

Environment Verification

After installation, verify the setup:

# Check if uv can find the script
uv run scripts/ms-todo-sync.py --help

# Expected: Command help text should be displayed

Troubleshooting:

  • If uv: command not found, install uv: pip install uv
  • If Python not found, install Python 3.9 or higher from https://python.org
  • If script fails with import errors, ensure dependencies are installed: uv sync or pip install -r requirements.txt

Security Notes

  • Uses official Microsoft Graph API via Microsoft's msal library
  • All code is plain Python (.py files), readable and auditable
  • Tokens stored locally in ~/.mstodo_token_cache.json
  • All API calls go directly to Microsoft endpoints

Command Reference

All commands follow this pattern:

uv run scripts/ms-todo-sync.py [GLOBAL_OPTIONS] <command> [COMMAND_OPTIONS]

Global 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. |

> ⚠️ Common mistake: Global options MUST come before the subcommand.

> - ✅ uv run scripts/ms-todo-sync.py -v lists

> - ✅ uv run scripts/ms-todo-sync.py --debug add "Task"

> - ❌ uv run scripts/ms-todo-sync.py lists -v


Authentication

Authentication uses a two-step device code flow designed for non-interactive/agent environments.

login get — Get verification code

uv run scripts/ms-todo-sync.py login get

Output example:

✓ Verification code generated

Please visit the following link to log in:
https://microsoft.com/devicelogin

Enter verification code: ABC123XYZ

Verify with command: ms-todo-sync.py login verify

Agent behavior: Present the URL and verification code to the user. Wait for the user to confirm they have completed the browser login before proceeding.

login verify — Complete login

uv run scripts/ms-todo-sync.py login verify

Output on success:

✓ Authentication successful! Login information saved, you will be logged in automatically next time.

Output on failure:

✗ Authentication failed: <error description>

> ⚠️ This command blocks until Microsoft's server confirms the user completed browser authentication. Do NOT run this until the user confirms they have completed the browser step.

Exit code: 0 on success, 1 on failure.

logout — Clear saved login

uv run scripts/ms-todo-sync.py logout

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.


List Management

lists — List all task lists

uv run scripts/ms-todo-sync.py lists
uv run scripts/ms-todo-sync.py -v lists  # with IDs and dates

Output example:

📋 Task Lists (3 total):

1. Tasks
2. Work
3. Shopping

create-list — Create a new list

uv run scripts/ms-todo-sync.py create-list "<name>"

| Argument | Required | Description |

|----------|----------|-------------|

| name | Yes | Name of the new list |

Output: ✓ List created:

delete-list — Delete a list

uv run scripts/ms-todo-sync.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. Consider asking the user before deleting important lists.

Output: ✓ List deleted:


Task Operations

add — Add a new task

uv run scripts/ms-todo-sync.py add "<title>" [options]

| Option | Required | Default | Description |

|--------|----------|---------|-------------|

| title | Yes | — | Task title (positional argument) |

| -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, not time. |

| -r, --reminder | No | — | Reminder datetime. Formats: 3h (hours), 2d (days), 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). Note: Automatically sets start date. |

| -D, --description | No | — | Task description/notes |

| -t, --tags | No | — | Comma-separated tags (e.g., "work,urgent") |

Behavior: If the specified list doesn't exist, it will be automatically created.

Output example:

✓ List created: Work
✓ Task added: Complete report

complete — Mark a task as completed

uv run scripts/ms-todo-sync.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. If not specified, uses your default list. |

Output: ✓ Task completed: </code> </p><h4><code>delete</code> — Delete a task </h4><pre><code>uv run scripts/ms-todo-sync.py delete "<title>" [-l "<list>"] [-y] </code></pre><p>| Option | Required | Default | Description | </p><p>|--------|----------|---------|-------------| </p><p>| <code>title</code> | Yes | — | Exact task title | </p><p>| <code>-l, --list</code> | No | (default list) | List name. If not specified, uses your default list. | </p><p>| <code>-y, --yes</code> | No | — | Skip confirmation prompt | </p><p>> ⚠️ <strong>This is a destructive operation</strong>. Without <code>-y</code>, the command will prompt for confirmation. For routine cleanup or when user intent is clear, <code>-y</code> can be used to avoid blocking. </p><p>Output: <code>✓ Task deleted: <title></code> </p><hr><h3>Task Views </h3><h4><code>tasks</code> — List tasks in a specific list </h4><pre><code>uv run scripts/ms-todo-sync.py tasks "<list>" [-a] </code></pre><p>| Option | Required | Default | Description | </p><p>|--------|----------|---------|-------------| </p><p>| <code>list</code> | Yes | — | List name (positional argument) | </p><p>| <code>-a, --all</code> | No | — | Include completed tasks (default: only incomplete) | </p><p><strong>Output example:</strong> </p><pre><code>📋 Tasks in list "Work" (2 total): 1. [In Progress] Write documentation ⭐ 2. [In Progress] Review PR </code></pre><h4><code>pending</code> — All incomplete tasks across all lists </h4><pre><code>uv run scripts/ms-todo-sync.py pending [-g] </code></pre><p>| Option | Required | Description | </p><p>|--------|----------|-------------| </p><p>| <code>-g, --group</code> | No | Group results by list | </p><p><strong>Output example (with <code>-g</code>):</strong> </p><pre><code>📋 All incomplete tasks (3 total): 📂 Work: [In Progress] Write documentation ⭐ [In Progress] Review PR 📂 Shopping: [In Progress] Buy groceries </code></pre><h4><code>today</code> — Tasks due today </h4><pre><code>uv run scripts/ms-todo-sync.py today </code></pre><p>Lists incomplete tasks with due date matching today. Output: <code>📅 No tasks due today</code> if none found. </p><h4><code>overdue</code> — Overdue tasks </h4><pre><code>uv run scripts/ms-todo-sync.py overdue </code></pre><p><strong>Output example:</strong> </p><pre><code>⚠️ Overdue tasks (1 total): [In Progress] Submit report ⭐ List: Work Overdue: 3 days </code></pre><h4><code>detail</code> — View full task details </h4><pre><code>uv run scripts/ms-todo-sync.py detail "<title>" [-l "<list>"] </code></pre><p>| Option | Required | Default | Description | </p><p>|--------|----------|---------|-------------| </p><p>| <code>title</code> | Yes | — | Task title (supports <strong>partial/fuzzy match</strong>) | </p><p>| <code>-l, --list</code> | No | (default list) | List name. If not specified, uses your default list. | </p><p>When multiple tasks match, returns the most recently modified <strong>incomplete</strong> task. If all matches are completed, returns the most recently modified completed task. </p><h4><code>search</code> — Search tasks by keyword </h4><pre><code>uv run scripts/ms-todo-sync.py search "<keyword>" </code></pre><p>Searches across all lists in both task titles and notes (case-insensitive). </p><p><strong>Output example:</strong> </p><pre><code>🔍 Search results (1 found): [In Progress] Write documentation ⭐ List: Work </code></pre><h4><code>stats</code> — Task statistics </h4><pre><code>uv run scripts/ms-todo-sync.py stats </code></pre><p><strong>Output example:</strong> </p><pre><code>📊 Task Statistics: Total lists: 3 Total tasks: 15 Completed: 10 Pending: 5 High priority: 2 Overdue: 1 Completion rate: 66.7% </code></pre><h4><code>export</code> — Export all tasks to JSON </h4><pre><code>uv run scripts/ms-todo-sync.py export [-o "<filename>"] </code></pre><p>| Option | Required | Default | Description | </p><p>|--------|----------|---------|-------------| </p><p>| <code>-o, --output</code> | No | <code>todo_export.json</code> | Output file path | </p><p>Output: <code>✓ Tasks exported to: <filename></code> </p><hr><h2>Error Handling </h2><h3>Exit Codes </h3><p>| Code | Meaning | </p><p>|------|---------| </p><p>| <code>0</code> | Success | </p><p>| <code>1</code> | Failure (not logged in, API error, invalid arguments, etc.) | </p><h3>Common Error Messages </h3><p>| Error | Cause | Resolution | </p><p>|-------|-------|------------| </p><p>| <code>❌ Not logged in</code> | No cached token or token expired | Run <code>login get</code> then <code>login verify</code> | </p><p>| <code>ModuleNotFoundError: No module named 'msal'</code> | Dependencies not installed | Run <code>uv sync</code> or <code>pip install -r requirements.txt</code> | </p><p>| <code>❌ List not found: <name></code> | Specified list does not exist | Check list name with <code>lists</code> command | </p><p>| <code>❌ Task not found: <name></code> | No task with exact matching title | Check task title with <code>tasks</code> or <code>search</code> | </p><p>| <code>❌ Error: <message></code> | API or network error | Retry; check network; use <code>--debug</code> for details | </p><hr><h2>Agent Usage Guidelines </h2><h3>Critical Rules </h3><ol><li><strong>Working directory</strong>: Always <code>cd</code> to the directory containing this SKILL.md before running commands. </li><li><strong>Dependency installation</strong>: Before first use or when encountering import errors, run <code>uv sync</code> to ensure all dependencies are installed. </li><li><strong>Task list organization</strong>: When adding tasks: </li><ul><li>First, run <code>lists</code> to see available task lists </li><li>If user doesn't specify a list, tasks will be added to their <strong>default list</strong> (wellknownListName: "defaultList") </li><li>Intelligently categorize tasks into appropriate lists (e.g., "Work", "Personal", "Shopping") </li><li>If user mentions a context (work, home, shopping, etc.), use or create an appropriate list </li><li>Lists will be auto-created if they don't exist, so feel free to use meaningful list names </li></ul><li><strong>Destructive operations</strong>: For <code>delete</code> and <code>delete-list</code> commands: </li><ul><li>These commands will prompt for confirmation by default (blocking behavior) </li><li>Use <code>-y</code> flag to skip confirmation ONLY when: </li><li>User has explicitly requested to delete without confirmation </li><li>The deletion intent is unambiguous and confirmed through conversation </li><li>When in doubt, ask the user for confirmation instead of using <code>-y</code> </li></ul><li><strong>Global option placement</strong>: <code>-v</code> and <code>--debug</code> must come BEFORE the subcommand, not after. </li><li><strong>Do not retry <code>login verify</code> automatically</strong>: This command blocks waiting for user browser interaction. Only call it after the user confirms completion. </li><li><strong>Check login status first</strong>: Before performing any task operations, run a lightweight command (e.g., <code>lists</code>) to verify authentication. Handle the "Not logged in" error gracefully. </li></ol><h3>Recommended Workflow for Agents </h3><pre><code>1. cd <skill_directory> 2. uv sync # Ensure dependencies are installed (first time or after updates) 3. uv run scripts/ms-todo-sync.py lists # Test auth & see available lists → If fails with exit code 1 ("Not logged in"): a. uv run scripts/ms-todo-sync.py login get # Get code b. Present URL + code to user c. Wait for user confirmation d. uv run scripts/ms-todo-sync.py login verify 4. When adding tasks: → Analyze task context from user's description → Choose or create appropriate list name: - Work-related → "Work" list - Personal errands → "Personal" list - Shopping items → "Shopping" list - Project-specific → Use project name as list → Add task with appropriate list via `-l` option 5. Verify results (e.g., list tasks after adding) </code></pre><p><strong>Example task categorization:</strong> </p><ul><li>\"Buy milk\" → Shopping list (or default list if no context) </li><li>\"Prepare report for meeting\" → Work list </li><li>\"Call dentist\" → Personal list (or default list) </li><li>\"Review PR for auth service\" → Work or project-specific list </li></ul><p><strong>Note:</strong> If no list is specified, tasks are added to the user's default Microsoft To Do list. </p><h3>Task Title Matching </h3><ul><li><code>complete</code> and <code>delete</code> require <strong>exact title match</strong>. </li><li><code>detail</code> and <code>search</code> support <strong>partial/fuzzy keyword match</strong> (case-insensitive). </li><li>When in doubt, use <code>search</code> first to find the exact title, then use it in subsequent commands. </li></ul><h3>Default List Behavior </h3><p>When <code>-l</code> is not specified, the tool uses your Microsoft To Do default list (typically "Tasks"). To target a specific list, provide the <code>-l</code> option. </p><hr><h2>Quick Examples </h2><pre><code># Check existing lists first uv run scripts/ms-todo-sync.py lists # Add task to specific list (list auto-created if needed) uv run scripts/ms-todo-sync.py add "Report" -l "Work" -p high -d 3 -D "Q4 financials" # Add task to default list (no -l option) uv run scripts/ms-todo-sync.py add "Buy milk" # Add task with reminder in 2 hours uv run scripts/ms-todo-sync.py add "Call client" -r 2h # Add task with specific reminder date and time uv run scripts/ms-todo-sync.py add "Meeting" -d 2026-03-15 -r "2026-03-15 14:30" # Add recurring tasks uv run scripts/ms-todo-sync.py add "Daily standup" -l "Work" -R daily -d 7 uv run scripts/ms-todo-sync.py add "Weekly review" -R weekly -d 2026-02-17 uv run scripts/ms-todo-sync.py add "Gym" -R weekdays -l "Personal" uv run scripts/ms-todo-sync.py add "Monthly report" -R monthly -p high -d 30 # Search then complete (use exact title from search results) uv run scripts/ms-todo-sync.py search "report" uv run scripts/ms-todo-sync.py complete "Report" -l "Work" # Delete (use -y only when user intent is clear) uv run scripts/ms-todo-sync.py delete "Old task" -y # Views uv run scripts/ms-todo-sync.py -v pending -g # all pending, grouped uv run scripts/ms-todo-sync.py -v detail "report" # task detail with fuzzy match uv run scripts/ms-todo-sync.py export -o "backup.json" # export all </code></pre></div> </div> </div> <div id="tab-versions" class="detail-content"> <div class="detail-section"> <h2>版本历史</h2> <p style="margin-bottom:12px;font-size:14px;color:#94a3b8;">共 1 个版本</p> <ul class="version-list"> <li> <div> <span class="version-tag">v1.0.2</span> <span style="font-size:11px;color:#5b6abf;margin-left:8px;background:#eef0ff;padding:1px 8px;border-radius:10px;">当前</span> </div> <div style="font-size:12px;color:#94a3b8;"> 2026-03-28 21:32 安全 安全 </div> </li> </ul> </div> </div> <div id="tab-security" class="detail-content"> <div class="detail-section"> <h2>安全检测</h2> <div class="sec-grid"> <div class="sec-card"> <h4>腾讯云安全 (Keen)</h4> <div class="sec-status sec-safe"> 安全,无风险 </div> <a href="https://tix.qq.com/search/skill?keyword=c6b65ae3430d35dd766a352fc4e12ecb" target="_blank">查看报告</a> </div> <div class="sec-card"> <h4>腾讯云安全 (Sanbu)</h4> <div class="sec-status sec-safe"> 安全,无风险 </div> <a href="https://static.cloudsec.tencent.com/html-report-v2/2026/05/25/394102_ced1294c7b4e77882b920b5682a1f5e5.html?q-sign-algorithm=sha1&q-ak=AKID8JMG1bzBC1dz96qNhssfFftujT1NCoFi&q-sign-time=1781384500%3B1812920500&q-key-time=1781384500%3B1812920500&q-header-list=host&q-url-param-list=&q-signature=6ed2318255ae30e5d9ef830cf338f57a6e212a07" target="_blank">查看报告</a> </div> </div> </div> </div> <!-- Recommended Skills --> <div style="margin-top:24px;"> <h2 style="font-size:18px;font-weight:600;margin-bottom:16px;">🔗 相关推荐</h2> <div class="rec-grid"> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">developer-tools</span> <h3><a href="/s/gog">Gog</a></h3> <div class="rec-owner">steipete</div> <div class="rec-desc">Google Workspace 命令行工具,支持 Gmail、日历、云端硬盘、通讯录、表格和文档。</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 921</span> <span style="color:#5b6abf;">📥 185,821</span> </div> </div> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">developer-tools</span> <h3><a href="/s/agent-browser-clawdbot">Agent Browser</a></h3> <div class="rec-owner">matrixy</div> <div class="rec-desc">专为AI智能体优化的无头浏览器自动化CLI,支持无障碍树快照和基于引用的元素选择。</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 427</span> <span style="color:#5b6abf;">📥 118,298</span> </div> </div> <div class="rec-card"> <span class="badge-cat" style="margin-bottom:8px;display:inline-block;">developer-tools</span> <h3><a href="/s/github">Github</a></h3> <div class="rec-owner">steipete</div> <div class="rec-desc">使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。</div> <div class="rec-stats"> <span style="color:#f39c12;">★ 671</span> <span style="color:#5b6abf;">📥 324,344</span> </div> </div> </div> </div> </div> <script> document.addEventListener('DOMContentLoaded',function(){ document.querySelectorAll('.detail-tab').forEach(function(btn){ btn.addEventListener('click',function(e){ var tab = this.getAttribute('data-tab'); document.querySelectorAll('.detail-tab').forEach(function(b){b.classList.remove('active')}); document.querySelectorAll('.detail-content').forEach(function(c){c.classList.remove('active')}); this.classList.add('active'); var el = document.getElementById('tab-'+tab); if(el) el.classList.add('active'); }); }); }); </script> <div class="footer"> <p>Skill工具集 © 2026</p> </div></body> </html>