Skip to content

Optimize Claude Code hooks to only run on src/ changes#5952

Merged
kzuraw merged 2 commits intomainfrom
update-claude-hooks
Oct 8, 2025
Merged

Optimize Claude Code hooks to only run on src/ changes#5952
kzuraw merged 2 commits intomainfrom
update-claude-hooks

Conversation

@kzuraw
Copy link
Contributor

@kzuraw kzuraw commented Oct 8, 2025

Summary

  • Optimized Claude Code validation hooks to skip execution when changes are outside the src/ directory
  • Reduces unnecessary validation time when working on documentation, configuration, or other non-source files

Changes

check-as-any-pre.py

  • Added early exit if file path is not in src/ directory

graphql-check.py

  • Filter files to only check those in src/ directory
  • Skip hook entirely if no src/ files modified

validation-check.sh

  • Check for src/ changes before running type checking and linting
  • Display info message when skipping validation

Test plan

  • Tested with changes in src/ directory - hooks run as expected
  • Tested with changes outside src/ - hooks skip appropriately
  • Verified all three hooks work correctly with the optimization

🤖 Generated with Claude Code

Updated three Claude Code hooks to skip validation when changes are outside the src/ directory:

- check-as-any-pre.py: Exit early if file is not in src/
- graphql-check.py: Filter to only check src/ files
- validation-check.sh: Skip type checking and linting if no src/ changes

This optimization reduces unnecessary hook execution time when working on documentation, configuration, or other non-source files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings October 8, 2025 11:42
@changeset-bot
Copy link

changeset-bot bot commented Oct 8, 2025

⚠️ No Changeset found

Latest commit: 799452f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@kzuraw kzuraw added the skip changeset Use if your changes doesn't need entry in changelog label Oct 8, 2025
@vercel
Copy link

vercel bot commented Oct 8, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
saleor-dashboard-storybook Ignored Ignored Preview Oct 8, 2025 11:45am

@kzuraw kzuraw marked this pull request as ready for review October 8, 2025 11:42
@kzuraw kzuraw requested a review from a team as a code owner October 8, 2025 11:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Optimizes Claude Code validation hooks to skip execution when changes are outside the src/ directory, reducing unnecessary validation time for non-source file modifications.

  • Added early exit conditions to check if files are in src/ directory before running validation
  • Implemented filtering logic to only process source files
  • Added informational messaging when validation is skipped

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
.claude/hooks/validation-check.sh Added git diff check to skip validation when no src/ changes detected
.claude/hooks/graphql-check.py Added filtering to only check GraphQL files within src/ directory
.claude/hooks/check-as-any-pre.py Added early exit for files outside src/ directory

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

lkostrowski
lkostrowski previously approved these changes Oct 8, 2025
Addressed Copilot review feedback:
- Use Path.parts for more precise path matching instead of string operations
- Prevents false positives from paths like 'docs/src_files/' or 'test/mysrc/'
- Fix graphql-check.py to use filtered src_files list consistently

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@kzuraw kzuraw enabled auto-merge (squash) October 8, 2025 11:46
@kzuraw kzuraw requested a review from lkostrowski October 8, 2025 11:46
@kzuraw kzuraw merged commit dd82a2d into main Oct 8, 2025
14 checks passed
@kzuraw kzuraw deleted the update-claude-hooks branch October 8, 2025 11:48
@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.06%. Comparing base (7458fc7) to head (799452f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5952   +/-   ##
=======================================
  Coverage   40.06%   40.06%           
=======================================
  Files        2473     2473           
  Lines       40229    40229           
  Branches     8854     8854           
=======================================
  Hits        16119    16119           
  Misses      24083    24083           
  Partials       27       27           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

skip changeset Use if your changes doesn't need entry in changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants