At the Claude Code prompt, enter:
This loads Anthropic's built-in plugin-authoring guidance. Then paste the request below. It asks for source files and tests before the mod runs.
Build a Claude Code mod named review-before-edit for this practice folder.
Use the plugin-authoring guidance and the API supported by my version.
Save the plugin in ./review-before-edit. Create source files and tests
only. Do not install it, enable hot reload, change permissions, or load it.
Do not edit README.md or release-settings.json while building the mod.
Behavior:
- Handle tool.call for the built-in Edit and Write tools.
- Check the final filename in file_path. Match release-settings.json
case-insensitively, including paths with Windows separators.
- Leave other filenames to the usual tool and permission checks.
- For a matching file, show the tool name, path, and a short preview of
the proposed edit. Label any truncated preview clearly.
- Ask through $.ui.ask with these choices, in this order:
"Keep file unchanged" and "Allow this edit".
- Continue with next(e) only for the exact answer "Allow this edit".
Preserve the original tool input and all normal permission checks.
- Refuse if the question is dismissed, cannot be shown, or returns any
other answer. Tell Claude to stop rather than try another tool or path.
- Add a .catch handler that returns a denial if this handler fails.
- Ask again for every matching edit. Never save blanket approval.
Keep the mod small. Use no network calls, subprocesses, extra model
calls, direct filesystem access, or new dependencies.
Add tests for allowed and refused edits, Write replacement, other files,
repeated requests, and a downstream permission denial. Explain how to
run them with claude plugin test. Show all files and the exact load
command. List the tools and paths this example does not cover.
Read the source before loading it. Ask Claude to explain any code you do not understand. Have an experienced developer review it when necessary.
Expect the mod file structure to include a plugin description, a file pointing to the code, and the code itself. Tests may occupy a separate folder.
review-before-edit/
.claude-plugin/
plugin.json
hooks/
hooks.json
register.js
tests/
review-before-edit.test.ts
Claude may choose register.ts; the file named in hooks.json must match.