Skip to content

Commit 7d57c32

Browse files
authored
Merge pull request #1 from Ty-Robb/feat/gstack-init-brownfield
feat(init): /gstack init command for brownfield onboarding
2 parents 1717ed2 + 11d69ed commit 7d57c32

5 files changed

Lines changed: 98 additions & 1 deletion

File tree

bin/gstack-check-duplicates

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
echo "=== Recent Open Pull Requests ==="
4+
if command -v gh >/dev/null 2>&1; then
5+
gh pr list --state open --limit 10 || echo "(Failed to fetch PRs. Are you logged in with 'gh auth login'?)"
6+
else
7+
echo "(GitHub CLI 'gh' not installed. Skipping PR check.)"
8+
fi
9+
10+
echo ""
11+
echo "=== Recent Open Issues ==="
12+
if command -v gh >/dev/null 2>&1; then
13+
gh issue list --state open --limit 10 || echo "(Failed to fetch Issues. Are you logged in with 'gh auth login'?)"
14+
else
15+
echo "(GitHub CLI 'gh' not installed. Skipping Issue check.)"
16+
fi

init/SKILL.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
description: Onboard an existing project to gstack in one command.
3+
---
4+
5+
# /gstack init
6+
7+
You are the `init` skill for gstack. Your job is to onboard an existing project (Greenfield or Brownfield) by auto-detecting its stack, inspecting build/test/CI configuration to find the correct commands, generating a `.gstack.json` file, and scaffolding a default review checklist if one is missing.
8+
9+
Follow these steps precisely:
10+
11+
1. **Pre-flight Checks**
12+
- Check if you are currently executing inside a gstack installation directory itself (e.g., if `./setup` and `browse/src/cli.ts` exist relative to the root). If you are, abort and tell the user they cannot run `/gstack init` on gstack itself.
13+
- Look for an existing `.gstack.json` in the current project root directory. If it exists, use the `AskUserQuestion` tool to ask the user if they want to overwrite it or partially update it. If they decline, abort.
14+
15+
2. **Auto-detect Stack from Project Files**
16+
- Look at the files in the current root directory (`package.json`, `Gemfile`, `go.mod`, `Cargo.toml`, `pyproject.toml`, `build.gradle`, etc.).
17+
- Identify the primary language and framework. For monorepos, multiple stacks can match; pick the root or dominant one.
18+
19+
3. **Inspect Actual Commands**
20+
- Examine the configuration files from the detected stack to determine the correct test and build/eval commands.
21+
- For Node.js/TypeScript: Check `package.json` for `scripts.test`, `scripts.build`, etc.
22+
- For Ruby on Rails: Look for `bin/test` or `rspec` in `Gemfile`.
23+
- For Go: Assume `go test ./...` if `go.mod` is present.
24+
- For Rust: Assume `cargo test` if `Cargo.toml` is present.
25+
- For Python: Look at `pyproject.toml` or `tox.ini` for `pytest` or `tox`.
26+
- **Crucial step**: Search for CI configuration files (e.g., `.github/workflows/*.yml` or `.gitlab-ci.yml`) to see exactly how tests are run in CI. Extract those commands if they are robust, as CI is the ground truth.
27+
28+
4. **Generate `.gstack.json`**
29+
- Present the detected test and eval commands to the user using the `AskUserQuestion` tool to confirm before writing them.
30+
- Once confirmed (or adjusted by the user), generate the `.gstack.json` file in the current root directory using the following schema (include `evalCommand` as `null` if none, and an empty array for `evalPatterns` if none):
31+
```json
32+
{
33+
"testCommand": "<detected or user-supplied command>",
34+
"evalCommand": "<detected or null>",
35+
"evalPatterns": [],
36+
"reviewChecklist": ".claude/skills/review/checklist.md"
37+
}
38+
```
39+
40+
5. **Scaffold Review Checklist if Missing**
41+
- Check if `.claude/skills/review/checklist.md` exists in the current project.
42+
- If it does NOT exist, create the directory `.claude/skills/review/` if necessary.
43+
- Read the universal default checklist from the gstack installation at `.claude/skills/gstack/review/checklists/default.md`.
44+
- Write the exact contents of that file to `.claude/skills/review/checklist.md` in the current project.
45+
46+
6. **Summary Output**
47+
- Output a short, helpful summary of what was detected and created (e.g., ".gstack.json created", "checklist.md scaffolded").
48+
- Conclude by telling the user: "You are now ready to use gstack! Use `/review` to review your code, and `/ship` to ship it."

plan-ceo-review/SKILL.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,12 @@ Never skip Step 0, the system audit, the error/rescue map, or the failure modes
6565
## PRE-REVIEW SYSTEM AUDIT (before Step 0)
6666
Before doing anything else, run a system audit. This is not the plan review — it is the context you need to review the plan intelligently.
6767
Run the following commands:
68-
```
68+
```bash
6969
git log --oneline -30 # Recent history
7070
git diff main --stat # What's already changed
7171
git stash list # Any stashed work
7272
grep -r "TODO\|FIXME\|HACK\|XXX" --include="*.rb" --include="*.js" -l
73+
~/.claude/skills/gstack/bin/gstack-check-duplicates # Check for existing PRs and Issues
7374
find . -name "*.rb" -newer Gemfile.lock | head -20 # Recently touched files
7475
```
7576
Then read CLAUDE.md, TODOS.md, and any existing architecture docs. Map:

plan-eng-review/SKILL.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ If you are running low on context or the user asks you to compress: Step 0 > Tes
4444

4545
## BEFORE YOU START:
4646

47+
### PRE-REVIEW SYSTEM AUDIT (before Step 0)
48+
Run this command to check for existing Pull Requests and Issues:
49+
```bash
50+
~/.claude/skills/gstack/bin/gstack-check-duplicates
51+
```
52+
Check the output to ensure this plan does not duplicate work that is already being handled elsewhere.
53+
4754
### Step 0: Scope Challenge
4855
Before reviewing anything, answer these questions:
4956
1. **What existing code already partially or fully solves each sub-problem?** Can we capture outputs from existing flows rather than building parallel ones?

review/checklists/default.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Default Review Checklist
2+
3+
This project hasn't yet defined a custom checklist. These are the default universal safety and quality checks applied to all projects. Feel free to modify this file to capture project-specific context.
4+
5+
## Pass 1: Critical Issues
6+
7+
Please verify the following critically. Any issues found here MUST result in blocking the review and a change request.
8+
9+
- **SQL Injection**: Parameterized queries must be used. No string formatting into SQL.
10+
- **Trust Boundaries**: Inputs from users or external APIs must be validated and sanitized.
11+
- **Error Handling**: No uncaught exceptions. Critical paths must return or throw explicitly handling the error.
12+
- **Concurrency**: Operations on shared state must be protected (e.g., race conditions, TOCTOU).
13+
- **Secrets**: No hardcoded credentials or API keys; must use environment variables.
14+
15+
## Pass 2: Informational Issues
16+
17+
These issues are worth raising, but typically are not blocking (unless egregious).
18+
19+
- **Dead Code**: Remove any dead code, unused imports, or lingering debug statements (`console.log`, `print()`, etc.).
20+
- **Consistency**: The code matches the surrounding style and idioms of the project.
21+
- **Test Gaps**: Note missing coverage for significantly complex logic.
22+
23+
## Suppressions
24+
25+
If there is a valid reason to bypass a check (e.g., an explicit disable comment), do not flag it.

0 commit comments

Comments
 (0)