cortexhawk 3.1.1 → 3.3.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.
@@ -0,0 +1,21 @@
1
+ # .cortexhawk-lint.yml — per-project lint-guard config (optional)
2
+ # Copy to .cortexhawk-lint.yml to override defaults.
3
+ # By default, all tools are auto-detected via their config files.
4
+ # Set a tool to false to disable it even if its config file is present.
5
+
6
+ formatters:
7
+ prettier: true # .prettierrc* / prettier.config.* / package.json "prettier"
8
+ black: true # pyproject.toml [tool.black]
9
+ gofmt: true # active if .go files staged (no config file required)
10
+ rustfmt: true # rustfmt.toml / .rustfmt.toml
11
+ stylelint: true # .stylelintrc* / stylelint.config.*
12
+
13
+ linters:
14
+ eslint: true # .eslintrc* / eslint.config.*
15
+ flake8: true # .flake8 / setup.cfg [flake8]
16
+ mypy: false # pyproject.toml [tool.mypy] / mypy.ini — set to false to disable (can be slow)
17
+
18
+ options:
19
+ run_on_push: false # run on git push too (overrides LINT_ON_PUSH in git-workflow.conf)
20
+ fail_on_formatter: false # block commit if a formatter fails (default: non-blocking)
21
+ timeout: 30 # max seconds per tool (requires timeout/gtimeout in PATH)
package/.gitmessage ADDED
@@ -0,0 +1,10 @@
1
+
2
+ # type(scope): subject
3
+ #
4
+ # Types: feat, fix, docs, style, refactor, test, chore, perf, security
5
+ # Scope: optional module/component name
6
+ # Subject: imperative mood, lowercase, no period, max 72 chars
7
+ #
8
+ # Body: explain WHY, not WHAT (the diff shows the what)
9
+ #
10
+ # Footer: BREAKING CHANGE: description | Closes #123 | Backlog #N
package/CHANGELOG.md CHANGED
@@ -3,12 +3,57 @@
3
3
  All notable changes to CortexHawk are documented here.
4
4
  Format: [Keep a Changelog](https://keepachangelog.com/)
5
5
 
6
- ## [3.1.1] - 2026-02-15
6
+ ## [Unreleased]
7
+
8
+ ## [3.3.0] - 2026-02-19
9
+
10
+ ### Added
11
+ - `lint-guard` Phase 3 performance: linters run in parallel (`&` + `wait` + tmpdir error signaling); detection results cached in `.claude/lint-guard-cache` (1hr TTL, safe key=value); hook extracted to `scripts/lint-guard-runner.sh` to stay within 150-line limit (#142)
12
+ - `lint-guard` advanced YAML options: `timeout` (per-tool kill with `timeout`/`gtimeout`, default 30s), `fail_on_formatter` (block commit on formatter failure, default false), `run_on_push` in yml (overrides git-workflow.conf) (#141)
13
+ - `lint-guard` pre-commit delegation: if `.pre-commit-config.yaml` + `pre-commit` CLI are present, lint-guard delegates entirely to the framework — no duplication for projects already using pre-commit (#143)
14
+ - `lint-guard` hook (PreToolUse): auto-detects formatters and linters on staged files before commit — formatters auto-fix + re-stage (prettier, black, gofmt, rustfmt, stylelint), linters check-only + block on errors (eslint, flake8, mypy); opt-out via `LINT_SKIP` in `git-workflow.conf` or `.cortexhawk-lint.yml` (#140)
15
+ - `/review-pr` command: fetch, triage, and address PR review comments — batch mode by default (one commit + one batched review reply = one notification); `--sequential` flag for complex interdependent threads (#145)
16
+ - MCP GitHub config: `mcp/github.json` (`@modelcontextprotocol/server-github`) — unlocks native GitHub API for `git-manager`, `/ship`, `pr-review-comments`, `/review-pr`; listed as recommended in fullstack + api profiles (#146)
17
+ - `/cleanup` command: delete merged local/remote branches, optional post-merge hook for auto-cleanup after PR merges (#139)
18
+ - Smart PR detection in `/ship`: reuses existing PR branch instead of creating duplicate branches when iterating with `/task` followed by review feedback (#138)
19
+
20
+ ### Fixed
21
+ - `branch-guard` hook: `git push --delete` (remote branch deletion) was incorrectly blocked when on a protected branch — `/cleanup` remote cleanup now works correctly
22
+ - `post-merge-cleanup.sh`: auto-detects missing TTY (`[ ! -t 0 ]`) and switches to auto mode — `/cleanup` called via Claude Bash tool or CI no longer hangs on `read` prompt
23
+ - `.gitignore`: add `docs/.context/` and `docs/.metrics/` — auto-generated session artifacts (snapshots, analytics logs, agent context) are ephemeral and should not be committed
24
+ - GitHub Actions (`claude.yml`, `claude-code-review.yml`): grant `pull-requests: write` + `issues: write` — Claude could read PRs but not post reviews or replies
25
+ - **Security (MEDIUM)**: replace predictable PID/timestamp temp paths with `mktemp` (portable, no `.json` suffix) in `autodetect-profile.sh` and `interactive-init.sh`
26
+ - **Security (MEDIUM)**: extend `.env` parser blocklist (`PYTHONPATH`, `GIT_SSH_COMMAND`, `NPM_CONFIG_*`, `NODE_OPTIONS`, `RUBYLIB`, `LD_AUDIT`, etc.) + add key format validation (`^[A-Z_][A-Z0-9_]{0,63}$`) to reject malformed variable names
27
+ - **Security (LOW)**: atomic `cache_set` in `lint-guard-runner.sh` via `mktemp` unique tmp + `mv` — eliminates race condition on concurrent hook invocations
28
+ - **Security**: replace `eval` with `xargs -0` in `lint-guard-runner.sh` — prevents command injection via crafted filenames in staged file lists
29
+
30
+ ## [3.2.0] - 2026-02-15
31
+
32
+ ### Added
33
+ - Component registry: `COMPONENTS` array + `copy_all_components`/`sync_all_components`/`count_component_files` — adding a new component is 1 line instead of modifying 5 functions
34
+ - `/commit` command: lightweight conventional commit + push without review or PR — use `/ship` for full workflow, `/commit` for quick iterations
35
+ - Install auto-detects existing PR/commit templates; generates CortexHawk defaults (`.github/PULL_REQUEST_TEMPLATE.md`, `.gitmessage`) if missing — agents (`git-manager`, `/ship`, `/commit`) read templates at runtime
36
+ - `--version` / `-v` flag: displays CortexHawk version
37
+ - `scripts/refresh-context.sh`: regenerates `docs/.context/_shared.md` mid-session — `/task` and `/backlog` auto-refresh after modifying backlog
7
38
 
8
39
  ### Fixed
9
40
  - `branch-guard` / `commit-guard` hooks: JSON parsing via `jq` with regex fallback — fixes false "hook error" on commands containing quotes or HEREDOC
10
41
  - `commit-guard`: multi-format commit message extraction (HEREDOC, single/double quotes)
11
42
  - `file-guard`: match on basename only — `*secret*`/`*credentials*` no longer false-positive on legitimate files (e.g., `oauth_service.py`); `.env.example`/`.env.sample`/`.env.template` whitelisted; `docker-compose*.yml` unblocked
43
+ - **Security**: eliminate shell injection in all Python HEREDOC/inline scripts — `$hooks_json`, file paths, and user input no longer interpolated into Python source; uses `sys.argv`/`sys.stdin` instead. Hook names validated against path traversal, hook paths shell-escaped via `shlex.quote()`
44
+ - Portable `sed -i` via `sed_inplace()` helper — fixes `sed` failures on macOS (BSD) across snapshot, hook toggle, and init wizard
45
+ - Argument validation for `--target`, `--profile`, and `--restore` flags — prevents cryptic shell errors when value is missing
46
+ - `update_gitignore()` now ensures essential entries (`.env`, `node_modules/`, `dist/`, etc.) are present — previously only added `.claude/` to an existing `.gitignore`
47
+ - Warning when python3 is not found — `generate_hooks_config()` previously failed silently, now alerts user that static fallback is used
48
+ - `.env` parser now strips single quotes, inline comments, and trailing whitespace — previously only stripped double quotes
49
+ - `--init` wizard now supports "All" and "Auto-detect" targets — removed false `--target all/auto` + `--init` guards, scope step auto-selects local for multi-target
50
+ - Snapshot no longer reads stale `/tmp/cortexhawk-custom-*.json` from previous runs — uses `$PROFILE_FILE` from current session only
51
+ - `copy_skills()` now warns when a skill from the profile doesn't exist in source — previously silently skipped
52
+ - Removed `local` keyword used outside function in `--target auto` dispatcher — fixes portability issues
53
+ - `.gitignore` no longer duplicates `# CortexHawk` header with `--target all` — groups all target dirs under single header
54
+ - `SKILL_COUNT` no longer shows 1 when no skills detected — fixed `wc -l` on empty string in `autodetect-profile.sh`
55
+ - `_shared.md` now includes generation timestamp for staleness awareness
56
+ - `settings.json` now merges on reinstall instead of skipping — new hooks regenerated from compose.yml, new permissions added via union (user customizations preserved). `--update` also merges new permissions
12
57
 
13
58
  ## [3.1.0] - 2026-02-14
14
59
 
package/CLAUDE.md CHANGED
@@ -6,13 +6,13 @@ Open-source development toolkit for Claude Code — optimized agents, skills, co
6
6
 
7
7
  ```
8
8
  agents/ — 20 specialized AI agents
9
- commands/ — 32 slash commands
9
+ commands/ — 35 slash commands
10
10
  scripts/ — Validation and post-install audit scripts
11
11
  skills/ — 36 domain-specific knowledge modules
12
- hooks/ — 9 lifecycle hooks
12
+ hooks/ — 11 lifecycle hooks
13
13
  modes/ — 7 behavioral presets
14
14
  profiles/ — 3 install profiles (fullstack, api, data)
15
- mcp/ — Pre-configured MCP server configs
15
+ mcp/ — Pre-configured MCP server configs (github, context7, sequential-thinking, puppeteer)
16
16
  docs/ — Agent outputs (brainstorms, plans, decisions, research, audits, conversations, chains)
17
17
  templates/ — Templates for contributing new components (agents, commands, skills, chain presets, personas)
18
18
  CONTRIBUTING.md — Contribution guidelines
@@ -49,7 +49,7 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
49
49
 
50
50
  ## Commands
51
51
 
52
- `/plan` `/build` `/test` `/review` `/ship` `/debug` `/scan` `/check` `/refactor` `/research` `/doc` `/bootstrap` `/tdd` `/optimize` `/migrate` `/monitor` `/api-gen` `/changelog` `/journal` `/brainstorm` `/simplify` `/deploy` `/export` `/backlog` `/pulse` `/map` `/learn` `/chain` `/task` `/ci` `/context` `/upgrade`
52
+ `/plan` `/build` `/test` `/review` `/review-pr` `/ship` `/commit` `/cleanup` `/debug` `/scan` `/check` `/refactor` `/research` `/doc` `/bootstrap` `/tdd` `/optimize` `/migrate` `/monitor` `/api-gen` `/changelog` `/journal` `/brainstorm` `/simplify` `/deploy` `/export` `/backlog` `/pulse` `/map` `/learn` `/chain` `/task` `/ci` `/context` `/upgrade`
53
53
 
54
54
  ## Skills
55
55
 
@@ -80,6 +80,7 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
80
80
  - `file-guard` (PreToolUse) — Blocks access to .env, secrets, keys
81
81
  - `branch-guard` (PreToolUse) — Prevents direct push to protected branches
82
82
  - `commit-guard` (PreToolUse) — Validates conventional commits, checks staged secrets
83
+ - `lint-guard` (PreToolUse) — Auto-detects formatters/linters on staged files; auto-fix for prettier/black/gofmt/rustfmt/stylelint, check-only for eslint/flake8/mypy
83
84
  - `self-review` (PostToolUse) — Checks for TODO/FIXME, secrets, debug artifacts
84
85
  - `dependency-check` (PostToolUse) — Alerts when dependency files are modified
85
86
  - `test-reminder` (PostToolUse) — Reminds to update tests for modified source files
@@ -94,3 +95,10 @@ Custom agents in `.cortexhawk-agents/` at project root. Each `.md` file uses `ex
94
95
  - Checklists > paragraphs, code examples > prose
95
96
  - One responsibility per component
96
97
  - All agents follow: frontmatter → description → Process → Output Format → Rules
98
+
99
+ ## Git Workflow
100
+
101
+ - **Branching**: dev-branch (working branch: dev)
102
+ - **Commits**: conventional
103
+ - **PR preference**: on-demand
104
+ - **Auto-push**: after-commit
package/README.md CHANGED
@@ -2,22 +2,35 @@
2
2
 
3
3
  [![GitHub stars](https://img.shields.io/github/stars/Spechawk94/CortexHawk?style=flat-square)](https://github.com/Spechawk94/CortexHawk/stargazers)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](LICENSE)
5
- [![Version](https://img.shields.io/badge/version-3.1.0-green.svg?style=flat-square)](CHANGELOG.md)
5
+ [![Version](https://img.shields.io/badge/version-3.2.0-green.svg?style=flat-square)](CHANGELOG.md)
6
6
  [![npm](https://img.shields.io/npm/v/cortexhawk?style=flat-square&color=red)](https://www.npmjs.com/package/cortexhawk)
7
7
  [![Skills](https://img.shields.io/badge/skills-36%20built--in%20%7C%2087k%2B%20via%20SkillsMP-orange.svg?style=flat-square)](https://skillsmp.com)
8
- [![Components](https://img.shields.io/badge/20%20agents%20%7C%2032%20commands%20%7C%209%20hooks%20%7C%207%20modes-purple.svg?style=flat-square)](#whats-inside)
8
+ [![Components](https://img.shields.io/badge/20%20agents%20%7C%2033%20commands%20%7C%209%20hooks%20%7C%207%20modes-purple.svg?style=flat-square)](#whats-inside)
9
9
 
10
10
  An open-source, community-driven development toolkit for Claude Code.
11
11
 
12
12
  CortexHawk provides a modular collection of optimized agents, skills, commands, hooks, and behavioral modes that transform Claude Code into a full-stack development team. Every prompt has been written for maximum efficiency — less token bloat, sharper instructions, better agent coordination.
13
13
 
14
- ### What's New in v3.1
14
+ ### What's New in v3.2
15
+
16
+ - **`/commit` command** — lightweight conventional commit + push without review or PR (use `/ship` for full workflow)
17
+ - **`--version` flag** — standard CLI version display
18
+ - **PR/commit templates** — auto-detected at install, generated if missing; agents read templates at runtime
19
+ - **Settings.json merge** — reinstall and `--update` now merge new hooks + permissions instead of skipping
20
+ - **Security hardening** — eliminated shell injection in all Python HEREDOC scripts, portable `sed -i`, input validation
21
+ - **`--init` wizard** — "Auto-detect" target option, improved multi-target support
22
+ - **15+ bug fixes** — see [CHANGELOG.md](CHANGELOG.md) for full details
23
+
24
+ <details>
25
+ <summary>v3.1 changes</summary>
15
26
 
16
27
  - **`npm install -g cortexhawk`** — available on npm, auto-resolves source from symlinked binary
17
28
  - **`cortexhawk` CLI wrapper** — clean subcommands (init, install, update, doctor, validate, search, snapshot, etc.) instead of `bash install.sh --flags`
18
29
  - **`--target auto`** — auto-detects installed CLIs (claude, kimi, codex) and installs for all found
19
30
  - **`cortexhawk validate`** — post-install diagnostic verifying skills/agents discovery per target
20
31
 
32
+ </details>
33
+
21
34
  <details>
22
35
  <summary>v3.0 changes</summary>
23
36
 
@@ -103,7 +116,7 @@ Specialized AI agents that coordinate together instead of working in silos.
103
116
  | `fullstack-developer` | Full-stack orchestration front+back |
104
117
  | `teacher` | Teaches concepts with 3 pedagogical levels (guided, mentor, professor) |
105
118
 
106
- ### Commands (32)
119
+ ### Commands (33)
107
120
 
108
121
  Slash commands for common workflows.
109
122
 
@@ -114,6 +127,7 @@ Slash commands for common workflows.
114
127
  | `/test` | Generate and run tests |
115
128
  | `/review` | Multi-agent code review |
116
129
  | `/ship` | Commit + PR pipeline |
130
+ | `/commit` | Lightweight commit + push (no review, no PR) |
117
131
  | `/debug` | Debug and fix issues |
118
132
  | `/scan` | Full security audit |
119
133
  | `/check` | Pre-commit quality gate (lint + test + scan + review → GO/NO-GO) |
@@ -313,7 +327,7 @@ Each target adapts components to the CLI's native format:
313
327
  | Component | Claude Code | Kimi CLI | Codex CLI |
314
328
  |---|---|---|---|
315
329
  | Agents (20) | `.claude/agents/*.md` | Skills (`/skill:agent-*`) + `AGENTS.md` | `AGENTS.md` |
316
- | Commands (32) | `.claude/commands/*.md` → `/plan` | Skills (`/skill:cmd-*`) | Skills (`$cmd-*`) |
330
+ | Commands (33) | `.claude/commands/*.md` → `/plan` | Skills (`/skill:cmd-*`) | Skills (`$cmd-*`) |
317
331
  | Skills (36) | `.claude/skills/` | `.kimi/skills/` (auto-discovered) | `.agents/skills/` |
318
332
  | Hooks (9) | `settings.json` (automatic) | Skills (`/skill:hook-*`, manual) | Dispatcher (partial) |
319
333
  | Modes (7) | `.claude/modes/` (native) | Skills (`/skill:modes/*`) | Skills (`$mode-*`) |
@@ -335,6 +349,7 @@ Each target adapts components to the CLI's native format:
335
349
  ./install.sh --update --dry-run # preview update delta
336
350
 
337
351
  # Diagnostics
352
+ ./install.sh --version # show CortexHawk version
338
353
  ./install.sh --doctor # check installation health
339
354
  ./install.sh --test-hooks # dry-run all hooks with synthetic inputs
340
355
  ./install.sh --stats # installation overview (version, counts)
@@ -11,9 +11,10 @@ You are a release engineer managing version control workflows.
11
11
 
12
12
  0. **Context** — Read `docs/.context/_shared.md` and `docs/.context/git-manager.md`
13
13
  1. **Assess** — Review current branch state, staged changes, and recent history
14
+ 1.5. **Detect PR** — Run `gh pr view --json state,url 2>/dev/null`, parse output; if PR exists with state=OPEN, note branch has active PR (skip creation later); if gh fails or no PR, proceed normally
14
15
  2. **Stage** — Select files for commit, verify no secrets or debug artifacts
15
16
  3. **Commit** — Generate conventional commit message matching change scope
16
- 4. **Push** — Push to remote, create PR with description and checklist
17
+ 4. **Push** — Push to remote, create PR with description and checklist (skip if active PR detected in step 1.5)
17
18
  5. **Manage** — Handle branching, tagging, merging, and release prep
18
19
 
19
20
  ## Commit Convention
@@ -49,6 +50,10 @@ Description: imperative mood, lowercase, no period, max 72 chars
49
50
  - Checklist: tests pass, no warnings, docs updated
50
51
  ```
51
52
 
53
+ ## Templates
54
+ - Before creating a PR, check for `.github/PULL_REQUEST_TEMPLATE.md` — if found, follow that format
55
+ - Before committing, check for `.gitmessage` — if found, follow that format for the commit message
56
+
52
57
  ## Rules
53
58
  - Atomic commits — one logical change per commit
54
59
  - Never force-push to shared branches
@@ -59,5 +64,8 @@ Description: imperative mood, lowercase, no period, max 72 chars
59
64
  - Always verify no secrets in staged files before commit
60
65
  - Read `## Git Workflow` in CLAUDE.md for project preferences (branching, commits, PRs, auto-push)
61
66
  - Respect configured branching strategy, PR preference, and auto-push behavior
62
- - If no Git Workflow section, default to: feature branches, conventional commits, on-demand PR, auto-push
67
+ - If no Git Workflow section and no `.claude/config/git-workflow.conf`, default to: feature branches, conventional commits, on-demand PR, auto-push
68
+ - Before creating a feature branch, check if current branch has open PR — if yes, reuse branch and push to update PR; if no or state!=OPEN, create new branch
69
+ - PR detection edge cases: gh CLI not installed (skip detection, proceed with branch creation), detached HEAD (skip detection, create new branch), gh fails (silent fail with warning, continue with branch creation), no remote configured (warn and stop)
70
+ - Silent fail on PR detection errors — log warning to user, continue with normal branch creation flow
63
71
  - Update `docs/.context/git-manager.md` with patterns, decisions, and key files discovered
@@ -12,6 +12,7 @@ Activate the **project-manager** agent in backlog mode.
12
12
  3. Score: impact (H/M/L), effort (H/M/L), feasibility (H/M/L)
13
13
  4. Update `docs/backlog.md` — add new items, re-prioritize existing ones
14
14
  5. Mark items already implemented as done
15
+ 6. Run `bash .claude/scripts/refresh-context.sh` to update shared context
15
16
 
16
17
  Backlog format in `docs/backlog.md`:
17
18
 
@@ -0,0 +1,36 @@
1
+ ---
2
+ name: cleanup
3
+ description: Delete merged branches and optionally enable auto-cleanup hook
4
+ ---
5
+
6
+ # /cleanup
7
+
8
+ Delete merged local branches and optionally delete remote branches.
9
+
10
+ ## Process
11
+
12
+ 1. Check if `.claude/.cleanup-configured` exists — if not, prompt for hook opt-in
13
+ 2. If marker missing, ask: "Enable auto-cleanup hook after merging PRs? [y/N]"
14
+ 3. If user chooses yes:
15
+ - Uncomment post-merge composition in `.claude/hooks/compose.yml` via sed
16
+ - Create marker: `echo 'enabled' > .claude/.cleanup-configured`
17
+ - Notify: "Auto-cleanup hook enabled. Runs automatically after git merge."
18
+ 4. If user chooses no:
19
+ - Create marker: `echo 'manual' > .claude/.cleanup-configured`
20
+ 5. Run cleanup script: `.claude/scripts/post-merge-cleanup.sh` (interactive mode)
21
+ 6. Script detects branching strategy from `.claude/git-workflow.conf` or `CLAUDE.md`
22
+ 7. Lists merged branches (excluding main/master/dev/develop/current)
23
+ 8. Prompts before deleting each local branch
24
+ 9. Prompts before deleting each remote branch (default: no)
25
+ 10. If on main branch: pulls latest changes
26
+ 11. If `BRANCHING=feature-branches`: optionally creates new feature branch
27
+
28
+ ## Rules
29
+
30
+ - First-run hook prompt only shows once (marker file persists preference)
31
+ - Remote deletion requires explicit confirmation (default: no)
32
+ - Never delete main/master/dev/develop or current branch
33
+ - Handle missing config files gracefully (fallback to defaults)
34
+ - Handle git errors without crashing (network, permissions, no remote)
35
+ - If compose.yml missing, warn and skip hook enablement
36
+ - If sed fails, report error but continue cleanup
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: commit
3
+ description: Conventional commit and push — lightweight alternative to /ship (no review, no PR).
4
+ ---
5
+
6
+ # /commit
7
+
8
+ Activate the **git-manager** agent. Commit: `$ARGUMENTS`
9
+
10
+ 1. Read `## Git Workflow` from CLAUDE.md if present — respect branching strategy, commit convention, and auto-push settings
11
+ 2. If `.gitmessage` exists, read it for commit message format guidance
12
+ 3. Review staged and unstaged changes, stage relevant files (never `git add -A`)
13
+ 4. Generate conventional commit message from changes — format: `type(scope): description`
14
+ 5. Commit with the generated message
15
+ 6. If auto-push is enabled, push to remote
16
+ 7. Show commit summary (hash, message, files changed)
17
+
18
+ ## Rules
19
+
20
+ - No review pass — use `/ship` for reviewed commits, `/commit` for quick iterations
21
+ - No PR creation — use `/ship` when a PR is needed
22
+ - Respect `.gitignore` — never stage `.env`, secrets, or debug artifacts
23
+ - If no changes to commit, report and stop
24
+ - If `$ARGUMENTS` is provided, use it as commit message context (not the literal message)
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: review-pr
3
+ description: Fetch, triage, and address PR review comments in batch — one commit, one notification.
4
+ ---
5
+
6
+ # /review-pr
7
+
8
+ Activate the **reviewer** agent using the `pr-review-comments` skill. Target PR: current branch.
9
+
10
+ 1. **Auth** — Check MCP GitHub (`mcp__github__list_pull_requests`); fall back to `gh pr view` if unavailable
11
+ 2. **Fetch** — Get all open inline threads, review submissions, and conversation comments
12
+ 3. **Triage** — Group by author: Copilot / human reviewers / bots; skip resolved and outdated
13
+ 4. **Present** — Show numbered threads with `file:line`, author, summary, and proposed fix
14
+ 5. **Confirm** — Ask which to address (`1, 3, 5` or `all`) before touching any file
15
+ 6. **Fix** (batch, default) — Apply all selected fixes in one pass
16
+ 7. **Commit** — `fix: address PR review comments` (single commit)
17
+ 8. **Push** — Push to remote
18
+ 9. **Reply** — `mcp__github__create_pull_request_review` (batch) or `gh pr comment` — one reply per thread, referencing the commit sha
19
+
20
+ ## Flags
21
+
22
+ - `--sequential` — fix → commit → reply per thread; use when comments are complex or interdependent
23
+
24
+ ## Rules
25
+
26
+ - Always present threads and wait for user selection before fixing
27
+ - Batch mode: one commit + one review submission = one notification to reviewers
28
+ - Sequential mode: one commit per thread, reply immediately after each fix
29
+ - Never fix resolved or outdated threads unless explicitly requested
30
+ - If no open threads, report and stop
31
+ - If auth fails, prompt `gh auth login` or check `GITHUB_PERSONAL_ACCESS_TOKEN`
package/commands/ship.md CHANGED
@@ -8,10 +8,11 @@ description: Commit, create PR, and prepare for deployment.
8
8
  Activate the **git-manager** agent, then the **reviewer** agent. Ship: `$ARGUMENTS`
9
9
 
10
10
  0. Read `## Git Workflow` from CLAUDE.md if present — respect PR preference and auto-push settings
11
+ 0.5. Check if current branch has open PR — run `gh pr view --json state,url 2>/dev/null`; if PR exists and state=OPEN, skip branch creation (update existing PR); if gh unavailable or no PR found, proceed with normal flow
11
12
  1. Stage changes and generate conventional commit message
12
13
  2. Run quick review pass — reviewer runs Pass 1 (Correctness) and Pass 2 (Security) only, reporting Critical findings exclusively
13
14
  3. If review passes, commit and push
14
- 4. Create PR with description, testing notes, and checklist
15
+ 4. Create PR if `.github/PULL_REQUEST_TEMPLATE.md` exists, follow that format; otherwise use: Summary, Changes, Test Plan, Checklist
15
16
  5. If review finds critical issues, report them and stop — don't ship broken code
16
17
 
17
18
  Format: `feat(scope): description` or `fix(scope): description`
package/commands/task.md CHANGED
@@ -16,6 +16,7 @@ Activate the **project-manager** agent as orchestrator. Execute backlog item `$A
16
16
  6. Update `CHANGELOG.md` with a one-line entry under the current version's `### Added` section
17
17
  7. If chain completes without critical blockers, execute `/ship`
18
18
  8. Mark item as `done` in backlog
19
+ 9. Run `bash .claude/scripts/refresh-context.sh` to update shared context
19
20
 
20
21
  ## Save Rules
21
22
 
package/cortexhawk CHANGED
@@ -120,8 +120,8 @@ do_validate() {
120
120
 
121
121
  # settings.json
122
122
  if [ -f "$target_dir/settings.json" ]; then
123
- if python3 -c "import json; json.load(open('$target_dir/settings.json'))" 2>/dev/null || \
124
- node -e "JSON.parse(require('fs').readFileSync('$target_dir/settings.json'))" 2>/dev/null; then
123
+ if python3 -c "import json,sys; json.load(open(sys.argv[1]))" "$target_dir/settings.json" 2>/dev/null || \
124
+ node -e "JSON.parse(require('fs').readFileSync(process.argv[1]))" "$target_dir/settings.json" 2>/dev/null; then
125
125
  check "settings.json valid JSON" "ok"
126
126
  else
127
127
  check "settings.json invalid JSON" "fail"
@@ -21,17 +21,25 @@ fi
21
21
 
22
22
  PROTECTED_BRANCHES=("main" "master" "production" "release")
23
23
 
24
- # Load git workflow config — allow direct-main push if configured
24
+ # Load git workflow config — adjust protected branches based on branching strategy
25
25
  CONF_FILE="$(git rev-parse --show-toplevel 2>/dev/null)/.claude/git-workflow.conf"
26
26
  if [[ -f "$CONF_FILE" ]]; then
27
27
  _BRANCHING=$(grep '^BRANCHING=' "$CONF_FILE" | cut -d= -f2)
28
28
  if [[ "$_BRANCHING" == "direct-main" ]]; then
29
29
  PROTECTED_BRANCHES=("master" "production" "release")
30
+ elif [[ "$_BRANCHING" == "dev-branch" ]]; then
31
+ _WORK_BRANCH=$(grep '^WORK_BRANCH=' "$CONF_FILE" | cut -d= -f2)
32
+ [[ -n "$_WORK_BRANCH" ]] && PROTECTED_BRANCHES+=("$_WORK_BRANCH")
30
33
  fi
31
34
  fi
32
35
 
33
36
  # Check for git push to protected branches
34
37
  if echo "$CMD" | grep -qE 'git\s+push'; then
38
+ # Allow --delete operations (deleting remote branches, not pushing code)
39
+ if echo "$CMD" | grep -qE 'git\s+push\s+.*--delete|git\s+push\s+.*-d\s'; then
40
+ exit 0
41
+ fi
42
+
35
43
  CURRENT_BRANCH=$(git branch --show-current 2>/dev/null)
36
44
 
37
45
  for branch in "${PROTECTED_BRANCHES[@]}"; do
package/hooks/compose.yml CHANGED
@@ -45,3 +45,9 @@ compositions:
45
45
  matcher: "*"
46
46
  hooks:
47
47
  - session-telemetry
48
+
49
+ # post-merge:
50
+ # event: GitHook
51
+ # matcher: "post-merge"
52
+ # hooks:
53
+ # - post-merge
@@ -9,12 +9,16 @@ BLOCKED_PATTERNS=(
9
9
  "*.key"
10
10
  "id_rsa"
11
11
  "id_ed25519"
12
+ "id_ecdsa"
12
13
  "*.p12"
13
14
  "*.pfx"
14
15
  "*.keystore"
16
+ "*.jks"
15
17
  "credentials.json"
16
18
  "credentials.yml"
17
19
  "credentials.yaml"
20
+ "*secret*"
21
+ "service-account*.json"
18
22
  )
19
23
 
20
24
  # Basename patterns that are .env.* but NOT .env.example/.env.sample/.env.template
package/hooks/hooks.json CHANGED
@@ -36,6 +36,12 @@
36
36
  "script": "hooks/commit-guard.sh",
37
37
  "description": "Validates commit format and checks for staged secrets"
38
38
  },
39
+ {
40
+ "name": "lint-guard",
41
+ "type": "PreToolUse",
42
+ "script": "hooks/lint-guard.sh",
43
+ "description": "Auto-detect and run formatters/linters on staged files before commit"
44
+ },
39
45
  {
40
46
  "name": "test-reminder",
41
47
  "type": "PostToolUse",
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # lint-guard — Auto-detect formatters/linters and run before git commit/push
3
+ # Hook type: PreToolUse (Bash)
4
+ # Delegates heavy work to scripts/lint-guard-runner.sh
5
+
6
+ # --- 1. PARSE COMMAND ---
7
+ if [ -n "$CORTEXHAWK_COMMAND" ]; then
8
+ CMD="$CORTEXHAWK_COMMAND"
9
+ else
10
+ INPUT=$(cat)
11
+ if command -v jq &>/dev/null; then
12
+ CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)
13
+ fi
14
+ [ -z "$CMD" ] && CMD=$(printf '%s' "$INPUT" \
15
+ | grep -o '"command" *: *"[^"]*"' | head -1 | sed 's/.*: *"//;s/"$//')
16
+ fi
17
+ [ -z "$CMD" ] && exit 0
18
+ echo "$CMD" | grep -qE 'git\s+(commit|push)' || exit 0
19
+
20
+ # --- 2. PUSH CHECK — yml takes priority over git-workflow.conf ---
21
+ if echo "$CMD" | grep -qE 'git\s+push'; then
22
+ _ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
23
+ _YML_PUSH=$(grep -E "^\s+run_on_push:" "$_ROOT/.cortexhawk-lint.yml" 2>/dev/null \
24
+ | sed 's/.*: *//' | tr -d ' \r')
25
+ if [ "$_YML_PUSH" = "true" ]; then
26
+ :
27
+ elif [ "$_YML_PUSH" = "false" ]; then
28
+ exit 0
29
+ else
30
+ LINT_ON_PUSH=$(grep '^LINT_ON_PUSH=' "$_ROOT/.claude/git-workflow.conf" 2>/dev/null | cut -d= -f2)
31
+ [ "$LINT_ON_PUSH" != "true" ] && exit 0
32
+ fi
33
+ fi
34
+
35
+ # --- 3. DELEGATE ---
36
+ REPO_ROOT=$(git rev-parse --show-toplevel 2>/dev/null)
37
+ [ -z "$REPO_ROOT" ] && exit 0
38
+
39
+ if command -v pre-commit &>/dev/null && [ -f "$REPO_ROOT/.pre-commit-config.yaml" ]; then
40
+ echo "lint-guard: pre-commit detected — delegating to pre-commit framework"
41
+ pre-commit run
42
+ exit $?
43
+ fi
44
+
45
+ bash "$REPO_ROOT/.claude/scripts/lint-guard-runner.sh"
46
+ exit $?
@@ -0,0 +1,12 @@
1
+ #!/bin/bash
2
+ # post-merge — Auto-cleanup merged branches after PR merge
3
+ # Hook type: GitHook
4
+ # Disabled by default — enable via /cleanup first run
5
+
6
+ # Call cleanup script in auto mode (silent, no prompts, skip remote deletion)
7
+ if [ -f ".claude/scripts/post-merge-cleanup.sh" ]; then
8
+ bash ".claude/scripts/post-merge-cleanup.sh" --auto 2>/dev/null || true
9
+ fi
10
+
11
+ # Exit silently — don't block merge operation on script failures
12
+ exit 0
@@ -44,14 +44,17 @@ if [ -d "docs/.context" ] && [ ! -L "docs/.context" ]; then
44
44
 
45
45
  echo "# Shared Context" > "$SHARED"
46
46
  echo "" >> "$SHARED"
47
- echo "_Auto-generated by session-start. Do not edit manually._" >> "$SHARED"
47
+ echo "_Auto-generated at $(date '+%Y-%m-%d %H:%M'). Snapshot from session start may be stale._" >> "$SHARED"
48
48
  echo "" >> "$SHARED"
49
49
 
50
50
  # Backlog summary
51
51
  if [ -f "docs/backlog.md" ]; then
52
- ACTIVE=$(grep -c '| todo |' docs/backlog.md 2>/dev/null || echo 0)
53
- DEFERRED=$(grep -c '| deferred |' docs/backlog.md 2>/dev/null || echo 0)
54
- DONE=$(grep -c '| done |' docs/backlog.md 2>/dev/null || echo 0)
52
+ ACTIVE=$(grep -c '| todo |' docs/backlog.md 2>/dev/null || true)
53
+ : "${ACTIVE:=0}"
54
+ DEFERRED=$(grep -c '| deferred |' docs/backlog.md 2>/dev/null || true)
55
+ : "${DEFERRED:=0}"
56
+ DONE=$(grep -c '| done |' docs/backlog.md 2>/dev/null || true)
57
+ : "${DONE:=0}"
55
58
  echo "## Backlog" >> "$SHARED"
56
59
  echo "- Active: $ACTIVE | Deferred: $DEFERRED | Done: $DONE" >> "$SHARED"
57
60
  # List active items
@@ -129,4 +132,4 @@ if [ -d "$SKILL_DIR" ]; then
129
132
  fi
130
133
 
131
134
  echo ""
132
- echo "Commands: /plan /build /test /review /ship /debug /scan /check /refactor /research /doc /bootstrap /tdd /optimize /migrate /monitor /api-gen /changelog /journal /brainstorm /simplify /deploy /export /backlog /pulse /map /learn /chain /task /ci /context"
135
+ echo "Commands: /plan /build /test /review /ship /commit /cleanup /debug /scan /check /refactor /research /doc /bootstrap /tdd /optimize /migrate /monitor /api-gen /changelog /journal /brainstorm /simplify /deploy /export /backlog /pulse /map /learn /chain /task /ci /context /upgrade"