Skip to content

Add Claude Code hooks and project documentation#6

Open
3x3by3 wants to merge 3 commits intofrankiejun:mainfrom
3x3by3:claude/elegant-kirch
Open

Add Claude Code hooks and project documentation#6
3x3by3 wants to merge 3 commits intofrankiejun:mainfrom
3x3by3:claude/elegant-kirch

Conversation

@3x3by3
Copy link

@3x3by3 3x3by3 commented Feb 14, 2026

Summary

  • Add PreToolUse hook to block edits to sensitive files (.env, secrets, .git/)
  • Add PostToolUse hook to auto-lint Python files with py_compile on save
  • Add CLAUDE.md documenting commands, architecture, secrets, and gotchas

Test plan

  • Verify PreToolUse hook blocks edits to files with .env, secrets, or .git/ in the path
  • Verify PostToolUse hook runs py_compile after editing .py files and reports syntax errors
  • Verify non-Python files are skipped by the PostToolUse hook
  • Verify CLAUDE.md content matches current project structure

🤖 Generated with Claude Code

3x3by3 and others added 3 commits February 13, 2026 17:05
Adds a PreToolUse hook that prevents Claude from accidentally editing
files containing .env, secrets, or .git/ paths.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a PostToolUse hook that runs py_compile after any Edit or Write
to a .py file, catching syntax errors immediately.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documents commands, architecture, key classes, required secrets,
and gotchas for the ClawCloud auto-login project.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @3x3by3, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the project's development environment by integrating automated checks and comprehensive documentation. It introduces Claude Code hooks to enforce security policies by blocking edits to sensitive files and improves code quality by automatically linting Python files. Additionally, it provides detailed guidance on the ClawCloud Auto-Login system, making it easier for developers to understand and maintain.

Highlights

  • PreToolUse Hook: Implemented a PreToolUse hook to prevent modifications to sensitive files such as .env, secrets, and .git/ directories.
  • PostToolUse Hook: Added a PostToolUse hook that automatically lints Python files using py_compile after they are edited or written, reporting any syntax errors.
  • Project Documentation: Introduced a new CLAUDE.md file to document the ClawCloud Auto-Login system, covering commands, architecture, required secrets, and common gotchas.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .claude/settings.json
    • Added a PreToolUse hook to intercept and block write/edit operations on sensitive files (e.g., .env, secrets, .git/).
    • Added a PostToolUse hook to automatically compile and check Python files for syntax errors using py_compile after they are written or edited.
  • CLAUDE.md
    • Added a new documentation file detailing the ClawCloud Auto-Login system.
    • Included sections on installation commands, architectural overview, key Python classes, required GitHub secrets, and important considerations ('Gotchas').
Activity
  • No specific activity (comments, reviews, progress updates) was provided for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces Claude Code hooks to automate certain development tasks and adds project documentation. The PreToolUse hook prevents edits to sensitive files, and the PostToolUse hook automatically lints Python files on save.

My review focuses on the implementation of these hooks in .claude/settings.json. I've identified a critical syntax error in the PostToolUse hook that will prevent it from running. I've also provided suggestions to improve the readability and maintainability of the hook commands by simplifying them and recommending they be moved to separate script files for easier management in the long run. The new documentation in CLAUDE.md is clear and provides a good overview of the project.

"hooks": [
{
"type": "command",
"command": "python -c \"import sys,json; d=json.load(sys.stdin); p=d.get('file_path',''); exec('import subprocess; r=subprocess.run([sys.executable,\\\"-m\\\",\\\"py_compile\\\",p],capture_output=True,text=True); print(r.stderr) if r.returncode else print(\\\"Syntax OK: \\\"+p)') if p.endswith('.py') else print('Skipped (not Python)')\""

Choose a reason for hiding this comment

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

critical

The python command for the PostToolUse hook has a syntax error and is unnecessarily complex. The exec(...) if ... else ... construct is not valid Python because exec is a statement, not an expression. This will cause the hook to fail with a SyntaxError.

Additionally, using exec here is a code smell and makes the command very difficult to read and maintain. The logic can be written directly without it.

I recommend simplifying the command and using a standard if/else structure. For better long-term maintainability, consider moving this logic into a separate script file.

Suggested change
"command": "python -c \"import sys,json; d=json.load(sys.stdin); p=d.get('file_path',''); exec('import subprocess; r=subprocess.run([sys.executable,\\\"-m\\\",\\\"py_compile\\\",p],capture_output=True,text=True); print(r.stderr) if r.returncode else print(\\\"Syntax OK: \\\"+p)') if p.endswith('.py') else print('Skipped (not Python)')\""
"command": "python -c \"import sys, json, subprocess; d = json.load(sys.stdin); p = d.get('file_path', '');\nif p.endswith('.py'):\n r = subprocess.run([sys.executable, '-m', 'py_compile', p], capture_output=True, text=True)\n if r.returncode == 0:\n print(f'Syntax OK: {p}')\n else:\n print(r.stderr, file=sys.stderr)\nelse:\n print('Skipped (not Python)')\""

"hooks": [
{
"type": "intercept",
"command": "python -c \"import sys,json; d=json.load(sys.stdin); p=d.get('file_path',''); blocked=['.env','secrets','.git/']; sys.exit(1) if any(x in p for x in blocked) else sys.exit(0)\""

Choose a reason for hiding this comment

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

medium

Embedding Python logic directly in JSON strings makes it hard to read, test, and maintain. While this command is simple enough, it sets a precedent. For more complex logic, it's better to move it to a separate script file (e.g., scripts/pre-tool-use-check.py) and invoke that script from the hook. This improves readability and makes the hook's behavior easier to manage in the long term.

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