-
-
Notifications
You must be signed in to change notification settings - Fork 0
docs: add Claude workflow automation and streamline CLAUDE.md #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9341ea5
docs: add Claude workflow automation and streamline CLAUDE.md
joshsmithxrm 3ff6f51
docs: minor refinements to hook and CLAUDE.md
joshsmithxrm 5784c3f
fix: improve pre-commit hook robustness
joshsmithxrm ce3bb08
fix: improve pre-commit hook command detection and output
joshsmithxrm eb7f8ac
docs: simplify gh api permission in settings example
joshsmithxrm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| # Pre-PR Validation | ||
|
|
||
| Run before creating a PR to catch issues early. | ||
|
|
||
| ## Usage | ||
|
|
||
| `/pre-pr` | ||
|
|
||
| ## Checks Performed | ||
|
|
||
| ### 1. Build & Test | ||
| ```bash | ||
| dotnet build -c Release --warnaserror | ||
| dotnet test --no-build -c Release | ||
| ``` | ||
|
|
||
| ### 2. New Public APIs | ||
| - Check for public classes/methods without XML documentation | ||
| - Check for new public APIs without corresponding tests | ||
|
|
||
| ### 3. Common Issues | ||
| - Generic catch clauses (`catch { }` or `catch (Exception)` without logging) | ||
| - TODO/FIXME comments that should be issues | ||
| - Console.WriteLine in library code (should use ILogger or AuthenticationOutput) | ||
| - Dead code (unused private methods, unreachable code) | ||
|
|
||
| ### 4. Changelog | ||
| - Verify CHANGELOG.md in affected package(s) is updated | ||
| - If not, prompt: "Update changelog for [package]?" | ||
|
|
||
| ### 5. Test Coverage (New Code) | ||
| - For each new class: does corresponding test file exist? | ||
| - Prompt: "No tests for [ClassName]. Add tests?" → Generate test stubs | ||
|
|
||
| ## Output | ||
|
|
||
| ``` | ||
| Pre-PR Validation | ||
| ================= | ||
| [x] Build: PASS | ||
| [x] Tests: PASS (42 passed) | ||
| [!] Missing XML docs: MsalClientBuilder.CreateClient() | ||
| [x] No TODOs found | ||
| [!] Changelog not updated for PPDS.Auth | ||
| [!] No tests for: ThrottleDetector, MsalClientBuilder | ||
|
|
||
| Fix issues? [Y/n] | ||
| ``` | ||
|
|
||
| ## Behavior | ||
|
|
||
| - On first failure: stop and report | ||
| - On warnings: list all, ask whether to fix | ||
| - Auto-fix what's possible (changelog stubs, test file creation) | ||
| - Manual fix guidance for others | ||
|
|
||
| ## When to Use | ||
|
|
||
| - Before `git commit` for significant changes | ||
| - Before `gh pr create` | ||
| - After addressing bot review comments | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Review Bot Comments | ||
|
|
||
| Systematically address PR review comments from Copilot, Gemini, and CodeQL. | ||
|
|
||
| ## Usage | ||
|
|
||
| `/review-bot-comments [pr-number]` | ||
|
|
||
| ## Process | ||
|
|
||
| ### 1. Fetch Comments | ||
| ```bash | ||
| gh api repos/joshsmithxrm/ppds-sdk/pulls/[PR]/comments | ||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| ### 2. Triage Each Comment | ||
|
|
||
| For each bot comment, determine: | ||
|
|
||
| | Verdict | Action | | ||
| |---------|--------| | ||
| | **Valid** | Fix the issue, reply "Fixed in [commit]" | | ||
| | **False Positive** | Reply with reason, dismiss | | ||
| | **Unclear** | Investigate before deciding | | ||
|
|
||
| ### 3. Common False Positives | ||
|
|
||
| | Bot Claim | Why It's Often Wrong | | ||
| |-----------|---------------------| | ||
| | "Use .Where() instead of foreach+if" | Preference, not correctness | | ||
| | "Volatile needed with Interlocked" | Interlocked provides barriers | | ||
| | "OR should be AND" | Logic may be intentionally inverted (DeMorgan) | | ||
| | "Static field not thread-safe" | May be set once at startup | | ||
|
|
||
| ### 4. Common Valid Findings | ||
|
|
||
| | Pattern | Usually Valid | | ||
| |---------|---------------| | ||
| | Unused variable/parameter | Yes - dead code | | ||
| | Missing null check | Check context | | ||
| | Resource not disposed | Yes - leak | | ||
| | Generic catch clause | Context-dependent | | ||
|
|
||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ## Output | ||
|
|
||
| ```markdown | ||
| ## Bot Review Triage - PR #82 | ||
|
|
||
| | # | Bot | Finding | Verdict | Action | | ||
| |---|-----|---------|---------|--------| | ||
| | 1 | Gemini | Use constants in dict | Valid | Fixed in abc123 | | ||
| | 2 | Copilot | Add validation tests | Valid | Fixed in def456 | | ||
| | 3 | Copilot | Use .Where() | False Positive | Style preference | | ||
| | 4 | CodeQL | Generic catch | Valid (low) | Acceptable for disposal | | ||
|
|
||
| All findings addressed: Yes | ||
| ``` | ||
|
|
||
| ## When to Use | ||
|
|
||
| - After opening a PR (before requesting review) | ||
| - After new bot comments appear | ||
| - Before merging | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| Pre-commit validation hook for PPDS SDK. | ||
| Runs dotnet build and test before allowing git commit. | ||
| """ | ||
| import json | ||
| import shlex | ||
| import subprocess | ||
| import sys | ||
| import os | ||
|
|
||
| def main(): | ||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| try: | ||
| input_data = json.load(sys.stdin) | ||
| except json.JSONDecodeError: | ||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print("⚠️ pre-commit-validate: Failed to parse input. Skipping validation.", file=sys.stderr) | ||
| sys.exit(0) | ||
|
|
||
| tool_name = input_data.get("tool_name", "") | ||
| tool_input = input_data.get("tool_input", {}) | ||
| command = tool_input.get("command", "") | ||
|
|
||
| # Only validate git commit commands (robust check using shlex) | ||
| if tool_name != "Bash": | ||
| sys.exit(0) | ||
| try: | ||
| parts = shlex.split(command) | ||
| is_git_commit = len(parts) >= 2 and os.path.basename(parts[0]) == "git" and parts[1] == "commit" | ||
| except ValueError: | ||
| is_git_commit = False | ||
| if not is_git_commit: | ||
| sys.exit(0) # Allow non-commit commands | ||
|
|
||
| # Get project directory | ||
| project_dir = os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd()) | ||
|
|
||
| try: | ||
| # Run dotnet build | ||
| print("Running pre-commit validation...", file=sys.stderr) | ||
| build_result = subprocess.run( | ||
| ["dotnet", "build", "-c", "Release", "--nologo", "-v", "q"], | ||
| cwd=project_dir, | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=300 # 5 minute timeout | ||
| ) | ||
|
|
||
| if build_result.returncode != 0: | ||
| print("❌ Build failed. Fix errors before committing:", file=sys.stderr) | ||
| if build_result.stdout: | ||
| print(build_result.stdout, file=sys.stderr) | ||
| if build_result.stderr: | ||
| print(build_result.stderr, file=sys.stderr) | ||
| sys.exit(2) # Block commit | ||
|
|
||
| # Run dotnet test (unit tests only - integration tests run on PR) | ||
| test_result = subprocess.run( | ||
| ["dotnet", "test", "--no-build", "-c", "Release", "--nologo", "-v", "q", | ||
| "--filter", "Category!=Integration"], | ||
| cwd=project_dir, | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=300 # 5 minute timeout | ||
| ) | ||
|
|
||
| if test_result.returncode != 0: | ||
| print("❌ Unit tests failed. Fix before committing:", file=sys.stderr) | ||
| if test_result.stdout: | ||
| print(test_result.stdout, file=sys.stderr) | ||
| if test_result.stderr: | ||
| print(test_result.stderr, file=sys.stderr) | ||
| sys.exit(2) # Block commit | ||
|
|
||
| print("✅ Build and unit tests passed", file=sys.stderr) | ||
| sys.exit(0) # Allow commit | ||
|
|
||
| except FileNotFoundError: | ||
| print("⚠️ pre-commit-validate: dotnet not found in PATH. Skipping validation.", file=sys.stderr) | ||
| sys.exit(0) | ||
| except subprocess.TimeoutExpired: | ||
| print("⚠️ pre-commit-validate: Build/test timed out after 5 minutes. Skipping validation.", file=sys.stderr) | ||
| sys.exit(0) | ||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "hooks": { | ||
| "PreToolUse": [ | ||
| { | ||
| "matcher": "Bash", | ||
| "hooks": [ | ||
| { | ||
| "type": "command", | ||
| "command": "python \"$CLAUDE_PROJECT_DIR/.claude/hooks/pre-commit-validate.py\"", | ||
| "timeout": 120 | ||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| ] | ||
| } | ||
| ] | ||
joshsmithxrm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.