Skip to content

Commit f1d6a40

Browse files
Gutizclaude
andauthored
Claude/generate skill documentation f npo6 (#5)
* Add lightweight release-branch guard (CODEOWNERS + Actions) - .github/CODEOWNERS routes review on every PR. - .github/workflows/release-guard.yml rejects PRs into release that don't come from main, and rejects direct pushes whose tip isn't an ancestor of origin/main. - .github/pull_request_template.md flags whether a PR targets release. These are git-side guards; pair with the GitHub branch protection rule for full enforcement (instructions in README). * Switch branch policy: feature -> release -> main - release is the integration/daily-release branch; accepts PRs from any branch. - main is the stable publish branch; only accepts PRs from release. - release-guard workflow renamed to branch-policy with four jobs covering push and PR events on both protected branches. - READMEs (zh/en) and PR template updated to reflect the new flow and document the one-time gh api calls needed to enable UI-level branch protection. * Prepare v1.0.0 release notes and changelog - CHANGELOG.md following Keep a Changelog / SemVer - .github/RELEASE_NOTES_v1.0.0.md as the body for the GitHub Release --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4353912 commit f1d6a40

7 files changed

Lines changed: 301 additions & 13 deletions

File tree

.github/CODEOWNERS

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Code owners — auto-requests review on PRs touching matching paths.
2+
# Listed users/teams must approve PRs into protected branches (see release-guard).
3+
#
4+
# Syntax: <pattern> <owner1> <owner2> ...
5+
# Reference: https://docs.github.com/en/repositories/managing-your-repositories-settings-and-customizations/customizing-your-repository/about-code-owners
6+
7+
* @Gutiz
8+
9+
# Skill content & scripts
10+
/skills/ @Gutiz
11+
/skills/win-c-cleaner/ @Gutiz
12+
13+
# CI / governance (changes here change how the repo is protected)
14+
/.github/ @Gutiz

.github/RELEASE_NOTES_v1.0.0.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# win-c-cleaner v1.0.0
2+
3+
首个稳定版本 —— Windows 10/11 通用 C 盘清理 Claude Skill。
4+
5+
## 亮点
6+
7+
- **8 阶段流程**:从极低风险的临时文件清理 → 重复驱动 → OEM 预装包,按「风险低→收益大」顺序释放空间,预计回收 **25–35 GB**
8+
- **Claude Skill 标准结构**`SKILL.md` + YAML frontmatter,支持 Claude Code(CLI / Web / Desktop / VS Code)、Claude Agent SDK(Python / TypeScript)、Anthropic API Skills beta。
9+
- **安全设计**:管理员自检、Win10+ 自检、路径白名单、dry-run 默认、二次确认;Stage 8 强制非系统盘备份 + 大小校验。
10+
- **中英双语文档**:完整安装、使用、回滚说明。
11+
- **CI 守卫**`branch-policy` 工作流防止意外破坏分支策略。
12+
13+
## 快速安装
14+
15+
```powershell
16+
# Claude Code(Windows)
17+
git clone https://github.com/Gutiz/win-c-cleaner.git
18+
$dst = "$env:USERPROFILE\.claude\skills\win-c-cleaner"
19+
New-Item -ItemType Directory -Path $dst -Force | Out-Null
20+
Copy-Item .\win-c-cleaner\skills\win-c-cleaner\* $dst -Recurse -Force
21+
```
22+
23+
之后对 Claude 说 **「清理 C 盘」****「free up C drive」** 即可触发。
24+
25+
## 直接运行(不通过 agent)
26+
27+
```powershell
28+
# 管理员 PowerShell
29+
Set-ExecutionPolicy -Scope Process Bypass
30+
cd .\win-c-cleaner\skills\win-c-cleaner\scripts
31+
.\Get-DiskReport.ps1
32+
.\Clean-All.ps1
33+
```
34+
35+
## 兼容性
36+
37+
- Windows 10(10.0.19041+)/ Windows 11
38+
- PowerShell 5.1(系统自带)或 PowerShell 7+
39+
- 必须管理员身份运行
40+
- 可选:`winget`(Stage 7 优先用,缺失自动 fallback)
41+
42+
## 已知限制
43+
44+
- 阶段 5 UWP 应用迁移因 Windows API 限制需手动点击「移动」按钮,脚本会自动打开设置页。
45+
- 阶段 6 / 7 / 8 不会自动批处理多项,每项单独确认。
46+
47+
## License
48+
49+
[MIT](./LICENSE)

.github/pull_request_template.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## Summary
2+
3+
<!-- 1-3 bullet points describing the change -->
4+
5+
## Target branch
6+
7+
- [ ] `release` — feature / fix / docs (default; merge from any feature branch)
8+
- [ ] `main` — release publish (source **must** be `release`, see branch-policy workflow)
9+
10+
## Test plan
11+
12+
- [ ] Stage scripts dry-run pass on Windows 10/11
13+
- [ ] `SKILL.md` frontmatter still parses
14+
- [ ] No new secrets / personal paths committed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: branch-policy
2+
3+
# Branch policy:
4+
# - release: integration branch. Accepts PRs from any branch.
5+
# Direct pushes blocked at the UI layer.
6+
# - main: publish branch. Accepts PRs ONLY from release.
7+
# Direct pushes blocked at the UI layer.
8+
#
9+
# This workflow is the git-side enforcement. Pair with GitHub UI branch
10+
# protection rules (see README for the one-line gh command).
11+
12+
on:
13+
push:
14+
branches: [main, release]
15+
pull_request:
16+
branches: [main, release]
17+
18+
permissions:
19+
contents: read
20+
pull-requests: read
21+
22+
jobs:
23+
# PRs into main must come from release.
24+
validate-main-pr-source:
25+
if: github.event_name == 'pull_request' && github.base_ref == 'main'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Require PR source = release
29+
env:
30+
HEAD_REF: ${{ github.head_ref }}
31+
run: |
32+
if [ "$HEAD_REF" != "release" ]; then
33+
echo "::error::PRs into 'main' must come from 'release' (got: $HEAD_REF)"
34+
exit 1
35+
fi
36+
echo "OK: PR into main is from release"
37+
38+
# PRs into release: just announce; any source allowed.
39+
announce-release-pr:
40+
if: github.event_name == 'pull_request' && github.base_ref == 'release'
41+
runs-on: ubuntu-latest
42+
steps:
43+
- run: echo "PR into release from ${{ github.head_ref }} — allowed."
44+
45+
# Direct pushes to release must be the result of a PR merge.
46+
# We detect this by requiring the tip to be a merge commit OR the
47+
# ancestor of an open PR head. Force-push / arbitrary push fails.
48+
validate-release-push:
49+
if: github.event_name == 'push' && github.ref == 'refs/heads/release'
50+
runs-on: ubuntu-latest
51+
steps:
52+
- uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0
55+
- name: Require merge-commit tip (PR merge) or fast-forward from previous release
56+
run: |
57+
PARENTS=$(git rev-list --parents -n 1 HEAD | awk '{print NF-1}')
58+
if [ "$PARENTS" -ge 2 ]; then
59+
echo "OK: HEAD is a merge commit ($PARENTS parents). Likely a PR merge."
60+
exit 0
61+
fi
62+
echo "::error::Direct non-merge push to 'release' is not allowed."
63+
echo "::error::Open a PR into release instead."
64+
exit 1
65+
66+
# Direct pushes to main must descend from origin/release.
67+
validate-main-push:
68+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
- name: Require push tip to descend from origin/release
75+
run: |
76+
git fetch origin release:refs/remotes/origin/release
77+
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/release \
78+
&& ! git merge-base --is-ancestor origin/release "${{ github.sha }}"; then
79+
echo "::error::Commit ${{ github.sha }} is not on the release line."
80+
echo "::error::main only accepts commits that came through release."
81+
exit 1
82+
fi
83+
echo "OK: ${{ github.sha }} is reachable via release."

CHANGELOG.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Changelog
2+
3+
本项目遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)
4+
5+
## [1.0.0] - 2026-05-14
6+
7+
首发版本:Windows 10/11 通用 C 盘清理 Skill。
8+
9+
### Added
10+
11+
- `skills/win-c-cleaner/SKILL.md`:Skill 触发说明 + 行为规约 + 8 阶段手册。
12+
- 8 个独立 stage 脚本,可单独执行或通过 `Clean-All.ps1` 编排:
13+
- Stage 1 `Invoke-Stage1-TempClean.ps1` —— 临时文件 / 缓存 / 回收站 / 崩溃转储(默认 dry-run)
14+
- Stage 2 `Invoke-Stage2-HiberPagefile.ps1` —— `powercfg /h off` + `pagefile` 缩容
15+
- Stage 3 `Invoke-Stage3-DismCleanup.ps1` —— DISM WinSxS 组件清理(可选 `/ResetBase`
16+
- Stage 4 `Invoke-Stage4-UwpBloat.ps1` —— UWP 垃圾应用卸载(含 `-AggressiveList`
17+
- Stage 5 `Invoke-Stage5-MoveApps.ps1` —— 大型 UWP 应用迁移到其他盘
18+
- Stage 6 `Invoke-Stage6-DriverCleanup.ps1` + `Get-DuplicateDrivers.ps1` —— 重复驱动分批清理
19+
- Stage 7 `Invoke-Stage7-OemBloat.ps1` —— OEM 预装软件(Dell/Lenovo/HP/ASUS/Acer/试用杀软)
20+
- Stage 8 `Invoke-Stage8-RemovePpkg.ps1` —— OEM ppkg 强制备份后删除
21+
- 辅助脚本:`Get-DiskReport.ps1``Get-AppDataTopConsumers.ps1``_Common.ps1`
22+
- 安全机制:管理员自检、Windows 10+ 自检、`Test-SafePath` 白名单、dry-run 默认、二次确认。
23+
- 中英双语 README(`README.md` / `README.en.md`)。
24+
- `.github/CODEOWNERS``.github/workflows/release-guard.yml`(branch-policy 工作流)、PR 模板。
25+
- 分支策略:`feat/* → PR → release → PR → main`,release 和 main 受保护,禁止直接 push 与 force push。
26+
27+
### Security
28+
29+
- 删除操作均经过路径白名单校验,越界路径自动拒绝。
30+
- Stage 3 `/ResetBase`、Stage 6 删驱动、Stage 8 删 ppkg 均要求显式参数 + 二次确认。
31+
- Stage 8 强制 `-BackupDir` 指向非系统盘,复制+大小校验通过后才删除原文件。
32+
33+
### Notes
34+
35+
- 预计在 Win10/11 上典型可释放 **25–35 GB** 空间。
36+
- 阶段 2/3/6 完整生效需重启。
37+
- 阶段 5/8 推荐有第二块盘(D:/E:/移动盘)。
38+
39+
[1.0.0]: https://github.com/Gutiz/win-c-cleaner/releases/tag/v1.0.0

README.en.md

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,15 +236,60 @@ It will not fire on macOS or Linux sessions.
236236

237237
---
238238

239-
## Branches
239+
## Branch policy
240240

241-
| Branch | Purpose |
242-
|--------|---------|
243-
| `main` | Mainline development |
244-
| `release` | Daily release branchprotected, deployment artifacts cut from here |
245-
| `claude/*` | Claude-generated feature branches |
241+
| Branch | Role | Write rules |
242+
|--------|------|-------------|
243+
| `release` | **Daily integration / release branch** (protected) | No direct push; accepts PRs from any feature branch |
244+
| `main` | **Stable publish branch** (protected) | No direct push; **only accepts PRs from `release`** |
245+
| `claude/*`, `feat/*`, `fix/*` | Feature / fix branches | Free push; merged via PR into `release` |
246246

247-
Pull requests should target `main`. Release rotations cherry-pick or fast-forward from `main` into `release`.
247+
Flow:
248+
249+
```
250+
feat/foo ──► PR ──► release ──► PR ──► main
251+
fix/bar ──► PR ──┘
252+
```
253+
254+
`.github/workflows/release-guard.yml` enforces git-side checks:
255+
- PR into `main`: requires `head_ref == release` or fails
256+
- Push to `main`: requires the tip to be reachable from release
257+
- Push to `release`: requires a merge-commit tip (PR-merge artifact)
258+
259+
True UI-level blocking still needs a one-time branch protection setup
260+
(see "Set up branch protection" below).
261+
262+
### Set up branch protection (one-time)
263+
264+
Install `gh` locally, run `gh auth login`, then:
265+
266+
```bash
267+
# release: no direct push, PRs required
268+
gh api -X PUT repos/Gutiz/win-c-cleaner/branches/release/protection \
269+
-F required_pull_request_reviews.required_approving_review_count=1 \
270+
-F required_pull_request_reviews.dismiss_stale_reviews=true \
271+
-F required_linear_history=true \
272+
-F allow_force_pushes=false \
273+
-F allow_deletions=false \
274+
-F enforce_admins=true \
275+
-F required_status_checks.strict=true \
276+
-F 'required_status_checks.contexts[]=branch-policy / announce-release-pr' \
277+
-F 'required_status_checks.contexts[]=branch-policy / validate-release-push' \
278+
-F restrictions=
279+
280+
# main: no direct push, PRs required, PR source must be release
281+
gh api -X PUT repos/Gutiz/win-c-cleaner/branches/main/protection \
282+
-F required_pull_request_reviews.required_approving_review_count=1 \
283+
-F required_pull_request_reviews.dismiss_stale_reviews=true \
284+
-F required_linear_history=true \
285+
-F allow_force_pushes=false \
286+
-F allow_deletions=false \
287+
-F enforce_admins=true \
288+
-F required_status_checks.strict=true \
289+
-F 'required_status_checks.contexts[]=branch-policy / validate-main-pr-source' \
290+
-F 'required_status_checks.contexts[]=branch-policy / validate-main-push' \
291+
-F restrictions=
292+
```
248293

249294
---
250295

README.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -237,13 +237,57 @@ Skill 通过 `SKILL.md` frontmatter 中的描述自动匹配下列触发词:
237237

238238
## 分支策略
239239

240-
| 分支 | 用途 |
241-
|------|------|
242-
| `main` | 主线开发 |
243-
| `release` | 日常发布分支(受保护),构建/发布产物从这里切 |
244-
| `claude/*` | Claude 生成的功能分支 |
240+
| 分支 | 用途 | 写入规则 |
241+
|------|------|---------|
242+
| `release` | **日常集成 / 发布分支**(受保护) | 不可直接 push;接收来自任意 feature 分支的 PR |
243+
| `main` | **发布稳定分支**(受保护) | 不可直接 push;**只接收来自 `release` 的 PR** |
244+
| `claude/*``feat/*``fix/*` | 功能 / 修复分支 | 自由 push,通过 PR 合入 `release` |
245245

246-
Pull Request 默认合到 `main`,发布时从 `main` 合入 / fast-forward 到 `release`
246+
提交流向:
247+
248+
```
249+
feat/foo ──► PR ──► release ──► PR ──► main
250+
fix/bar ──► PR ──┘
251+
```
252+
253+
`.github/workflows/release-guard.yml` 已经在 git 层做基本检查:
254+
- PR 进入 `main`:CI 校验 `head_ref == release`,否则 fail
255+
- Push 到 `main`:CI 校验 tip 必须在 release 历史上
256+
- Push 到 `release`:CI 校验 tip 必须是 merge commit(PR 合并产物)
257+
258+
UI 层的强制阻止还需要一次性的 Branch Protection 设置(见下文「设置分支保护」)。
259+
260+
### 设置分支保护(一次性)
261+
262+
本机装好 `gh``gh auth login` 后,跑:
263+
264+
```bash
265+
# release:禁止直接 push,必须 PR
266+
gh api -X PUT repos/Gutiz/win-c-cleaner/branches/release/protection \
267+
-F required_pull_request_reviews.required_approving_review_count=1 \
268+
-F required_pull_request_reviews.dismiss_stale_reviews=true \
269+
-F required_linear_history=true \
270+
-F allow_force_pushes=false \
271+
-F allow_deletions=false \
272+
-F enforce_admins=true \
273+
-F required_status_checks.strict=true \
274+
-F 'required_status_checks.contexts[]=branch-policy / announce-release-pr' \
275+
-F 'required_status_checks.contexts[]=branch-policy / validate-release-push' \
276+
-F restrictions=
277+
278+
# main:禁止直接 push,必须 PR,且 PR 来源只能是 release
279+
gh api -X PUT repos/Gutiz/win-c-cleaner/branches/main/protection \
280+
-F required_pull_request_reviews.required_approving_review_count=1 \
281+
-F required_pull_request_reviews.dismiss_stale_reviews=true \
282+
-F required_linear_history=true \
283+
-F allow_force_pushes=false \
284+
-F allow_deletions=false \
285+
-F enforce_admins=true \
286+
-F required_status_checks.strict=true \
287+
-F 'required_status_checks.contexts[]=branch-policy / validate-main-pr-source' \
288+
-F 'required_status_checks.contexts[]=branch-policy / validate-main-push' \
289+
-F restrictions=
290+
```
247291

248292
---
249293

0 commit comments

Comments
 (0)