onedrive
БесплатноБез исполняемых скриптовНе проверенManage files and folders in OneDrive and OneDrive for Business via Microsoft Graph API. Use when someone asks to "upload to OneDrive", "sync files with…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
OneDrive
Overview
This skill helps AI agents manage files in OneDrive (personal and business) via Microsoft Graph API. It covers file upload/download, folder management, sharing links, permission control, search, thumbnails, large file uploads with resumable sessions, delta queries for efficient sync, and webhook notifications.
Instructions
Authentication
// Permissions needed:
// Files.ReadWrite — delegated: the signed-in user's own OneDrive (use /me/drive)
// Files.ReadWrite.All — delegated or application: any drive the app may reach
// Application permissions work only for work/school accounts, not personal OneDrive.
// npm install @microsoft/microsoft-graph-client @azure/identity
import { Client } from '@microsoft/microsoft-graph-client';
import { TokenCredentialAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials';
import { ClientSecretCredential } from '@azure/identity';
const credential = new ClientSecretCredential(
process.env.AZURE_TENANT_ID, process.env.AZURE_CLIENT_ID, process.env.AZURE_CLIENT_SECRET);
const graphClient = Client.initWithMiddleware({
authProvider: new TokenCredentialAuthenticationProvider(credential, {
scopes: ['https://graph.microsoft.com/.default'],
}),
});
const userId = '[email protected]'; // app-only calls address a user; delegated calls use /me/drive
File & Folder Operations
// Get user's drive info
const drive = await graphClient.api(`/users/${userId}/drive`)
.select('id,driveType,quota')
.get();
console.log(`Used: ${(drive.quota.used / 1e9).toFixed(1)} GB / ${(drive.quota.total / 1e9).toFixed(0)} GB`);
// List root folder
const root = await graphClient.api(`/users/${userId}/drive/root/children`)
.select('id,name,size,lastModifiedDateTime,folder,file,webUrl')
.orderby('name')
.get();
// List specific folder (by path)
const items = await graphClient
.api(`/users/${userId}/drive/root:/Projects/Q1-2026:/children`)
.select('id,name,size,lastModifiedDateTime,folder,file')
.get();
// Create folder
await graphClient.api(`/users/${userId}/drive/root/children`)
.post({
name: 'New Project',
folder: {},
'@microsoft.graph.conflictBehavior': 'rename', // 'fail', 'replace', or 'rename'
});
// Create a subfolder by path
await graphClient.api(`/users/${userId}/drive/root:/Projects/Q1-2026/Reports:/children`)
.post({
name: 'March',
folder: {},
});
Upload Files
// Simple upload (up to 250 MB)
const fileBuffer = fs.readFileSync('./proposal.pdf');
const uploaded = await graphClient
.api(`/users/${userId}/drive/root:/Documents/proposal.pdf:/content`)
.put(fileBuffer);
console.log('Uploaded:', uploaded.webUrl);
// Large file upload (over 250 MB, or any file you want resumable) — upload session
const uploadSession = await graphClient
.api(`/users/${userId}/drive/root:/LargeFiles/database-backup.zip:/createUploadSession`)
.post({
item: {
'@microsoft.graph.conflictBehavior': 'replace',
name: 'database-backup.zip',
},
});
const filePath = './database-backup.zip';
const fileSize = fs.statSync(filePath).size;
const chunkSize = 10 * 1024 * 1024; // 10 MiB chunks: a multiple of 320 KiB, under 60 MiB
const file = fs.openSync(filePath, 'r');
let offset = 0;
while (offset < fileSize) {
const length = Math.min(chunkSize, fileSize - offset);
const buffer = Buffer.alloc(length);
fs.readSync(file, buffer, 0, length, offset);
const res = await fetch(uploadSession.uploadUrl, {
method: 'PUT',
headers: {
// no Authorization header: the uploadUrl is pre-authenticated and a token can cause 401
'Content-Length': `${length}`,
'Content-Range': `bytes ${offset}-${offset + length - 1}/${fileSize}`,
},
body: buffer,
});
if (!res.ok) throw new Error(`Chunk upload failed: ${res.status} ${await res.text()}`);
offset += length;
console.log(`Progress: ${Math.round(offset / fileSize * 100)}%`);
}
fs.closeSync(file);
Download Files
// Download by item ID
const stream = await graphClient
.api(`/users/${userId}/drive/items/${itemId}/content`)
.getStream();
const writer = fs.createWriteStream('./output.pdf');
stream.pipe(writer);
// Download by path
const content = await graphClient
.api(`/users/${userId}/drive/root:/Documents/proposal.pdf:/content`)
.getStream();
Move, Copy, Rename, Delete
// Rename or move via PATCH
await graphClient.api(`/users/${userId}/drive/items/${itemId}`)
.patch({ name: 'new-filename.pdf', parentReference: { id: targetFolderId } });
// Copy (async — returns Location header with monitor URL)
await graphClient.api(`/users/${userId}/drive/items/${itemId}/copy`)
.post({ parentReference: { driveId, id: targetFolderId }, name: 'report-copy.pdf' });
// Delete (sends to recycle bin)
await graphClient.api(`/users/${userId}/drive/items/${itemId}`).delete();
Sharing
Установить onedrive в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл onedrive?
Manage files and folders in OneDrive and OneDrive for Business via Microsoft Graph API. Use when someone asks to "upload to OneDrive", "sync files with OneDrive", "share OneDrive files", "manage OneDrive folders", "OneDrive API integration", "backup to OneDrive", or "automate file management in OneDrive". Covers file CRUD, sharing, sync, search, large file upload, thumbnails, and delta queries for change tracking.
Как установить скилл onedrive?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл onedrive запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic