skills/plan-writer/SKILL.md
Plan 模式下智能分批写入计划文件,避免单次写入过大导致失败
npx skillsauth add snailuu/skill plan-writerInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
必须直接使用 Bash 工具执行 shell 命令,绝对不要使用 Task 工具来执行命令。
当在 Plan 模式下需要写入计划文件时自动触发,或用户明确要求:
Plan 模式下一次性写入大量内容会导致失败,原因:
将计划按逻辑章节分批写入到同一个文件:
如果单个文件仍然过大,分割成多个文件:
plan-phase-1.md, plan-phase-2.mdplan-backend.md, plan-frontend.mdplan-index.md 链接所有子计划# 估算内容大小(字符数)
echo "计划内容" | wc -c
判断策略:
100KB:多文件分割
# 项目迁移计划
## 概述
[项目背景和目标]
## 第一阶段:准备工作
[详细步骤]
## 第二阶段:数据迁移
[详细步骤]
使用 Edit 工具在文件末尾追加:
## 第三阶段:API 更新
[详细步骤]
## 第四阶段:前端集成
[详细步骤]
## 第五阶段:测试验证
[详细步骤]
## 第六阶段:上线部署
[详细步骤]
## 风险评估
[风险列表]
如果需要分割成多个文件:
# 项目迁移计划索引
## 计划概述
[总体说明]
## 计划文件
1. [第一阶段:准备工作](./plan-phase-1.md)
2. [第二阶段:数据迁移](./plan-phase-2.md)
3. [第三阶段:API 更新](./plan-phase-3.md)
4. [第四阶段:前端集成](./plan-phase-4.md)
5. [第五阶段:测试验证](./plan-phase-5.md)
## 执行顺序
按照上述阶段顺序依次执行,每个阶段完成后进行验证。
每个文件独立保存一个阶段的详细计划。
# 检查文件是否创建成功
ls -lh .claude/plans/
# 查看文件大小
du -h .claude/plans/*.md
# 验证内容完整性(检查章节数)
grep "^## " .claude/plans/plan.md | wc -l
总内容 < 30KB:
└─ 直接写入
总内容 30KB - 100KB:
├─ 第一次写入: 0 - 30KB
├─ 第二次追加: 30KB - 60KB
└─ 第三次追加: 60KB - 100KB
总内容 > 100KB:
├─ plan-index.md (索引)
├─ plan-phase-1.md (< 50KB)
├─ plan-phase-2.md (< 50KB)
└─ plan-phase-3.md (< 50KB)
优先在以下位置分段:
## 二级标题(主要章节)### 三级标题(次要章节)不要在以下位置分段:
✅ 计划写入完成
文件信息:
📄 .claude/plans/plan.md (45.2 KB)
写入统计:
- 第 1 批:章节 1-3 (28.5 KB)
- 第 2 批:章节 4-6 (16.7 KB)
验证结果:
✓ 所有 6 个章节已写入
✓ 文件完整性检查通过
✅ 计划分割完成
文件列表:
📋 .claude/plans/plan-index.md (2.3 KB)
📄 .claude/plans/plan-phase-1.md (42.1 KB)
📄 .claude/plans/plan-phase-2.md (38.7 KB)
📄 .claude/plans/plan-phase-3.md (35.9 KB)
总大小:119.0 KB (分 3 个文件)
查看计划:
cat .claude/plans/plan-index.md
如果写入仍然失败:
如果提示 context 不足:
# 使用 compact 命令清理上下文
/compact focus on writing the plan file
用户:写入迁移计划
AI 执行:
1. 分析内容:约 50KB,需要分 2 批
2. 第一批:写入前 3 个章节(25KB)
3. 第二批:追加后 3 个章节(25KB)
4. 验证:检查所有章节完整
用户:保存重构计划
AI 执行:
1. 分析内容:约 150KB,需要分 3 个文件
2. 创建索引文件:plan-index.md
3. 创建阶段文件:
- plan-phase-1.md (准备阶段)
- plan-phase-2.md (实施阶段)
- plan-phase-3.md (验证阶段)
4. 验证:检查所有文件创建成功
def split_content(content: str, chunk_size: int = 30000) -> list[str]:
"""
按章节智能分割内容
"""
chunks = []
current_chunk = ""
# 按二级标题分割
sections = content.split("\n## ")
for i, section in enumerate(sections):
# 恢复标题格式
if i > 0:
section = "\n## " + section
# 如果当前块 + 新章节超过限制
if len(current_chunk) + len(section) > chunk_size:
if current_chunk:
chunks.append(current_chunk)
current_chunk = section
else:
current_chunk += section
# 添加最后一块
if current_chunk:
chunks.append(current_chunk)
return chunks
使用 Edit 工具在文件末尾追加:
# 读取现有内容
existing_content = read_file("plan.md")
# 追加新内容
new_content = existing_content + "\n\n" + additional_content
# 使用 Edit 工具替换
edit_file(
file_path="plan.md",
old_string=existing_content,
new_string=new_content
)
在 .claude/settings.json 中添加:
{
"env": {
"PLAN_CHUNK_SIZE": "30000",
"PLAN_MAX_FILE_SIZE": "50000"
}
}
这个技能通过智能分批写入解决了 Plan 模式下的文件写入问题:
关键是分而治之,将大任务分解为多个小的、可管理的写入操作。
documentation
Use when 需要根据 git 历史生成或更新 CHANGELOG.md,尤其在发版前整理 Unreleased、版本区间、tag diff 或 Keep a Changelog 条目时。
development
Semantic Design System Skill for Google Stitch. Generates agent-friendly DESIGN.md files that enforce premium, anti-generic UI standards — strict typography, calibrated color, asymmetric layouts, perpetual micro-motion, and hardware-accelerated performance.
development
Upgrades existing websites and apps to premium quality. Audits current design, identifies generic AI patterns, and applies high-end design standards without breaking functionality. Works with any CSS framework or vanilla CSS.
development
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.