dingtalk-workspace-cli
Use DingTalk Workspace CLI (dws) to manage DingTalk contacts, calendar, todos, attendance, approvals, and more from the command line or AI agent workflows.
What this skill does
# DingTalk Workspace CLI (dws)
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
`dws` is an officially open-sourced cross-platform CLI tool from DingTalk that unifies DingTalk's full product suite into a single binary. It is designed for both human users and AI agent workflows. Every response is structured JSON, and built-in Agent Skills let LLMs use DingTalk out of the box.
---
## Installation
### One-liner (recommended)
**macOS / Linux:**
```bash
curl -fsSL https://raw.githubusercontent.com/DingTalk-Real-AI/dingtalk-workspace-cli/main/scripts/install.sh | sh
```
**Windows (PowerShell):**
```powershell
irm https://raw.githubusercontent.com/DingTalk-Real-AI/dingtalk-workspace-cli/main/scripts/install.ps1 | iex
```
The installer:
- Auto-detects OS and architecture
- Downloads a pre-compiled binary to `~/.local/bin`
- Installs Agent Skills to `~/.agents/skills/dws`
Add to PATH if needed:
```bash
export PATH="$HOME/.local/bin:$PATH"
# Add to ~/.bashrc or ~/.zshrc to persist
```
### Build from source
```bash
git clone https://github.com/DingTalk-Real-AI/dingtalk-workspace-cli.git
cd dingtalk-workspace-cli
make build
./dws version
```
---
## Prerequisites & Setup
### 1. Create a DingTalk app
Go to [DingTalk Open Platform](https://open-dev.dingtalk.com/fe/app?hash=%23%2Fcorp%2Fapp#/corp/app), create an enterprise internal app, and note the **Client ID (AppKey)** and **Client Secret (AppSecret)**.
### 2. Configure redirect URL
In the app's **Security Settings**, add `http://127.0.0.1` as a redirect URL.
### 3. Publish the app
Go to **App Release → Version Management** and publish the app so it is active.
### 4. Whitelist (beta)
During the co-creation phase, join the DingTalk DWS group and provide your Client ID and enterprise admin confirmation to be whitelisted.
### 5. Authenticate
```bash
# Via CLI flags
dws auth login --client-id $DWS_CLIENT_ID --client-secret $DWS_CLIENT_SECRET
# Or set env vars first, then login
export DWS_CLIENT_ID=your-app-key
export DWS_CLIENT_SECRET=your-app-secret
dws auth login
```
Tokens are stored encrypted with **PBKDF2 (600,000 iterations) + AES-256-GCM**, keyed to your device MAC address.
---
## Environment Variables
| Variable | Purpose |
|---|---|
| `DWS_CLIENT_ID` | OAuth Client ID (DingTalk AppKey) |
| `DWS_CLIENT_SECRET` | OAuth Client Secret (DingTalk AppSecret) |
| `DWS_CONFIG_DIR` | Override default config directory |
| `DWS_SERVERS_URL` | Custom server registry endpoint |
| `DWS_TRUSTED_DOMAINS` | Comma-separated domains for bearer token (default: `*.dingtalk.com`) |
| `DWS_ALLOW_HTTP_ENDPOINTS` | Set to `1` to allow HTTP on loopback (dev only) |
---
## Key Commands
### Authentication
```bash
dws auth login # Authenticate via OAuth device flow
dws auth logout # Remove stored credentials
dws auth status # Show current auth status
```
### Contacts
```bash
# Search users
dws contact user search --keyword "Alice"
# List departments
dws contact department list
# Get user details
dws contact user get --user-id <userId>
```
### Calendar
```bash
# List events
dws calendar event list
# Create an event
dws calendar event create \
--title "Q2 Planning" \
--start "2026-04-01T10:00:00+08:00" \
--end "2026-04-01T11:00:00+08:00" \
--attendees "<userId1>,<userId2>"
# Check room availability
dws calendar room list
```
### Todo
```bash
# List tasks
dws todo task list
# Create a task
dws todo task create \
--title "Prepare quarterly report" \
--executors "<userId>"
# Complete a task
dws todo task complete --task-id <taskId>
```
### Chat
```bash
# List groups
dws chat group list
# Send a message via webhook
dws chat webhook send \
--url $DINGTALK_WEBHOOK_URL \
--content "Deployment succeeded ✅"
# Send robot message
dws chat robot send \
--group-id <groupId> \
--content "Hello from dws"
```
### Attendance
```bash
# Get attendance records
dws attendance record list --user-id <userId> --date "2026-03-01"
# List shift schedules
dws attendance shift list
```
### Approval
```bash
# List approval templates
dws approval template list
# Submit an approval instance
dws approval instance create \
--process-code <processCode> \
--form-values '{"key":"value"}'
# Query approval instances
dws approval instance list --status RUNNING
```
### DING Messages
```bash
# Send a DING message
dws ding send --receiver-ids "<userId>" --content "Urgent: please review PR"
# Recall a DING message
dws ding recall --ding-id <dingId>
```
### AI Table (aitable)
```bash
# List tables
dws aitable table list --space-id <spaceId>
# Query records
dws aitable record list --table-id <tableId>
```
### Developer Docs
```bash
# Search DingTalk open platform docs
dws devdoc search --keyword "webhook"
```
### Workbench
```bash
# List workbench apps
dws workbench app list
```
---
## Output Formats
All commands support `-f` / `--format`:
```bash
# Human-readable table (default)
dws contact user search --keyword "Alice" -f table
# Structured JSON (for agents and piping)
dws contact user search --keyword "Alice" -f json
# Raw API response
dws contact user search --keyword "Alice" -f raw
```
Save output to a file:
```bash
dws contact user search --keyword "Alice" -f json -o results.json
```
---
## Dry Run
Preview the MCP tool call without executing it:
```bash
dws todo task list --dry-run
dws calendar event create --title "Test" --dry-run
```
---
## Shell Completion
```bash
# Bash
dws completion bash > /etc/bash_completion.d/dws
# Zsh
dws completion zsh > "${fpath[1]}/_dws"
# Fish
dws completion fish > ~/.config/fish/completions/dws.fish
```
---
## Exit Codes
| Code | Category | Meaning |
|---|---|---|
| 0 | Success | Command completed successfully |
| 1 | API | MCP tool call or upstream API failure |
| 2 | Auth | Authentication or authorization failure |
| 3 | Validation | Bad input flags or schema mismatch |
| 4 | Discovery | Service discovery or cache failure |
| 5 | Internal | Unexpected internal error |
When using `-f json`, errors include structured fields: `category`, `reason`, `hint`, `actions`.
---
## Common Patterns
### Scripting: find a user then create a todo assigned to them
```bash
#!/bin/bash
set -euo pipefail
# Search for user and extract userId
USER_ID=$(dws contact user search --keyword "Alice" -f json | \
jq -r '.data[0].userId')
echo "Found user: $USER_ID"
# Create a todo assigned to that user
dws todo task create \
--title "Review design doc" \
--executors "$USER_ID" \
-f json
```
### Scripting: send a daily standup reminder
```bash
#!/bin/bash
dws ding send \
--receiver-ids "$TEAM_USER_IDS" \
--content "🕘 Daily standup in 5 minutes — please join!" \
-f json
```
### CI/CD: post build status to a DingTalk group
```bash
#!/bin/bash
STATUS=${1:-"unknown"}
EMOJI=$([[ "$STATUS" == "success" ]] && echo "✅" || echo "❌")
dws chat webhook send \
--url "$DINGTALK_WEBHOOK_URL" \
--content "$EMOJI Build #$BUILD_NUMBER $STATUS — $BUILD_URL"
```
### Using dws in a Go project
```go
package main
import (
"os/exec"
"encoding/json"
"fmt"
)
type SearchResult struct {
Data []struct {
UserID string `json:"userId"`
Name string `json:"name"`
} `json:"data"`
}
func searchDingTalkUser(keyword string) (*SearchResult, error) {
cmd := exec.Command("dws", "contact", "user", "search",
"--keyword", keyword,
"-f", "json",
)
out, err := cmd.Output()
if err != nil {
return nil, fmt.Errorf("dws error: %w", err)
}
var result SearchResult
if err := json.Unmarshal(out, &result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
result, err := searchDingTalkUser("Alice")
if err != nil {
panic(err)
}
for _, u := range result.Data {
fmt.Printf("User: %s (%s)\n", u.Name, u.UserID)
}
}
```
---
## AI Agent Integration
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.