polyforgeai 0.1.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.
- package/LICENSE +21 -0
- package/README.md +144 -0
- package/bin/polyforge.js +252 -0
- package/hooks/pre-commit-check.sh +27 -0
- package/hooks/pre-push-verify.sh +45 -0
- package/package.json +46 -0
- package/rules/golden-principles.md +22 -0
- package/rules/security.md +18 -0
- package/rules/testing.md +14 -0
- package/skills/analyse-code/SKILL.md +164 -0
- package/skills/analyse-db/SKILL.md +175 -0
- package/skills/brainstorm/SKILL.md +118 -0
- package/skills/fix/SKILL.md +151 -0
- package/skills/fix-ci/SKILL.md +136 -0
- package/skills/generate-doc/SKILL.md +202 -0
- package/skills/init/SKILL.md +150 -0
- package/skills/pr-review/SKILL.md +141 -0
- package/skills/report-issue/SKILL.md +128 -0
- package/templates/CLAUDE.md.template +26 -0
- package/templates/polyforge.config.json +43 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fix-ci
|
|
3
|
+
description: Use when CI/CD checks fail on a PR or branch, when the user says "CI is broken", "build failed", "tests fail in CI", or "fix the pipeline". Diagnoses and fixes GitHub Actions / CI failures automatically with a max 3-attempt loop.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /fix-ci — CI Failure Auto-Fix
|
|
7
|
+
|
|
8
|
+
You are PolyForge's CI debugging specialist. Diagnose and fix CI failures on the current PR or branch. Loop until checks pass or you hit the retry limit.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
/fix-ci Fix CI on current branch's PR
|
|
14
|
+
/fix-ci #123 Fix CI on PR #123
|
|
15
|
+
/fix-ci --diagnose Diagnose only, don't fix
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Process (Loop — max 3 iterations)
|
|
19
|
+
|
|
20
|
+
### Step 1: Verify GitHub CLI Access
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
gh auth status
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
If not authenticated, stop and ask the user to run `gh auth login`.
|
|
27
|
+
|
|
28
|
+
### Step 2: Get CI Status
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Get all checks for the PR
|
|
32
|
+
gh pr view --json statusCheckRollup --jq '.statusCheckRollup[]'
|
|
33
|
+
|
|
34
|
+
# Alternative: list by branch
|
|
35
|
+
gh pr checks
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
If all checks pass, report success and stop.
|
|
39
|
+
|
|
40
|
+
### Step 3: Inspect Failed Checks
|
|
41
|
+
|
|
42
|
+
For each failed check:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Get run summary
|
|
46
|
+
gh run view <run-id>
|
|
47
|
+
|
|
48
|
+
# Get failed job logs
|
|
49
|
+
gh run view <run-id> --log-failed
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Extract from logs:
|
|
53
|
+
- The first actionable error (often earlier in logs, not the last line)
|
|
54
|
+
- The failing command (`npm test`, `phpstan`, `go vet`, etc.)
|
|
55
|
+
- File paths and line numbers
|
|
56
|
+
- Whether it's code vs config vs environment
|
|
57
|
+
|
|
58
|
+
Categorize the failure:
|
|
59
|
+
- **Build** — compilation, syntax errors
|
|
60
|
+
- **Test** — unit, integration, e2e failures
|
|
61
|
+
- **Lint** — formatting, static analysis
|
|
62
|
+
- **Type** — type checking errors
|
|
63
|
+
- **Security** — dependency vulnerabilities
|
|
64
|
+
- **Config** — CI config, missing env vars, permissions
|
|
65
|
+
|
|
66
|
+
### Step 4: Confirm Root Cause
|
|
67
|
+
|
|
68
|
+
1. Read the failing code locally
|
|
69
|
+
2. Run the failing command locally to reproduce if possible
|
|
70
|
+
3. Check recent commits that might have caused it: `git log --oneline -5`
|
|
71
|
+
4. Form a hypothesis and validate before editing
|
|
72
|
+
|
|
73
|
+
If the failure requires secrets, permissions, or manual intervention — report clearly and stop.
|
|
74
|
+
|
|
75
|
+
### Step 5: Fix
|
|
76
|
+
|
|
77
|
+
1. Make targeted, minimal changes — only what's needed to pass CI
|
|
78
|
+
2. Preserve existing code style
|
|
79
|
+
3. Run the failing command locally to verify the fix
|
|
80
|
+
|
|
81
|
+
### Step 6: Push and Monitor
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
git add <specific files>
|
|
85
|
+
git commit -m "fix(ci): <short description of what was fixed>"
|
|
86
|
+
git push
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Then watch:
|
|
90
|
+
```bash
|
|
91
|
+
gh pr checks --watch
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Step 7: Evaluate
|
|
95
|
+
|
|
96
|
+
- **All checks pass** → go to Final Report
|
|
97
|
+
- **Same failure persists** → re-analyze with new logs, return to Step 3
|
|
98
|
+
- **New failure** → analyze the new failure, return to Step 3
|
|
99
|
+
- **3 attempts reached** → stop, go to Final Report with NEEDS_HUMAN status
|
|
100
|
+
|
|
101
|
+
## Circuit Breaker Rules
|
|
102
|
+
|
|
103
|
+
- **Max 3 fix attempts.** After 3 pushes without all checks passing, stop and report.
|
|
104
|
+
- **Same error twice** with the same fix approach → do not retry the same approach. Try a different angle or report.
|
|
105
|
+
- **Environment/permissions issues** (missing secrets, Docker pull limits, runner issues) → report immediately, these cannot be fixed in code.
|
|
106
|
+
- After 2 failed attempts, compact the conversation before the 3rd try to ensure clean context.
|
|
107
|
+
|
|
108
|
+
## Final Report
|
|
109
|
+
|
|
110
|
+
```markdown
|
|
111
|
+
## CI Fix Summary
|
|
112
|
+
|
|
113
|
+
### Status: RESOLVED | PARTIALLY_RESOLVED | NEEDS_HUMAN
|
|
114
|
+
|
|
115
|
+
### Failures Found
|
|
116
|
+
- {check name}: {failure type} — {root cause}
|
|
117
|
+
|
|
118
|
+
### Fixes Applied
|
|
119
|
+
- `{file}:{line}` — {what was changed and why}
|
|
120
|
+
|
|
121
|
+
### Verification
|
|
122
|
+
- Local: {command} → {pass/fail}
|
|
123
|
+
- CI: {status after push}
|
|
124
|
+
|
|
125
|
+
### Remaining Issues (if any)
|
|
126
|
+
- {what still fails and why it needs human intervention}
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
*⚒ Forged with [PolyForge](https://github.com/Vekta/polyforge)*
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Context Management
|
|
133
|
+
|
|
134
|
+
- Use a subagent to parse large CI logs (>500 lines) — return only errors and context
|
|
135
|
+
- After each fix iteration, keep only: current failure, hypothesis, fix applied
|
|
136
|
+
- After final report, compact the conversation
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: generate-doc
|
|
3
|
+
description: Use when the user asks to generate, update, or refresh project documentation, CLAUDE.md, context files, or scoped rules. Creates Claude-optimized documentation with a short CLAUDE.md (<200 lines), detailed docs/CONTEXT.md, and path-scoped rules.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /generate-doc — Documentation Generator
|
|
7
|
+
|
|
8
|
+
You are PolyForge's documentation generator. You create and maintain documentation optimized for Claude Code to understand the project efficiently.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
/generate-doc Generate all documentation
|
|
14
|
+
/generate-doc --claude-md Only update CLAUDE.md
|
|
15
|
+
/generate-doc --context Only update docs/CONTEXT.md
|
|
16
|
+
/generate-doc --rules Only update .claude/rules/
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## What Gets Generated
|
|
20
|
+
|
|
21
|
+
### 1. `CLAUDE.md` (under 200 lines — strict)
|
|
22
|
+
|
|
23
|
+
The root file Claude Code reads every session. Must be concise and high-signal.
|
|
24
|
+
|
|
25
|
+
Structure:
|
|
26
|
+
```markdown
|
|
27
|
+
# {Project Name}
|
|
28
|
+
|
|
29
|
+
{One-line description}
|
|
30
|
+
|
|
31
|
+
## Stack
|
|
32
|
+
{language} {version} + {framework} {version} + {database}
|
|
33
|
+
|
|
34
|
+
## Commands
|
|
35
|
+
- Build: `{command}`
|
|
36
|
+
- Test: `{command}`
|
|
37
|
+
- Lint: `{command}`
|
|
38
|
+
- Dev server: `{command}`
|
|
39
|
+
|
|
40
|
+
## Architecture
|
|
41
|
+
{3-5 lines describing the architecture pattern and key directories}
|
|
42
|
+
|
|
43
|
+
## Conventions
|
|
44
|
+
- {convention 1 — only what Claude can't infer from code}
|
|
45
|
+
- {convention 2}
|
|
46
|
+
|
|
47
|
+
## Key References
|
|
48
|
+
- Architecture details: @docs/CONTEXT.md
|
|
49
|
+
- Database schema: @docs/DB.md
|
|
50
|
+
- API documentation: @docs/API.md
|
|
51
|
+
|
|
52
|
+
## PolyForge
|
|
53
|
+
Config: `.claude/polyforge.json`
|
|
54
|
+
Commands: /init, /pr-review, /analyse-db, /analyse-code, /report-issue, /fix, /fix-ci, /brainstorm, /generate-doc
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Every line must pass the test: "Would removing this cause Claude to make mistakes?" If no, cut it.
|
|
58
|
+
|
|
59
|
+
### 2. `docs/CONTEXT.md` (detailed, no size limit)
|
|
60
|
+
|
|
61
|
+
The deep reference document. Covers everything Claude might need for complex tasks.
|
|
62
|
+
|
|
63
|
+
Structure:
|
|
64
|
+
```markdown
|
|
65
|
+
# Project Context — {name}
|
|
66
|
+
|
|
67
|
+
> ⚒ Last updated: {date} · Forged with [PolyForge](https://github.com/Vekta/polyforge)
|
|
68
|
+
|
|
69
|
+
## Purpose
|
|
70
|
+
{What this project does, who it's for, 3-5 sentences}
|
|
71
|
+
|
|
72
|
+
## Architecture
|
|
73
|
+
|
|
74
|
+
### Pattern
|
|
75
|
+
{Detailed description: Clean Architecture, DDD, MVC, etc.}
|
|
76
|
+
|
|
77
|
+
### Directory Structure
|
|
78
|
+
```
|
|
79
|
+
{annotated tree of key directories}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Layer Responsibilities
|
|
83
|
+
- **Domain/Entities**: {what goes here}
|
|
84
|
+
- **Use Cases/Services**: {what goes here}
|
|
85
|
+
- **Infrastructure**: {what goes here}
|
|
86
|
+
- **Presentation/Controllers**: {what goes here}
|
|
87
|
+
|
|
88
|
+
## Dependencies
|
|
89
|
+
|
|
90
|
+
### External
|
|
91
|
+
- {dependency}: {why it's used, version}
|
|
92
|
+
|
|
93
|
+
### Internal Repositories
|
|
94
|
+
- {repo}: {relationship, how it's used}
|
|
95
|
+
|
|
96
|
+
## Data Flow
|
|
97
|
+
{How a request flows through the system — entry point to response}
|
|
98
|
+
|
|
99
|
+
## Key Patterns
|
|
100
|
+
- {Pattern 1}: {where and how it's used}
|
|
101
|
+
- {Pattern 2}: {where and how it's used}
|
|
102
|
+
|
|
103
|
+
## Environment
|
|
104
|
+
- Required env vars: {list with descriptions}
|
|
105
|
+
- Docker services: {what runs in docker}
|
|
106
|
+
|
|
107
|
+
## Deployment
|
|
108
|
+
- {How the project is deployed}
|
|
109
|
+
|
|
110
|
+
## Known Quirks
|
|
111
|
+
- {Non-obvious behavior 1}
|
|
112
|
+
- {Non-obvious behavior 2}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### 3. `.claude/rules/` (scoped rules)
|
|
116
|
+
|
|
117
|
+
Generate scoped rule files based on detected stack. Examples:
|
|
118
|
+
|
|
119
|
+
**`.claude/rules/polyforge-backend.md`** (for PHP/Go backend files):
|
|
120
|
+
```markdown
|
|
121
|
+
---
|
|
122
|
+
paths:
|
|
123
|
+
- "src/**/*.php"
|
|
124
|
+
- "internal/**/*.go"
|
|
125
|
+
---
|
|
126
|
+
# Backend Rules
|
|
127
|
+
- Services receive dependencies via constructor injection
|
|
128
|
+
- Repository methods return domain entities, never raw DB rows
|
|
129
|
+
- All public service methods have corresponding test methods
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**`.claude/rules/polyforge-frontend.md`** (for JS/TS frontend files):
|
|
133
|
+
```markdown
|
|
134
|
+
---
|
|
135
|
+
paths:
|
|
136
|
+
- "src/**/*.tsx"
|
|
137
|
+
- "src/**/*.ts"
|
|
138
|
+
---
|
|
139
|
+
# Frontend Rules
|
|
140
|
+
- Components are functional with hooks
|
|
141
|
+
- State management via {detected: Redux/Zustand/Context}
|
|
142
|
+
- All user-facing strings use i18n keys
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**`.claude/rules/polyforge-tests.md`**:
|
|
146
|
+
```markdown
|
|
147
|
+
---
|
|
148
|
+
paths:
|
|
149
|
+
- "tests/**/*"
|
|
150
|
+
- "**/*.test.*"
|
|
151
|
+
- "**/*.spec.*"
|
|
152
|
+
---
|
|
153
|
+
# Testing Rules
|
|
154
|
+
- Test names describe behavior: "it should {expected} when {condition}"
|
|
155
|
+
- Use factories/fixtures for test data, never hardcode
|
|
156
|
+
- Each test is independent — no shared mutable state
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Process
|
|
160
|
+
|
|
161
|
+
### Step 1: Analyze the Project
|
|
162
|
+
|
|
163
|
+
1. Read existing `.claude/polyforge.json` for known context
|
|
164
|
+
2. Scan the full project structure
|
|
165
|
+
3. Read key files: entry points, config files, main modules
|
|
166
|
+
4. Analyze patterns: how dependencies are injected, how errors are handled, how data flows
|
|
167
|
+
5. Check for existing docs to update rather than overwrite
|
|
168
|
+
|
|
169
|
+
### Step 2: Handle Existing Files
|
|
170
|
+
|
|
171
|
+
For each file to generate:
|
|
172
|
+
- If it doesn't exist → create it
|
|
173
|
+
- If it exists and was generated by PolyForge (has the `Forged with PolyForge` marker) → update it
|
|
174
|
+
- If it exists and was NOT generated by PolyForge → ask: "(a) Merge (b) Keep existing, create separate file (c) Replace (backup to tmp/)"
|
|
175
|
+
|
|
176
|
+
### Step 3: Generate and Confirm
|
|
177
|
+
|
|
178
|
+
Show a preview of what will be created/updated:
|
|
179
|
+
```
|
|
180
|
+
Files to create/update:
|
|
181
|
+
+ CLAUDE.md (142 lines)
|
|
182
|
+
+ docs/CONTEXT.md (89 lines)
|
|
183
|
+
+ .claude/rules/polyforge-backend.md (15 lines)
|
|
184
|
+
+ .claude/rules/polyforge-tests.md (12 lines)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Ask: "Generate these files? (y/n/preview {filename})"
|
|
188
|
+
|
|
189
|
+
## Context Management
|
|
190
|
+
|
|
191
|
+
- Delegate codebase scanning for CONTEXT.md to a subagent — the subagent returns a structured summary, the parent formats the final document
|
|
192
|
+
- Scan progressively: directory tree first, then key entry points, then config files
|
|
193
|
+
- After generating all files, compact the conversation
|
|
194
|
+
|
|
195
|
+
## Important Behaviors
|
|
196
|
+
|
|
197
|
+
- CLAUDE.md MUST stay under 200 lines — this is non-negotiable
|
|
198
|
+
- Use `@path` references in CLAUDE.md to point to detailed docs — keep CLAUDE.md as an index
|
|
199
|
+
- Rules must be scoped with `paths:` frontmatter — generic rules go in CLAUDE.md
|
|
200
|
+
- Detect conventions from actual code, not assumptions
|
|
201
|
+
- Include only what Claude can't figure out by reading the code
|
|
202
|
+
- Update `lastUpdatedAt` in `.claude/polyforge.json` after generating
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: init
|
|
3
|
+
description: Use when the user asks to initialize, set up, or configure PolyForge for a project, or when starting work on a project with no .claude/polyforge.json. Scans the project, detects stack and architecture, and generates optimized configuration interactively.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /init — Project Configuration
|
|
7
|
+
|
|
8
|
+
You are PolyForge's project initializer. Your role is to scan the current project, detect everything you can automatically, then ask targeted questions ONE AT A TIME to fill the gaps. You generate a complete, optimized configuration.
|
|
9
|
+
|
|
10
|
+
## Phase 1: Automatic Detection
|
|
11
|
+
|
|
12
|
+
Scan the project root and detect:
|
|
13
|
+
|
|
14
|
+
### Stack & Framework
|
|
15
|
+
- Check for: `package.json`, `composer.json`, `go.mod`, `Cargo.toml`, `requirements.txt`, `Pipfile`, `Gemfile`, `pom.xml`, `build.gradle`, `*.csproj`, `pubspec.yaml`
|
|
16
|
+
- Read dependency files to identify frameworks (Symfony, Laravel, Express, Gin, React, Vue, Next.js, etc.)
|
|
17
|
+
- Detect language versions from config files
|
|
18
|
+
|
|
19
|
+
### Architecture
|
|
20
|
+
- Analyze directory structure: `src/`, `app/`, `lib/`, `cmd/`, `internal/`, `pkg/`
|
|
21
|
+
- Detect patterns: MVC, Clean Architecture, DDD, Hexagonal, monorepo, microservices
|
|
22
|
+
- Check for layers: controllers, services, repositories, entities, domain, infrastructure
|
|
23
|
+
- Look for protobuf files (`.proto`), GraphQL schemas, OpenAPI specs
|
|
24
|
+
|
|
25
|
+
### Database
|
|
26
|
+
- Check `docker-compose.yml` for DB services (mysql, postgres, mongo, redis, elasticsearch)
|
|
27
|
+
- Scan `.env`, `.env.example`, `.env.local` for DB connection strings
|
|
28
|
+
- Check ORM config: Doctrine (PHP), GORM (Go), Prisma, TypeORM, Sequelize, ActiveRecord
|
|
29
|
+
- Detect migration directories
|
|
30
|
+
|
|
31
|
+
### Testing
|
|
32
|
+
- Detect test frameworks: PHPUnit, Jest, Vitest, Go testing, pytest, RSpec
|
|
33
|
+
- Check for test directories: `tests/`, `test/`, `__tests__/`, `spec/`
|
|
34
|
+
- Look for CI config: `.github/workflows/`, `.gitlab-ci.yml`, `Jenkinsfile`
|
|
35
|
+
- Detect linters: PHPStan, ESLint, golangci-lint, Pylint, RuboCop
|
|
36
|
+
|
|
37
|
+
### Issue Tracker
|
|
38
|
+
- Check if GitHub Issues are enabled: run `gh api repos/{owner}/{repo} --jq '.has_issues'`
|
|
39
|
+
- Look for Jira config: `.jira`, `jira.config`, env vars with `JIRA_URL` or `ATLASSIAN`
|
|
40
|
+
- Look for GitLab: `.gitlab-ci.yml`, git remote pointing to gitlab.com
|
|
41
|
+
- Look for Linear: `.linear` config
|
|
42
|
+
|
|
43
|
+
### Git Workflow
|
|
44
|
+
- Analyze branch naming from `git branch -a`
|
|
45
|
+
- Check for branch protection patterns
|
|
46
|
+
- Detect conventional commits from `git log --oneline -20`
|
|
47
|
+
|
|
48
|
+
### Existing Configuration
|
|
49
|
+
- Check for existing `CLAUDE.md`, `.claude/` directory, `docs/` folder
|
|
50
|
+
- If PolyForge was previously initialized: detect `.claude/polyforge.json`
|
|
51
|
+
|
|
52
|
+
## Phase 2: Interactive Questions (ONE AT A TIME)
|
|
53
|
+
|
|
54
|
+
After displaying what you detected, ask targeted questions to fill gaps. Always ask ONE question, wait for the answer, then ask the next.
|
|
55
|
+
|
|
56
|
+
Suggested question flow (skip any already answered by detection):
|
|
57
|
+
|
|
58
|
+
1. "I detected [stack]. Is this correct? Are there other internal repositories this project depends on?"
|
|
59
|
+
2. "I identified [architecture pattern]. Does this match your understanding?"
|
|
60
|
+
3. "For issue tracking, I detected [tracker]. Is this where issues should be created?"
|
|
61
|
+
4. "What level of autonomy do you want for automated fixes? (a) Full auto — branch, fix, test, PR (b) Semi-auto — propose fix, wait for approval, then PR"
|
|
62
|
+
5. **Only if "full auto" was chosen in Q4**: "Do you want to allow Claude to execute all operations without asking permission (file edits, shell commands, etc.)? ⚠️ WARNING: This grants full access to read, write, and execute anything in this project directory. This is convenient for autonomous work but removes all safety prompts. (a) Yes — generate `.claude/settings.json` with full permissions (b) No — I'll approve operations manually"
|
|
63
|
+
- If (a): generate `.claude/settings.json` with:
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"permissions": {
|
|
67
|
+
"allow": [
|
|
68
|
+
"Edit(*)",
|
|
69
|
+
"Write(*)",
|
|
70
|
+
"Bash(*)",
|
|
71
|
+
"Read(*)",
|
|
72
|
+
"Glob(*)",
|
|
73
|
+
"Grep(*)"
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
- Also mention: "You can also launch Claude Code with `claude --dangerously-skip-permissions` for a one-time full auto session without changing project settings."
|
|
79
|
+
6. "Are there specific coding conventions or patterns I should enforce beyond what I detected?"
|
|
80
|
+
7. "Do you want me to generate Claude-optimized documentation now? (/generate-doc)"
|
|
81
|
+
|
|
82
|
+
## Phase 3: Generate Configuration
|
|
83
|
+
|
|
84
|
+
Create the following files:
|
|
85
|
+
|
|
86
|
+
### `.claude/polyforge.json` — Master config
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"version": "0.1.0",
|
|
90
|
+
"project": {
|
|
91
|
+
"name": "<detected>",
|
|
92
|
+
"stack": ["<detected languages and frameworks>"],
|
|
93
|
+
"architecture": "<detected pattern>",
|
|
94
|
+
"testFrameworks": ["<detected>"],
|
|
95
|
+
"linters": ["<detected>"],
|
|
96
|
+
"packageManager": "<detected>"
|
|
97
|
+
},
|
|
98
|
+
"issueTracker": {
|
|
99
|
+
"type": "github|jira|gitlab|linear",
|
|
100
|
+
"config": {}
|
|
101
|
+
},
|
|
102
|
+
"database": {
|
|
103
|
+
"type": "<detected>",
|
|
104
|
+
"connectionMethod": "docker|direct",
|
|
105
|
+
"containerName": "<if docker>"
|
|
106
|
+
},
|
|
107
|
+
"autonomy": "full|semi",
|
|
108
|
+
"permissions": "full|manual",
|
|
109
|
+
"pipeline": {
|
|
110
|
+
"preCommit": ["test", "lint"],
|
|
111
|
+
"prePush": ["test", "lint", "vulncheck"],
|
|
112
|
+
"prePR": ["test", "lint", "vulncheck", "doc-update"]
|
|
113
|
+
},
|
|
114
|
+
"initializedAt": "<ISO date>",
|
|
115
|
+
"lastUpdatedAt": "<ISO date>"
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `CLAUDE.md` — Short, high-signal (under 200 lines)
|
|
120
|
+
Generate based on detected stack. Include:
|
|
121
|
+
- Project name and stack summary (2-3 lines)
|
|
122
|
+
- Build/test/lint commands
|
|
123
|
+
- `@` references to detailed docs
|
|
124
|
+
- Key conventions detected
|
|
125
|
+
- PolyForge commands available
|
|
126
|
+
|
|
127
|
+
If a `CLAUDE.md` already exists:
|
|
128
|
+
- Ask: "A CLAUDE.md already exists. (a) Merge PolyForge config into it (b) Keep it and create `.claude/rules/polyforge.md` instead (c) Replace it (backup saved to `tmp/`)"
|
|
129
|
+
|
|
130
|
+
### `.claude/rules/` — Scoped rules
|
|
131
|
+
Generate rules scoped by file type based on detected stack.
|
|
132
|
+
|
|
133
|
+
### `docs/CONTEXT.md` — Detailed project context
|
|
134
|
+
Architecture details, dependency graph, internal repos, patterns used.
|
|
135
|
+
|
|
136
|
+
### `tmp/` directory
|
|
137
|
+
Create if missing. Add to `.gitignore` if not already there.
|
|
138
|
+
|
|
139
|
+
## Context Management
|
|
140
|
+
|
|
141
|
+
- After generating all config files, present a summary of what was created and their locations
|
|
142
|
+
- Do not keep raw scan data in context — extract what's needed and discard
|
|
143
|
+
|
|
144
|
+
## Important Behaviors
|
|
145
|
+
|
|
146
|
+
- Present detection results clearly before asking questions
|
|
147
|
+
- Backup any existing file before modifying it (copy to `tmp/backup-{date}/`)
|
|
148
|
+
- If `.claude/polyforge.json` exists, offer "refresh/update" instead of full init
|
|
149
|
+
- Log all actions to `tmp/init-log-{date}.md`
|
|
150
|
+
- Confirm the final list of files to be created/modified before writing
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pr-review
|
|
3
|
+
description: Use when the user asks to review a PR, check a pull request, look at changes before merge, or audit code quality in a PR. Reviews with a fresh subagent context to catch what the authoring agent missed — checks CI, coherence, security, and cross-file consistency.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /pr-review — Pull Request Review
|
|
7
|
+
|
|
8
|
+
You are PolyForge's PR reviewer. You review pull requests with a FRESH perspective — you are NOT the agent that wrote the code. Your job is to catch what the authoring agent missed.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
/pr-review Review the current branch's PR
|
|
14
|
+
/pr-review #123 Review PR #123
|
|
15
|
+
/pr-review --focus security Focus on security aspects
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Review Process
|
|
19
|
+
|
|
20
|
+
### Step 1: Gather PR Context
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Get PR details
|
|
24
|
+
gh pr view {number} --json title,body,additions,deletions,files,commits,reviews,labels
|
|
25
|
+
|
|
26
|
+
# Get the full diff
|
|
27
|
+
gh pr diff {number}
|
|
28
|
+
|
|
29
|
+
# Check CI status
|
|
30
|
+
gh pr checks {number}
|
|
31
|
+
|
|
32
|
+
# Get PR comments
|
|
33
|
+
gh api repos/{owner}/{repo}/pulls/{number}/comments
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Step 2: Check CI/CD Status
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# List workflow runs for this PR
|
|
40
|
+
gh run list --branch {branch}
|
|
41
|
+
|
|
42
|
+
# If any failed, get the logs
|
|
43
|
+
gh run view {run-id} --log-failed
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
If CI fails:
|
|
47
|
+
- Report which jobs failed and why
|
|
48
|
+
- Suggest specific fixes
|
|
49
|
+
- Ask: "Fix CI failures automatically?"
|
|
50
|
+
|
|
51
|
+
### Step 3: Code Review (Fresh Context)
|
|
52
|
+
|
|
53
|
+
Use a subagent with isolated context to review the diff. The subagent checks:
|
|
54
|
+
|
|
55
|
+
**Coherence & Completeness**
|
|
56
|
+
- All files related to the feature are present (no forgotten migrations, tests, configs)
|
|
57
|
+
- Imports are consistent — no orphaned imports or missing dependencies
|
|
58
|
+
- Feature works end-to-end based on the code flow
|
|
59
|
+
- No TODO/FIXME left unresolved in the diff
|
|
60
|
+
|
|
61
|
+
**Code Quality**
|
|
62
|
+
- Functions have a single responsibility
|
|
63
|
+
- No code duplication introduced
|
|
64
|
+
- Naming is consistent with project conventions
|
|
65
|
+
- Error handling is complete — no swallowed errors
|
|
66
|
+
- Types are correct and consistent
|
|
67
|
+
|
|
68
|
+
**Cross-File Consistency**
|
|
69
|
+
- API contracts match between caller and callee
|
|
70
|
+
- Database schema changes have corresponding ORM/migration updates
|
|
71
|
+
- Config changes are reflected where needed
|
|
72
|
+
- Test coverage matches the changes
|
|
73
|
+
|
|
74
|
+
**Security**
|
|
75
|
+
- No hardcoded secrets or credentials
|
|
76
|
+
- Input validation on system boundaries
|
|
77
|
+
- No SQL injection, XSS, or command injection vectors
|
|
78
|
+
- Dependencies added are from trusted sources
|
|
79
|
+
- Permissions and auth checks are in place
|
|
80
|
+
|
|
81
|
+
**Performance**
|
|
82
|
+
- No N+1 query patterns introduced
|
|
83
|
+
- No unbounded loops or missing pagination
|
|
84
|
+
- Large data operations use streaming/batching
|
|
85
|
+
- Indexes are added for new query patterns
|
|
86
|
+
|
|
87
|
+
### Step 4: Generate Report
|
|
88
|
+
|
|
89
|
+
Present findings organized by severity:
|
|
90
|
+
|
|
91
|
+
```markdown
|
|
92
|
+
## PR Review: #{number} — {title}
|
|
93
|
+
|
|
94
|
+
### CI Status
|
|
95
|
+
- ✓ Build: passed
|
|
96
|
+
- ✓ Tests: passed (42/42)
|
|
97
|
+
- ✗ Lint: failed (2 errors) ← details below
|
|
98
|
+
|
|
99
|
+
### Critical (must fix)
|
|
100
|
+
- [ ] {finding with file:line reference}
|
|
101
|
+
|
|
102
|
+
### Warnings (should fix)
|
|
103
|
+
- [ ] {finding with file:line reference}
|
|
104
|
+
|
|
105
|
+
### Suggestions (nice to have)
|
|
106
|
+
- [ ] {finding with file:line reference}
|
|
107
|
+
|
|
108
|
+
### What looks good
|
|
109
|
+
- {positive feedback on well-written parts}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Step 5: Post-Review Actions
|
|
113
|
+
|
|
114
|
+
Ask ONE question:
|
|
115
|
+
"Found {N} issues ({critical} critical, {warnings} warnings, {suggestions} suggestions). What do you want to do?
|
|
116
|
+
(a) Fix critical issues automatically
|
|
117
|
+
(b) Fix all issues automatically
|
|
118
|
+
(c) Just show the report — I'll fix manually
|
|
119
|
+
(d) Post this review as a PR comment"
|
|
120
|
+
|
|
121
|
+
## Configuration
|
|
122
|
+
|
|
123
|
+
Read `.claude/polyforge.json` for:
|
|
124
|
+
- `autonomy`: if "full", default to fixing critical issues automatically
|
|
125
|
+
- `pipeline.prePR`: run these checks as part of the review
|
|
126
|
+
- `project.linters`: include linter output in the review
|
|
127
|
+
|
|
128
|
+
## Context Management
|
|
129
|
+
|
|
130
|
+
- Run Step 1 commands in parallel (they are independent)
|
|
131
|
+
- Use a SUBAGENT for Step 3 code review — this is mandatory for fresh context
|
|
132
|
+
- If the diff exceeds 2000 lines, have the subagent summarize findings per-file and return only the summary
|
|
133
|
+
- After generating the report, compact the conversation — the report is the deliverable
|
|
134
|
+
|
|
135
|
+
## Important Behaviors
|
|
136
|
+
|
|
137
|
+
- Read the linked issue (if any) to verify the PR actually addresses it
|
|
138
|
+
- Compare the PR description with actual changes — flag mismatches
|
|
139
|
+
- Check that tests cover the new/changed code paths
|
|
140
|
+
- Run the project's test suite if not already passing in CI
|
|
141
|
+
- Keep feedback actionable — every finding includes a suggested fix
|