8000 feat: add a local cleanup skill by tangwz · Pull Request #7 · tangwz/skills · GitHub
[go: up one dir, main page]

Skip to content

feat: add a local cleanup skill - #7

Open
tangwz wants to merge 2 commits into
mainfrom
codex/add-claude-cleanup
Open

tangwz wants to merge 2 commits into
mainfrom
codex/add-claude-cleanup

Conversation

@tangwz
@tangwz tangwz commented Nov 19, 2026
Copy link
Copy Markdown
Owner

Summary

  • Add a skill for backing up and cleaning local application state on macOS, and for managing startup context on macOS and Windows.
  • Include the upstream script, reference, tests, and MIT license. Upstream revision 5a6848f

Verification

  • The imported file contents and modes match upstream, including the cleanup script's executable bit.

Upstream revision 5a6848ffd3c2b4f6705aa18547117ed1b1bf05cb from suyuan2022/suyuan-skill.
@chatgpt-codex-connector
chatgpt-codex-connector Bot commented Nov 19, 2026 •
Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T15:29:39.285300Z d960a3f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9404aae110

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +187 to +189
absolute = target.absolute()
protected = {claude / name for name in PROTECTED}
if absolute == claude.absolute() or any(absolute == p.absolute() or p.absolute() in absolute.parents for p in protected):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Resolve ancestor symlinks before checking protected paths

When a cleanup target has a symlinked ancestor, absolute() leaves that ancestor unresolved, allowing the protected-path check to pass even though shutil.move() moves protected data. For example, with ~/Library/Logs symlinked to ~/.claude/projects, discovery automatically includes ~/Library/Logs/Claude, and cleanup moves the actual ~/.claude/projects/Claude directory into Trash. I reproduced this with an isolated temporary home. The final protection check also misses it because projects itself still exists. Resolve ancestor directories before validating the target against protected paths, while preserving the ability to move a target that is itself a symlink without following it.

Useful? React with 👍 / 👎.

Comment on lines +533 to +534
for key in keys - {"CLAUDE_CODE_SIMPLE"}:
env.pop(key, None)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Clear inherited simple mode when measuring terminal sessions

When this script runs inside a terminal Claude Code session that inherited CLAUDE_CODE_SIMPLE=1, removing that setting and rerunning --measure still passes the stale value to every child because this exclusion applies to all sessions, not just Desktop. I reproduced this with an empty current env and a settings backup containing the removed key: claude_env() retains CLAUDE_CODE_SIMPLE=1, while simple_mode() returns false. Consequently, the documented disable-and-remeasure flow continues measuring without skills or MCP and no longer warns that the results represent simple mode. Preserve the Desktop-injected override only for Desktop sessions; let terminal measurements reread this key from the updated settings like the other settings-derived variables.

Useful? React with 👍 / 👎.

Comment on lines +772 to +776
clean_safe = not processes
if processes and risky:
print("\n所选风险操作要求由你正常退出所有 Claude Code / Claude Desktop;脚本不会 kill 进程。")
input("退出后按 Enter 重新检查:")
if claude_processes():
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck running processes after the final confirmation

If Claude starts after the initial audit—for example, while the user is answering the risk-selection prompts—the empty processes snapshot keeps clean_safe true and bypasses the only subsequent process check, even when identity rotation or Desktop removal is selected. I reproduced this by making Claude become active at the first prompt: the script checked processes only once, then rotated the identity and moved the cache while reporting success. This defeats the requirement that these operations run only after Claude has exited and permits modifications while the application is using the affected state. Perform a fresh process check after confirmation and before destructive operations, including after the potentially lengthy backup.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d960a3f84a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return env
preserved = {"CLAUDE_CODE_SIMPLE"} if in_desktop_session() else set()
path = config_dir(pathlib.Path.home()) / "settings.json"
for source in [path, *sorted(path.parent.glob("settings.json.bak-*"))[-1:]]:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Retain removed environment keys across successive settings edits

When multiple settings changes are made within the same Claude session, consulting only the latest backup lets previously removed environment variables leak back into measurements. For example, remove ENABLE_LSP_TOOL=0 after one backup, then back up settings again before another edit: neither the current settings nor the latest backup contains that key, so claude_env() retains the session's inherited ENABLE_LSP_TOOL=0. I reproduced this with two timestamped backups. Subsequent measurements therefore continue disabling LSP despite the updated configuration, undermining the documented edit-and-remeasure verification. Track settings-derived keys across the relevant backups rather than only the newest one.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0