| name | csdn-publish-and-data |
| description | Save Markdown articles into the CSDN draft box and fetch CSDN creator analytics/article performance data with storageState.json or cookies.json. Use when the user asks to 保存 CSDN 草稿, 准备 CSDN 文章草稿, 批量生成 CSDN 草稿, 抓取 CSDN 创作中心运营数据, 获取最近文章的 7 日动态数据, 校验 CSDN 创作中心登录态, or export CSDN creator storage state. |
编排入口:多 skill 组合流程请使用 media-manager 总控 skill 与 media CLI。本 skill 为 deep-dive。
CSDN Publish And Data
Language
Match the user's language.
Use This Skill For
- Save a local Markdown file into the CSDN draft box.
- Validate whether the current CSDN creator auth state is still usable.
- Export Playwright storage state for later reuse.
- Fetch creator analytics with a JSON report focused on overall metrics plus per-article summary and recent 7-day dynamics.
Do not use this skill for password-based login, CAPTCHA bypass, multi-account automation, or hidden-field guessing.
CLI(推荐)
执行前先 media workspace show。Auth 默认在 $WORKSPACE/.media-manager/auth/csdn/。
| 操作 | 命令 |
|---|
| 保存草稿 | media csdn post --file output/{slug}/article.md --draft |
| 抓取运营数据 | media csdn analytics fetch |
| 导出登录态 | media csdn auth export |
| 检查登录 | media csdn auth check |
Resolve Paths And Runtime(Deep-dive / 无 CLI 时)
Determine this SKILL.md directory as {baseDir}. Prefer media csdn ... above; use scripts from {baseDir}/scripts only when debugging.
Choose The Workflow
Pick exactly one path for the current request:
- Post article (draft only): use
post-article.ts.
- Fetch analytics: use
fetch-analytics.ts.
- Check auth only: use
check-login.ts.
- Export auth state only: use
export-storage-state.ts.
Run one-time setup steps only when the environment is new, dependencies are missing, browser support changed, or the saved auth file is missing/expired.
One-Time Setup
Run this checklist only for first-time setup or when the previous setup is no longer valid.
One-Time Setup Progress:
- [ ] Step 1: Install dependencies in {baseDir}/scripts
- [ ] Step 2: Install Playwright browser if needed
- [ ] Step 3: Export or place storageState.json / cookies.json
- [ ] Step 4: Run login check once to confirm auth works
Useful commands (fallback):
media csdn auth check
media csdn auth export
After this succeeds once, skip these steps in normal runs unless auth expires or the machine/runtime changes.
Auth File Discovery Order
- CLI
--state / --cookie
$WORKSPACE/.media-manager/auth/csdn/storageState.json
$WORKSPACE/.media-manager/auth/csdn/cookies.json
<skillRoot>/.auth/(兼容旧路径)
Prefer storageState.json. Use cookies.json only as fallback.
Read extra references only when needed:
Recurring Workflow: Save Draft
Use this path for requests like “把这篇文章保存到 CSDN 草稿箱”.
Draft Workflow Progress:
- [ ] Step 1: Resolve auth file
- [ ] Step 2: Run post-article.ts with the original Markdown file
- [ ] Step 3: Confirm draft save result from JSON output
- [ ] Step 4: Report draft result files and warnings
Recommended command:
media csdn post --file output/{slug}/article.md --draft
Rules:
- Pass the original Markdown file directly.
- Do not convert Markdown to HTML before calling the script.
- By default, saves draft only.
- If the editor layout changes or selectors fail, rerun with
--headful and inspect the current page.
- If auth is already known-good, do not rerun dependency install or login check first.
Recurring Workflow: Fetch Analytics
Use this path for requests like “抓取 CSDN 运营数据”, “获取最近文章 7 日数据”, or “导出 CSDN 创作中心表现”.
Analytics Workflow Progress:
- [ ] Step 1: Resolve auth file
- [ ] Step 2: Run fetch-analytics.ts
- [ ] Step 3: Return the main JSON report path
- [ ] Step 4: Return raw output path only if --save-raw was used or debugging is needed
Recommended command:
media csdn analytics fetch
Default interpretation of the analytics output:
- Main JSON is the primary report for analysis.
- Main JSON keeps only analysis-relevant fields: overall creator metrics plus per-article summary and recent 7-day dynamics.
- Raw files are for debugging and schema inspection only.
- If auth is already known-good, do not rerun dependency install or login check first.
Current report shape:
{
"generatedAt": "...",
"report": {
"range": { "start": "YYYY-MM-DD", "end": "YYYY-MM-DD" },
"overview": {
"articleCount": 0,
"exposuresCount": 0,
"diggCount": 0,
"commentCount": 0,
"viewCount": 0,
"score": 0,
"averageQuality": 0,
"collectCount": 0
},
"articles": [
{
"articleId": "...",
"title": "...",
"url": "...",
"summary": {
"publishTime": "...",
"exposuresCount": 0,
"viewCount": 0,
"commentCount": 0,
"diggCount": 0,
"favoriteCount": 0,
"fansCount": 0,
"qualityScore": {
"score": 0,
"version": "V5.0",
"createAt": "..."
}
},
"recent7Days": [
{
"date": "YYYY-MM-DD",
"exposuresCount": 0,
"viewCount": 0,
"commentCount": 0,
"diggCount": 0,
"favoriteCount": 0,
"fansCount": 0
}
]
}
]
}
}
Common options:
--page analytics|manage|both
--start YYYY-MM-DD
--end YYYY-MM-DD
--output <dir>
--state <path>
--cookie <path>
--probe
--headful
--timeout <ms>
Focused Execution Rules
- Prefer the main JSON report for user-facing answers.
- Mention raw files only when debugging, verification, or schema exploration is useful.
- Treat storage state as reusable session state; do not force refresh unless login has expired.
- Keep the user-facing summary focused on meaningful analytics rather than raw transport metadata.
Auth-Only Workflow
Use this only when the request is specifically about validating or exporting auth state.
Check auth:
npx tsx {baseDir}/scripts/check-login.ts --state <storageState.json>
Export storage state:
npx tsx {baseDir}/scripts/export-storage-state.ts
Safety And Boundaries
- Do not ask for account password, SMS code, or login QR secrets.
- Do not commit cookies.json or storageState.json into git.
- Draft save is always supported.
- If CSDN introduces new required fields in the editor or publish dialog, stop after surfacing the missing selector or warning instead of guessing hidden values.