Skip to content

Commit 11d69ed

Browse files
committed
feat(init): add /gstack init command for brownfield onboarding
The new init skill auto-detects a project's stack (e.g. Node.js, Ruby/Rails, Go, Rust, Python) by inspecting project files like package.json, Gemfile, etc., and extracts test/build commands. It scaffolds a .gstack.json and provides a default review checklist if none exists, enabling a one-command onboarding for any existing project.
1 parent e8c69af commit 11d69ed

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

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."

0 commit comments

Comments
 (0)