zrosenfield/m365-cli/m365-shared
Claude Code and agent skill by zrosenfield/m365-cli
- community
Checking that the SKILL.md file is still in the repository.
M365 CLI: Auth, config, global flags, and site/drive discovery. Prerequisite for all m365-* skills.
Install
npx vskill@latest install zrosenfield/m365-cli/m365-sharedSKILL.md
m365-shared — Auth, Config & Global Concepts
Prerequisites
Install the CLI:
Verify: m365 --version
Authentication
m365 supports three auth methods, tried in this order on every command:
SP_CLI_ACCESS_TOKENenv var- Client credentials (service principal) — if
clientSecretis configured - Stored delegated token — set by
m365 auth login
Permission models — choose one
Delegated (device code) — recommended, least privilege
The app acts as your signed-in user account. It can only access sites your account can access. No admin consent required.
App registration prerequisite: Authentication → Advanced settings → Allow public client flows → Yes (required for device code).
Tokens expire (typically 1 hour access / 90-day refresh). Re-run m365 auth login if you get auth errors.
`Sites.Selected` — app-only, scoped to specific sites
Best for headless agents. The app has no access until a SharePoint admin explicitly grants it per-site. Requires a client secret; no interactive login.
Admin grants access once per site via Graph API (see README App Registration section).
`Sites.ReadWrite.All` — app-only, full tenant access
Easiest to set up but broadest blast radius. Requires Global/SharePoint Admin consent. Avoid unless you genuinely need tenant-wide access.
Auth commands
Configuration
Config is stored at ~/.m365-cli/config.json (mode 0600).
Keys:
| Key | Description | |
|---|---|---|
tenantId | Azure AD tenant GUID or domain | |
clientId | App registration client ID | |
clientSecret | Client secret (omit for device code) | |
tenantUrl | Default SharePoint URL (e.g. https://contoso.sharepoint.com) | |
defaultSiteId | Default site ID used when --site is omitted | |
defaultDriveId | Default drive ID used when --drive is omitted |
Global Option Precedence
Most commands accept --site and --drive flags that override config defaults:
- CLI flag (
--site,--drive,--tenant) - Config file defaults (
defaultSiteId,defaultDriveId,tenantUrl)
Output Format
All commands output JSON to stdout:
Errors go to stderr:
Use --raw (on m365 auth token) or pipe through jq .data to extract values.
Discover Sites and Drives
Before using file or list commands, discover the IDs you need:
Required App Registration Permissions
Delegated (device code) — no admin consent needed:
Sites.ReadWrite.All(delegated) — covers lists and list items tooFiles.ReadWrite.All(delegated)Mail.ReadWrite(delegated)Mail.Send(delegated)Calendars.ReadWrite(delegated)Calendars.ReadWrite.Shared(delegated)offline_access(delegated)
`Sites.Selected` — app-only, scoped:
Sites.Selected(application) — admin consents this, then grants per-site via Graph API
`Sites.ReadWrite.All` — app-only, full tenant:
Sites.ReadWrite.All(application) — requires Global/SharePoint Admin consentFiles.ReadWrite.All(application)Lists.ReadWrite.All(application)
Security Rules
- Never log or expose the access token in command output (use
m365 auth token --raw | ...and pipe directly). - Config file is written with mode 0600; never commit
~/.m365-cli/config.json. - Client secrets should use
m365 auth setuprather than being placed in environment variables in scripts that get committed.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/m365-shared/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/zrosenfield/m365-cli/m365-shared)