@chris1807/claude-kit 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +821 -0
  3. package/bin/cli.js +521 -0
  4. package/package.json +50 -0
  5. package/templates/agents/global/api-tester.md +75 -0
  6. package/templates/agents/global/azure-ops.md +59 -0
  7. package/templates/agents/global/backend.md +245 -0
  8. package/templates/agents/global/build-validator.md +50 -0
  9. package/templates/agents/global/frontend.md +254 -0
  10. package/templates/agents/global/legacy.md +218 -0
  11. package/templates/agents/global/lint-checker.md +86 -0
  12. package/templates/agents/global/manager.md +138 -0
  13. package/templates/agents/global/mockup.md +95 -0
  14. package/templates/agents/global/reviewer.md +149 -0
  15. package/templates/agents/global/security-auditor.md +74 -0
  16. package/templates/agents/global/test-runner.md +98 -0
  17. package/templates/agents/global/uat-generator.md +107 -0
  18. package/templates/agents/project/db-admin.md +106 -0
  19. package/templates/agents/project/deployer.md +113 -0
  20. package/templates/agents/project/devops-tracker.md +101 -0
  21. package/templates/commands/add-to-release.md +55 -0
  22. package/templates/commands/cherry-pick.md +96 -0
  23. package/templates/commands/cleanup-branches.md +73 -0
  24. package/templates/commands/create-release.md +65 -0
  25. package/templates/commands/deploy-release.md +147 -0
  26. package/templates/commands/deploy.md +65 -0
  27. package/templates/commands/explain.md +49 -0
  28. package/templates/commands/implement.md +170 -0
  29. package/templates/commands/promote.md +71 -0
  30. package/templates/commands/quote.md +39 -0
  31. package/templates/commands/review.md +32 -0
  32. package/templates/commands/rework.md +158 -0
  33. package/templates/commands/rollback.md +106 -0
  34. package/templates/commands/status.md +111 -0
  35. package/templates/hooks/auto-format.sh +46 -0
  36. package/templates/hooks/protected-files.sh +52 -0
  37. package/templates/hooks/secret-blocker.sh +68 -0
  38. package/templates/hooks/self-improve.sh +7 -0
  39. package/templates/hooks/sensitive-data-blocker.sh +43 -0
  40. package/templates/hooks/sensitive-data-mcp-blocker.sh +40 -0
  41. package/templates/hooks/sensitive-data-output-blocker.sh +63 -0
  42. package/templates/hooks/test-on-change.sh +46 -0
  43. package/templates/hooks/uat-reminder.sh +9 -0
  44. package/templates/infrastructure/CLAUDE-WORKFLOW.md +274 -0
  45. package/templates/infrastructure/azure-pipelines-template.yml +199 -0
  46. package/templates/infrastructure/mcp.json +35 -0
  47. package/templates/infrastructure/settings.json +94 -0
@@ -0,0 +1,71 @@
1
+ Promote all code from one environment to the next. Usage: `/promote [source] [target]`
2
+
3
+ Parse `$ARGUMENTS` to extract:
4
+ - **Source environment**: optional (e.g., "develop", "staging"). If omitted, auto-detect.
5
+ - **Target environment**: optional. If omitted, use the next environment in the promotion flow.
6
+
7
+ ## Step 1: Determine Source and Target
8
+
9
+ If not specified, auto-detect based on the current branch:
10
+
11
+ | Current Branch | Source | Target |
12
+ |---|---|---|
13
+ | `develop` | develop | staging |
14
+ | `staging` | staging | production branch |
15
+
16
+ If both are specified (e.g., `/promote staging production`), use those directly.
17
+
18
+ Determine the actual branch names — do NOT hardcode. Check the project's CLAUDE.md or use `git branch -r` to find matching environment branches.
19
+
20
+ ## Step 2: Show What Will Be Promoted
21
+
22
+ Compare the source and target branches to show what's new:
23
+
24
+ ```bash
25
+ git log <target-branch>..<source-branch> --oneline
26
+ ```
27
+
28
+ Present the changes:
29
+
30
+ ```
31
+ ## Promote {source} → {target}
32
+
33
+ Commits to promote:
34
+ | Commit | Message | Work Item |
35
+ |--------|---------|-----------|
36
+ | abc1234 | Add payment export | AB#1234 |
37
+ | def5678 | Fix login redirect | AB#1235 |
38
+ | ghi9012 | Update dashboard | AB#1236 |
39
+
40
+ {count} commits will be promoted from {source} to {target}.
41
+ Promote? (yes/no)
42
+ ```
43
+
44
+ If there are no new commits, report that the environments are already in sync.
45
+
46
+ Wait for confirmation.
47
+
48
+ ## Step 3: Create PR
49
+
50
+ Create a PR directly from the source branch to the target branch via Azure DevOps MCP:
51
+
52
+ - **sourceRefName**: `refs/heads/<source-branch>`
53
+ - **targetRefName**: `refs/heads/<target-branch>`
54
+ - **title**: `Promote {source} → {target}`
55
+ - **description**: List all commits and associated work items being promoted
56
+
57
+ Link any associated work items to the PR.
58
+
59
+ ## Step 4: Present Summary
60
+
61
+ ```
62
+ Promotion PR created: {source} → {target}
63
+
64
+ PR: {pr-url}
65
+
66
+ {count} commits included.
67
+ Merge the PR to trigger the CD pipeline for {target}.
68
+ Remember to update work item states in Azure DevOps after merge.
69
+ ```
70
+
71
+ Do NOT merge the PR automatically — the user or a reviewer must approve and merge.
@@ -0,0 +1,39 @@
1
+ Fetch a work item and display it as a formatted quote block. Usage: `/quote <work-item-id>`
2
+
3
+ Parse `$ARGUMENTS` to extract the work item ID. Accept formats like `AB#1234`, `#1234`, or just `1234`.
4
+
5
+ ## Step 1: Fetch the Work Item
6
+
7
+ Read the work item from Azure DevOps using the project from the current repo's CLAUDE.md configuration. Expand with `relations` to include child items and links.
8
+
9
+ If the work item is not found, report the error and stop.
10
+
11
+ ## Step 2: Display the Quote
12
+
13
+ Format the work item as a quote block:
14
+
15
+ ```
16
+ > **AB#{id}: {title}**
17
+ > **Type:** {type} | **State:** {state} | **Assigned To:** {assignedTo}
18
+ >
19
+ > {description text, stripped of HTML tags, truncated to ~500 chars if long}
20
+ >
21
+ > **Acceptance Criteria:**
22
+ > {acceptance criteria, stripped of HTML tags, truncated to ~500 chars if long}
23
+ ```
24
+
25
+ - Strip all HTML tags from description and acceptance criteria fields, preserving line breaks as `> ` prefixed lines
26
+ - If description or acceptance criteria is empty, omit that section
27
+ - If the work item has child items, append:
28
+
29
+ ```
30
+ >
31
+ > **Child Items:** {count}
32
+ > | ID | Title | State |
33
+ > |----|-------|-------|
34
+ > | AB#{id} | {title} | {state} |
35
+ ```
36
+
37
+ - If the work item has tags, include them: `> **Tags:** {comma-separated tags}`
38
+
39
+ That's it — just display the quote. Do not modify anything.
@@ -0,0 +1,32 @@
1
+ Review PR #$ARGUMENTS in the current project. Automatically:
2
+
3
+ 1. **Read the full diff** — understand every change in the PR
4
+ 2. **Read the linked work item** and verify all acceptance criteria are met
5
+ 3. **Review for:**
6
+ - Clean Architecture boundaries (Domain has no infrastructure dependencies)
7
+ - Tenant/organizationId enforcement on all database queries
8
+ - Missing unit or integration tests for new code
9
+ - `any` types in TypeScript (should be properly typed)
10
+ - Security issues (OWASP Top 10, hardcoded secrets, SQL/NoSQL injection)
11
+ - Error handling (are exceptions caught appropriately?)
12
+ - Naming conventions and code style consistency
13
+ - Breaking changes or backwards compatibility issues
14
+ 4. **Post inline comments** on all findings directly on the PR
15
+ 5. **Post a PR-level summary comment** with:
16
+ - Overall assessment (ready to merge / needs changes)
17
+ - Count of issues by severity (critical / warning / suggestion)
18
+ - Acceptance criteria checklist (met / not met / not applicable)
19
+ - Test coverage assessment
20
+
21
+ Then ask me:
22
+ ```
23
+ Review complete. Summary:
24
+ - X critical issues
25
+ - Y warnings
26
+ - Z suggestions
27
+ - Acceptance criteria: A/B met
28
+
29
+ Approve, Request Changes, or skip the vote?
30
+ ```
31
+
32
+ Wait for my response before submitting any vote on the PR.
@@ -0,0 +1,158 @@
1
+ Rework work item AB#$ARGUMENTS based on feedback received after the last pull request. Follow this workflow:
2
+
3
+ ## Step 1: Find the Latest Pull Request
4
+
5
+ Handle `$ARGUMENTS` as either `1234` or `AB#1234` — strip the `AB#` prefix when calling the MCP API.
6
+
7
+ Find the most recent PR linked to this work item:
8
+
9
+ 1. Read the work item via MCP and note its **relations** — look for pull request artifact links
10
+ 2. For each linked PR, fetch its details via `repo_get_pull_request_by_id` and record the **creationDate**
11
+ 3. Identify the **most recent PR** by creation date — this is the baseline for detecting new feedback
12
+
13
+ Save the PR's `creationDate` as `LAST_PR_DATE` — everything after this timestamp is new feedback.
14
+
15
+ ## Step 2: Gather Rework Feedback
16
+
17
+ ### New Comments
18
+
19
+ Read the work item comments via `wit_list_work_item_comments`. Filter to only comments created **after** `LAST_PR_DATE`. These contain the rework feedback.
20
+
21
+ For each new comment, check for embedded images (`<img>` tags with `src` URLs pointing to Azure DevOps attachments). **Download and view every embedded image** using WebFetch — they often contain screenshots of bugs, visual issues, or annotated UI showing what needs to change.
22
+
23
+ ### Description & Acceptance Criteria Changes
24
+
25
+ Read the work item revisions via `wit_list_work_item_revisions`. Check if the **description** or **acceptance criteria** fields were modified **after** `LAST_PR_DATE`.
26
+
27
+ - If changed: extract the **current** description and acceptance criteria, and note what was added or modified
28
+ - If unchanged: still read the current description and acceptance criteria — a comment may reference something that was in the original requirements but missing from the implementation
29
+
30
+ ### Always Re-read Requirements
31
+
32
+ Regardless of whether description/acceptance criteria changed, **always read the full current description and acceptance criteria**. Rework comments often say things like "the original requirement for X is missing" without the description itself changing. You need the full context to understand what the feedback is referring to.
33
+
34
+ ## Step 3: Summarize Rework and Confirm
35
+
36
+ Present a summary of the rework feedback to the user:
37
+
38
+ ```
39
+ ## Rework for AB#{id}: {title}
40
+
41
+ **Last PR:** #{pr_id} (created {date})
42
+ **New comments:** {count}
43
+
44
+ ### Rework Feedback
45
+ {summarized feedback from new comments — numbered list}
46
+
47
+ ### Requirement Changes (if any)
48
+ {description/acceptance criteria changes since last PR, or "No changes to description or acceptance criteria since last PR"}
49
+
50
+ ### Current Acceptance Criteria
51
+ {full acceptance criteria — numbered list, highlight any that the feedback suggests are not yet met}
52
+
53
+ Does this capture the rework correctly? Do you have any additional context?
54
+ ```
55
+
56
+ **Wait for the user to respond.** Do NOT proceed until the user confirms or provides additional context. If they add context, incorporate it into the plan.
57
+
58
+ ## Step 4: Explore & Plan
59
+
60
+ 1. **Explore** the codebase to map relevant files — focus on files changed in the last PR and any new areas needed
61
+ 2. **Plan** the rework approach
62
+
63
+ Present the plan to the user:
64
+
65
+ ```
66
+ ## Rework Plan for AB#{id}
67
+
68
+ ### Approach
69
+ {brief description of what needs to change to address the feedback}
70
+
71
+ ### Files to Create
72
+ - `path/to/new/file.cs` — {purpose}
73
+ - `path/to/new/file.tsx` — {purpose}
74
+
75
+ ### Files to Modify
76
+ - `path/to/existing/file.cs` — {what changes and why}
77
+ - `path/to/existing/file.tsx` — {what changes and why}
78
+
79
+ ### Files to Delete (if any)
80
+ - `path/to/old/file.cs` — {why it's being removed}
81
+
82
+ ### Agents
83
+ - **backend**: {what it will do}
84
+ - **frontend**: {what it will do}
85
+
86
+ ### Risks / Considerations
87
+ - {any potential issues or trade-offs}
88
+
89
+ Approve this plan? (yes / no / suggest changes)
90
+ ```
91
+
92
+ **Wait for the user to approve the plan.** Do NOT start implementation until the user approves. If they suggest changes, revise the plan and present it again.
93
+
94
+ ## Step 5: Switch to Existing Branch
95
+
96
+ The work item already has a branch from the previous PR. Switch to it:
97
+
98
+ 1. Get the source branch name from the most recent PR
99
+ 2. Switch to that branch: `git checkout <branch-name>`
100
+ 3. Pull the latest: `git pull`
101
+
102
+ If the PR was completed/merged and the branch was deleted, create a new branch from the PR's target branch following the same naming convention as `/implement` Step 4.
103
+
104
+ ## Step 6: Implement
105
+
106
+ 1. **Implement** the rework using backend and/or frontend agents according to the approved plan
107
+ 2. **Generate mockup** if there are UI changes
108
+
109
+ ## Step 7: Build Validation
110
+
111
+ Run a build check **before** any other quality checks. Use the `build-validator` agent to verify that all projects compile successfully.
112
+
113
+ - If the build fails, **fix the errors immediately** and re-run until the build passes
114
+ - Do NOT proceed to review, tests, or lint until the build is clean
115
+
116
+ ## Step 8: Quality Checks
117
+
118
+ 1. **Review** code for quality, security, and Clean Architecture compliance
119
+ 2. **Run tests** — unit, integration, and build validation
120
+ 3. **Run lint** — ESLint and dotnet format
121
+
122
+ ## Step 9: UAT Gate
123
+
124
+ ### If Hot Fix:
125
+ Skip manual UAT. Present an abbreviated confirmation:
126
+
127
+ ```
128
+ Rework complete. All automated checks passed.
129
+
130
+ Push changes? (yes/no)
131
+ ```
132
+
133
+ Wait for confirmation before proceeding.
134
+
135
+ ### If Feature, User Story, Bug, or other:
136
+ Generate a UAT checklist from the acceptance criteria and present:
137
+
138
+ ```
139
+ Automated checks passed and the UAT checklist is ready.
140
+
141
+ ## UAT Checklist
142
+ [generated checklist here — highlight items specific to the rework feedback]
143
+
144
+ Please manually test the rework using the checklist above.
145
+
146
+ Did manual testing pass?
147
+ - If YES → reply "testing passed" and I will push the changes
148
+ - If NO → describe what failed or what behaved unexpectedly
149
+ and I will investigate and fix before asking you again
150
+ ```
151
+
152
+ Wait for the user's response before proceeding. Do NOT push until confirmed.
153
+
154
+ ## Step 10: Push and Update
155
+
156
+ 1. Push the changes: `git push`
157
+ 2. Add a comment on the existing PR summarizing what was changed in the rework
158
+ 3. Update the work item status in Azure DevOps if needed
@@ -0,0 +1,106 @@
1
+ Roll back a deployment in an environment. Usage: `/rollback <work-item-ids-or-commit> <environment>`
2
+
3
+ Parse `$ARGUMENTS` to extract:
4
+ - **What to revert**: work item IDs (e.g., "AB#1234") or commit hashes, or "last" for the most recent deployment
5
+ - **Target environment**: the environment to roll back (e.g., "staging", "production")
6
+
7
+ ## Step 1: Identify What to Revert
8
+
9
+ Determine the target environment branch. Do NOT hardcode branch names.
10
+
11
+ If the user specified:
12
+ - **Work item IDs**: Find the associated commits on the environment branch using `repo_search_commits` with `includeWorkItems: true`
13
+ - **Commit hashes**: Use those directly
14
+ - **"last"**: Find the most recent merge commit on the environment branch via `git log --merges -1 <branch>`
15
+
16
+ Present the revert plan:
17
+
18
+ ```
19
+ ## Rollback on {environment}
20
+
21
+ Commits to revert:
22
+ | Commit | Message | Work Item |
23
+ |--------|---------|-----------|
24
+ | abc1234 | Add payment export | AB#1234 |
25
+ | def5678 | Fix login redirect | AB#1235 |
26
+
27
+ This will revert {count} commit(s) on {environment}. Proceed? (yes/no)
28
+ ```
29
+
30
+ Wait for confirmation.
31
+
32
+ ## Step 2: Create Revert Branch
33
+
34
+ ```bash
35
+ git checkout <target-environment-branch>
36
+ git pull origin <target-environment-branch>
37
+ git checkout -b revert/<date>-on-<environment>
38
+ ```
39
+
40
+ ## Step 3: Revert Commits
41
+
42
+ Revert each commit in reverse chronological order (newest first):
43
+
44
+ ```bash
45
+ git revert --no-commit <commit-hash>
46
+ ```
47
+
48
+ After all reverts are staged, create a single commit:
49
+
50
+ ```bash
51
+ git commit -m "$(cat <<'EOF'
52
+ Revert AB#1234, AB#1235 on {environment}
53
+
54
+ Reverted commits:
55
+ - abc1234: Add payment export
56
+ - def5678: Fix login redirect
57
+
58
+ Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59
+ EOF
60
+ )"
61
+ ```
62
+
63
+ ## Step 4: Verify
64
+
65
+ Run pre-flight checks on the reverted code:
66
+ 1. `dotnet build` on any .NET projects
67
+ 2. `npx tsc --noEmit` on any frontend projects
68
+ 3. If either fails, STOP and report — the revert may have introduced inconsistencies
69
+
70
+ ## Step 5: Push and Create PR
71
+
72
+ 1. Push: `git push -u origin HEAD`
73
+ 2. Create a PR via Azure DevOps MCP:
74
+ - **sourceRefName**: `refs/heads/revert/<date>-on-<environment>`
75
+ - **targetRefName**: `refs/heads/<target-environment-branch>`
76
+ - **title**: `Rollback: Revert AB#1234, AB#1235 on {Environment}`
77
+ - **description**: List reverted commits and reason
78
+ 3. Link work items to the PR
79
+
80
+ ## Step 6: Present Summary
81
+
82
+ ```
83
+ Rollback PR created for {environment}.
84
+
85
+ PR: {pr-url}
86
+ Reverted:
87
+ - AB#1234: Add payment export
88
+ - AB#1235: Fix login redirect
89
+
90
+ Merge the PR to trigger the CD pipeline and deploy the rollback.
91
+ ```
92
+
93
+ For production rollbacks, flag urgency to the user.
94
+
95
+ ## Step 7: Notify Team (if Teams MCP is configured)
96
+
97
+ Send a notification to the project's Teams channel via the Microsoft Teams MCP server:
98
+
99
+ ```
100
+ ⚠️ Rollback PR created for {environment}
101
+ PR: {pr-url}
102
+ Reverting: AB#1234, AB#1235
103
+ Awaiting review and merge.
104
+ ```
105
+
106
+ For production rollbacks, mark the message as urgent. If the Teams MCP server is not configured, skip this step silently.
@@ -0,0 +1,111 @@
1
+ Check the status of a release, pipeline, or work item. Usage: `/status <target>`
2
+
3
+ Parse `$ARGUMENTS` to determine what to check:
4
+ - **Release**: "release 24" or "r24" → show release status
5
+ - **Pipeline**: "pipeline" or "build" → show recent pipeline runs
6
+ - **Work item**: "AB#1234" or "1234" → show work item status
7
+ - **Environment**: "staging" or "production" → show what's deployed
8
+ - **No argument**: show an overview of everything
9
+
10
+ ## If Release (e.g., `/status release 24`):
11
+
12
+ Query all work items tagged `release-{N}` or in the `Release #{N}` iteration.
13
+
14
+ ```
15
+ ## Release #24 Status
16
+
17
+ | ID | Type | Title | State | Environment |
18
+ |----|------|-------|-------|-------------|
19
+ | AB#4521 | User Story | Add payment export | Closed | Production |
20
+ | AB#4522 | User Story | Bulk approval workflow | Ready for Testing | Staging |
21
+ | AB#4530 | User Story | Dashboard trends | Ready for Testing | Staging |
22
+ | AB#4589 | Bug | Login plus sign fix | Closed | Production |
23
+
24
+ Deployed to:
25
+ - Dev: All 4 items
26
+ - Staging: All 4 items
27
+ - Production: 2 of 4 items (AB#4521, AB#4589)
28
+ ```
29
+
30
+ ## If Pipeline (e.g., `/status pipeline` or `/status build`):
31
+
32
+ Check the project's CLAUDE.md for pipeline configuration. Query recent builds for each pipeline.
33
+
34
+ ```
35
+ ## Recent Pipeline Runs
36
+
37
+ | Pipeline | Branch | Status | Time | Build # |
38
+ |----------|--------|--------|------|---------|
39
+ | Compass API | main | Succeeded | 2026-03-22 14:26 | 20260322.1 |
40
+ | Compass Client | main | Succeeded | 2026-03-22 14:27 | 20260322.1 |
41
+ | Compass API | develop | Succeeded | 2026-03-21 10:15 | 20260321.3 |
42
+ ```
43
+
44
+ ## If Work Item (e.g., `/status AB#4521`):
45
+
46
+ Read the work item from Azure DevOps and show its full status.
47
+
48
+ ```
49
+ ## AB#4521: Admin Can Export Payment History to CSV
50
+
51
+ **Type:** User Story
52
+ **State:** Ready for Testing
53
+ **Assigned To:** Chris Waters
54
+ **Release:** Release #24
55
+ **Branch:** story/AB#4521-admin-can-export-payment-history
56
+ **PR:** #287 (merged to develop)
57
+
58
+ ### Linked PRs
59
+ - PR #287 → develop (merged 2026-03-20)
60
+ - PR #291 → staging (merged 2026-03-21)
61
+
62
+ ### Child Tasks
63
+ | ID | Title | State |
64
+ |----|-------|-------|
65
+ | AB#4525 | Add export API endpoint | Closed |
66
+ | AB#4526 | Add CSV service | Closed |
67
+ | AB#4527 | Add export button UI | Closed |
68
+ ```
69
+
70
+ ## If Environment (e.g., `/status staging`):
71
+
72
+ Check the project's CLAUDE.md for the environment branch mapping. Show the last deployment and what's currently deployed.
73
+
74
+ ```
75
+ ## Staging Environment
76
+
77
+ **Branch:** staging
78
+ **Last deployment:** 2026-03-21 15:30 (Build #20260321.2)
79
+ **Pipeline:** Compass API — Succeeded
80
+
81
+ ### Recent merges to staging:
82
+ | Commit | Message | Date |
83
+ |--------|---------|------|
84
+ | a1b2c3d | Release #24 → Staging | 2026-03-21 |
85
+ | d4e5f6a | Cherry-pick AB#4601 | 2026-03-22 |
86
+ ```
87
+
88
+ ## If No Argument (e.g., `/status`):
89
+
90
+ Show a high-level overview.
91
+
92
+ ```
93
+ ## Project Status
94
+
95
+ ### Active Releases
96
+ | Release | Work Items | Latest Environment |
97
+ |---------|-----------|-------------------|
98
+ | Release #24 | 6 items | Staging |
99
+ | Release #23 | 4 items | Production |
100
+
101
+ ### Recent Pipelines
102
+ | Pipeline | Last Run | Status |
103
+ |----------|----------|--------|
104
+ | Compass API | 20260322.1 | Succeeded |
105
+ | Compass Client | 20260322.1 | Succeeded |
106
+
107
+ ### Open PRs
108
+ | PR # | Title | Target |
109
+ |------|-------|--------|
110
+ | #292 | AB#4601: Fix bulk approval | develop |
111
+ ```
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # Auto-Format Hook (PostToolUse - Edit/Write)
3
+ # Runs the appropriate formatter on files after they're modified.
4
+
5
+ INPUT=$(cat)
6
+
7
+ # Extract the file path
8
+ FILE_PATH=$(echo "$INPUT" | python3 -c "
9
+ import sys, json
10
+ try:
11
+ data = json.load(sys.stdin)
12
+ inp = data.get('tool_input', {})
13
+ print(inp.get('file_path', ''))
14
+ except:
15
+ pass
16
+ " 2>/dev/null)
17
+
18
+ if [ -z "$FILE_PATH" ]; then
19
+ exit 0
20
+ fi
21
+
22
+ # Get file extension
23
+ EXT="${FILE_PATH##*.}"
24
+
25
+ case "$EXT" in
26
+ cs)
27
+ # .NET files — run dotnet format on the file (quiet, no restore)
28
+ PROJECT_DIR=$(echo "$FILE_PATH" | grep -oE '.*/src/[^/]+/')
29
+ if [ -n "$PROJECT_DIR" ] && [ -f "${PROJECT_DIR}*.csproj" ] 2>/dev/null; then
30
+ dotnet format "$PROJECT_DIR" --include "$FILE_PATH" --no-restore --verbosity quiet 2>/dev/null
31
+ fi
32
+ ;;
33
+ ts|tsx|js|jsx)
34
+ # TypeScript/JavaScript — find nearest node_modules and run eslint fix
35
+ DIR=$(dirname "$FILE_PATH")
36
+ while [ "$DIR" != "/" ]; do
37
+ if [ -f "$DIR/node_modules/.bin/eslint" ]; then
38
+ "$DIR/node_modules/.bin/eslint" --fix --quiet "$FILE_PATH" 2>/dev/null
39
+ break
40
+ fi
41
+ DIR=$(dirname "$DIR")
42
+ done
43
+ ;;
44
+ esac
45
+
46
+ exit 0
@@ -0,0 +1,52 @@
1
+ #!/bin/bash
2
+ # Protected Files Guard (PreToolUse - Edit/Write)
3
+ # Warns before modifying critical files. Exit code 2 = BLOCK.
4
+
5
+ INPUT=$(cat)
6
+
7
+ # Extract the file path
8
+ FILE_PATH=$(echo "$INPUT" | python3 -c "
9
+ import sys, json
10
+ try:
11
+ data = json.load(sys.stdin)
12
+ inp = data.get('tool_input', {})
13
+ print(inp.get('file_path', ''))
14
+ except:
15
+ pass
16
+ " 2>/dev/null)
17
+
18
+ if [ -z "$FILE_PATH" ]; then
19
+ exit 0
20
+ fi
21
+
22
+ # Files that should never be modified without explicit intent
23
+ BLOCKED_FILES=(
24
+ "appsettings.Production.json"
25
+ "appsettings.Staging.json"
26
+ )
27
+
28
+ for blocked in "${BLOCKED_FILES[@]}"; do
29
+ if echo "$FILE_PATH" | grep -q "$blocked"; then
30
+ echo "BLOCKED: Cannot modify production/staging config: $blocked"
31
+ echo "If you need to change production settings, do it in Azure App Configuration or Key Vault."
32
+ exit 2
33
+ fi
34
+ done
35
+
36
+ # Files that trigger a warning (but allow the edit)
37
+ WARN_FILES=(
38
+ "CLAUDE.md"
39
+ ".gitignore"
40
+ "azure-pipelines.yml"
41
+ "staticwebapp.config.json"
42
+ "Program.cs"
43
+ "DependencyInjection.cs"
44
+ )
45
+
46
+ for warn in "${WARN_FILES[@]}"; do
47
+ if echo "$FILE_PATH" | grep -q "$warn"; then
48
+ echo "WARNING: Modifying critical file: $warn — make sure this change is intentional."
49
+ fi
50
+ done
51
+
52
+ exit 0
@@ -0,0 +1,68 @@
1
+ #!/bin/bash
2
+ # Secret Blocker Hook (PreToolUse - Write/Edit)
3
+ # Blocks file writes that contain hardcoded secrets, API keys, or credentials.
4
+ # Exit code 2 = BLOCK the action.
5
+
6
+ # Read the tool input from stdin
7
+ INPUT=$(cat)
8
+
9
+ # Extract the file content being written (new_string for Edit, content for Write)
10
+ CONTENT=$(echo "$INPUT" | python3 -c "
11
+ import sys, json
12
+ try:
13
+ data = json.load(sys.stdin)
14
+ tool = data.get('tool_name', '')
15
+ inp = data.get('tool_input', {})
16
+ if tool == 'Write':
17
+ print(inp.get('content', ''))
18
+ elif tool == 'Edit':
19
+ print(inp.get('new_string', ''))
20
+ except:
21
+ pass
22
+ " 2>/dev/null)
23
+
24
+ if [ -z "$CONTENT" ]; then
25
+ exit 0
26
+ fi
27
+
28
+ # Patterns that indicate hardcoded secrets
29
+ BLOCKED=false
30
+ REASON=""
31
+
32
+ # MongoDB connection strings with credentials
33
+ if echo "$CONTENT" | grep -qE 'mongodb\+srv://[^$\{]+:[^$\{]+@'; then
34
+ BLOCKED=true
35
+ REASON="Hardcoded MongoDB connection string with credentials"
36
+ fi
37
+
38
+ # AWS keys
39
+ if echo "$CONTENT" | grep -qE 'AKIA[0-9A-Z]{16}'; then
40
+ BLOCKED=true
41
+ REASON="AWS access key detected"
42
+ fi
43
+
44
+ # Stripe secret keys (not env var references)
45
+ if echo "$CONTENT" | grep -qE 'sk_live_[a-zA-Z0-9]{20,}'; then
46
+ BLOCKED=true
47
+ REASON="Stripe live secret key detected"
48
+ fi
49
+
50
+ # Private keys
51
+ if echo "$CONTENT" | grep -qE 'BEGIN (RSA |EC |DSA )?PRIVATE KEY'; then
52
+ BLOCKED=true
53
+ REASON="Private key detected"
54
+ fi
55
+
56
+ # Generic password assignments (but not placeholder patterns)
57
+ if echo "$CONTENT" | grep -qiE '"(password|secret|apikey|api_key|token)"\s*:\s*"[^$\{\}][^"]{8,}"' | grep -vqE 'Admin123!|Test123|placeholder|your-.*-here|xxx'; then
58
+ BLOCKED=true
59
+ REASON="Possible hardcoded credential"
60
+ fi
61
+
62
+ if [ "$BLOCKED" = true ]; then
63
+ echo "BLOCKED: $REASON"
64
+ echo "Use environment variables or Azure Key Vault instead of hardcoding secrets."
65
+ exit 2
66
+ fi
67
+
68
+ exit 0
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ # Self-Improvement Hook
3
+ # Fires on Stop to remind Claude to save learnings from the session.
4
+ # This creates a feedback loop where each session makes the next one better.
5
+
6
+ echo "📝 Before ending: Did you learn anything new about Chris's preferences, project decisions, or workflow patterns? If so, save it to memory (feedback or project type)."
7
+ echo "📋 Check if project_current_priorities.md needs updating based on work completed this session."