From f0ed1b5fbfd7e35ab918d69d0df1d47c13b70907 Mon Sep 17 00:00:00 2001 From: Zhongwei Li Date: Sun, 30 Nov 2025 08:23:30 +0800 Subject: [PATCH] Initial commit --- .claude-plugin/plugin.json | 15 ++++ README.md | 3 + commands/snapshot-manager.md | 77 +++++++++++++++++++ plugin.lock.json | 61 +++++++++++++++ skills/snapshot-test-manager/SKILL.md | 52 +++++++++++++ skills/snapshot-test-manager/assets/README.md | 6 ++ .../references/README.md | 9 +++ .../snapshot-test-manager/scripts/README.md | 7 ++ 8 files changed, 230 insertions(+) create mode 100644 .claude-plugin/plugin.json create mode 100644 README.md create mode 100644 commands/snapshot-manager.md create mode 100644 plugin.lock.json create mode 100644 skills/snapshot-test-manager/SKILL.md create mode 100644 skills/snapshot-test-manager/assets/README.md create mode 100644 skills/snapshot-test-manager/references/README.md create mode 100644 skills/snapshot-test-manager/scripts/README.md diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json new file mode 100644 index 0000000..1e8895a --- /dev/null +++ b/.claude-plugin/plugin.json @@ -0,0 +1,15 @@ +{ + "name": "snapshot-test-manager", + "description": "Manage and update snapshot tests with intelligent diff analysis and selective updates", + "version": "1.0.0", + "author": { + "name": "Claude Code Plugin Hub", + "email": "[email protected]" + }, + "skills": [ + "./skills" + ], + "commands": [ + "./commands" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..37ae6cc --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# snapshot-test-manager + +Manage and update snapshot tests with intelligent diff analysis and selective updates diff --git a/commands/snapshot-manager.md b/commands/snapshot-manager.md new file mode 100644 index 0000000..be28243 --- /dev/null +++ b/commands/snapshot-manager.md @@ -0,0 +1,77 @@ +--- +description: Manage snapshot tests with intelligent diff analysis and updates +shortcut: sm +--- + +# Snapshot Test Manager + +Manage and update snapshot tests across your codebase with intelligent diff analysis, selective updates, and snapshot validation. + +## What You Do + +1. **Analyze Snapshot Failures** + - Review failed snapshot diffs + - Identify intentional vs unintentional changes + - Show side-by-side comparisons + +2. **Selective Updates** + - Update specific snapshots that represent intentional changes + - Preserve snapshots that represent regressions + - Batch update related snapshots + +3. **Snapshot Validation** + - Verify snapshot content is meaningful + - Detect overly broad or brittle snapshots + - Suggest snapshot improvements + +4. **Snapshot Organization** + - Organize snapshots by feature/component + - Clean up orphaned snapshots + - Generate snapshot documentation + +## Usage Pattern + +When invoked, you should: + +1. Identify the test framework (Jest, Vitest, etc.) +2. Locate snapshot files and failed tests +3. Analyze diffs to determine if changes are intentional +4. Provide clear recommendations for updates +5. Execute selective snapshot updates +6. Validate updated snapshots still test meaningful behavior + +## Output Format + +```markdown +## Snapshot Analysis Report + +### Failed Snapshots: [N] + +#### Component: [Name] +**File:** `__snapshots__/[file].snap` +**Status:** [Intentional Change / Potential Regression] + +**Diff Summary:** +- Changed: [description] +- Impact: [assessment] + +**Recommendation:** [Update / Review / Reject] + +### Actions Taken +- Updated [N] snapshots +- Preserved [N] snapshots for review +- Cleaned [N] orphaned snapshots + +### Next Steps +- [ ] Review preserved snapshots +- [ ] Run full test suite +- [ ] Document snapshot changes +``` + +## Framework Support + +- Jest snapshot testing +- Vitest snapshots +- React Testing Library snapshots +- Playwright snapshots +- Storybook visual regression diff --git a/plugin.lock.json b/plugin.lock.json new file mode 100644 index 0000000..3e5c065 --- /dev/null +++ b/plugin.lock.json @@ -0,0 +1,61 @@ +{ + "$schema": "internal://schemas/plugin.lock.v1.json", + "pluginId": "gh:jeremylongshore/claude-code-plugins-plus:plugins/testing/snapshot-test-manager", + "normalized": { + "repo": null, + "ref": "refs/tags/v20251128.0", + "commit": "7eaf285fcbbf14a01435a244228eeee180083dec", + "treeHash": "b953e5a3118b0f6c276d737d8df910c212e5c0c15cacd4f6c2a15608bbc040ee", + "generatedAt": "2025-11-28T10:18:46.285615Z", + "toolVersion": "publish_plugins.py@0.2.0" + }, + "origin": { + "remote": "git@github.com:zhongweili/42plugin-data.git", + "branch": "master", + "commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390", + "repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data" + }, + "manifest": { + "name": "snapshot-test-manager", + "description": "Manage and update snapshot tests with intelligent diff analysis and selective updates", + "version": "1.0.0" + }, + "content": { + "files": [ + { + "path": "README.md", + "sha256": "a7d2b4daaeb3b36a0891957d970cbded1c5bd68e43f8fa8d515f36e0e6362279" + }, + { + "path": ".claude-plugin/plugin.json", + "sha256": "60fd75a0c8073e313a485739a635c01329bbb9180186a2174f1cdff6385814cf" + }, + { + "path": "commands/snapshot-manager.md", + "sha256": "799c7970aad0c98d0d7cd57afbf96d1d4fa9068e40b19f0216750d6f90a90802" + }, + { + "path": "skills/snapshot-test-manager/SKILL.md", + "sha256": "8351de473436d41820abbb9320a60f41e22a7a9e25e9f8ea3f2fe9e594fc9e91" + }, + { + "path": "skills/snapshot-test-manager/references/README.md", + "sha256": "7516b5efe24319b6f4872de84833b194830b6396f449a485c44c36f50940c6c2" + }, + { + "path": "skills/snapshot-test-manager/scripts/README.md", + "sha256": "37b206adee401effcb7c17f5400b3e9cdf36b91a8f7f4ebae376e0cb976c64d9" + }, + { + "path": "skills/snapshot-test-manager/assets/README.md", + "sha256": "2160d03ec146cc5b81608195d2b6e7b0e4ad78bf453f75fe853881cadae029fa" + } + ], + "dirSha256": "b953e5a3118b0f6c276d737d8df910c212e5c0c15cacd4f6c2a15608bbc040ee" + }, + "security": { + "scannedAt": null, + "scannerVersion": null, + "flags": [] + } +} \ No newline at end of file diff --git a/skills/snapshot-test-manager/SKILL.md b/skills/snapshot-test-manager/SKILL.md new file mode 100644 index 0000000..386892e --- /dev/null +++ b/skills/snapshot-test-manager/SKILL.md @@ -0,0 +1,52 @@ +--- +name: managing-snapshot-tests +description: | + This skill enables Claude to manage and update snapshot tests using intelligent diff analysis and selective updates. It is triggered when the user asks to analyze snapshot failures, update snapshots, or manage snapshot tests in general. It helps distinguish intentional changes from regressions, selectively update snapshots, and validate snapshot integrity. Use this when the user mentions "snapshot tests", "update snapshots", "snapshot failures", or requests to run "/snapshot-manager" or "/sm". It supports Jest, Vitest, Playwright, and Storybook frameworks. +allowed-tools: Read, Bash, Grep, Glob +version: 1.0.0 +--- + +## Overview + +This skill empowers Claude to efficiently manage snapshot tests by analyzing differences, selectively updating snapshots based on intentional changes, and identifying potential regressions. It provides a streamlined approach to maintain snapshot test suites across various JavaScript testing frameworks. + +## How It Works + +1. **Analyzing Failures**: Reviews failed snapshot diffs, highlighting intentional and unintentional changes with side-by-side comparisons. +2. **Selective Updating**: Updates specific snapshots that reflect intentional UI or code changes, while preserving snapshots that have caught regressions. +3. **Batch Processing**: Allows for batch updating of related snapshots to streamline the update process. + +## When to Use This Skill + +This skill activates when you need to: +- Analyze snapshot test failures after code changes. +- Update snapshot tests to reflect intentional UI changes. +- Identify and preserve snapshots that are catching regressions. + +## Examples + +### Example 1: Updating Snapshots After UI Changes + +User request: "I've made some UI changes and now my snapshot tests are failing. Can you update the snapshots?" + +The skill will: +1. Analyze the snapshot failures, identifying the diffs caused by the UI changes. +2. Update the relevant snapshot files to reflect the new UI. + +### Example 2: Investigating Unexpected Snapshot Changes + +User request: "My snapshot tests are failing, but I don't expect any UI changes. Can you help me figure out what's going on?" + +The skill will: +1. Analyze the snapshot failures, highlighting the unexpected diffs. +2. Present the diffs to the user for review, indicating potential regressions. + +## Best Practices + +- **Clear Communication**: Clearly state the intention behind updating or analyzing snapshots. +- **Framework Awareness**: Specify the testing framework (Jest, Vitest, etc.) if known for more accurate analysis. +- **Selective Updates**: Avoid blindly updating all snapshots. Focus on intentional changes and investigate unexpected diffs. + +## Integration + +This skill works independently but can be used in conjunction with other code analysis and testing tools to provide a comprehensive testing workflow. \ No newline at end of file diff --git a/skills/snapshot-test-manager/assets/README.md b/skills/snapshot-test-manager/assets/README.md new file mode 100644 index 0000000..0f30075 --- /dev/null +++ b/skills/snapshot-test-manager/assets/README.md @@ -0,0 +1,6 @@ +# Assets + +Bundled resources for snapshot-test-manager skill + +- [ ] snapshot_update_prompt_template.txt Template for prompting the user to confirm snapshot updates. +- [ ] example_snapshot_diff.txt Example of a snapshot diff to illustrate analysis capabilities. diff --git a/skills/snapshot-test-manager/references/README.md b/skills/snapshot-test-manager/references/README.md new file mode 100644 index 0000000..e0a0bf4 --- /dev/null +++ b/skills/snapshot-test-manager/references/README.md @@ -0,0 +1,9 @@ +# References + +Bundled resources for snapshot-test-manager skill + +- [ ] jest_snapshot_format.md Documentation on Jest snapshot format and best practices. +- [ ] vitest_snapshot_format.md Documentation on Vitest snapshot format and best practices. +- [ ] playwright_snapshot_format.md Documentation on Playwright snapshot format and best practices. +- [ ] storybook_snapshot_format.md Documentation on Storybook snapshot format and best practices. +- [ ] snapshot_update_workflow.md Detailed workflow for updating snapshots with examples. diff --git a/skills/snapshot-test-manager/scripts/README.md b/skills/snapshot-test-manager/scripts/README.md new file mode 100644 index 0000000..b1b5672 --- /dev/null +++ b/skills/snapshot-test-manager/scripts/README.md @@ -0,0 +1,7 @@ +# Scripts + +Bundled resources for snapshot-test-manager skill + +- [ ] update_snapshots.py Script to automatically update snapshots based on user confirmation. +- [ ] analyze_diffs.py Script to analyze snapshot diffs and suggest update/review actions. +- [ ] validate_snapshots.py Script to validate snapshot integrity and detect brittle snapshots.