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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 kiloumap
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ [![npm version](https://img.shields.io/npm/v/polyforgeai.svg)](https://www.npmjs.com/package/polyforgeai)
2
+ [![CI](https://github.com/Vekta/polyforge/actions/workflows/ci.yml/badge.svg)](https://github.com/Vekta/polyforge/actions/workflows/ci.yml)
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen.svg)](https://nodejs.org)
5
+
6
+ # PolyForge
7
+
8
+ Self-adaptive Claude Code plugin for automated software development workflows.
9
+
10
+ PolyForge scans your project, detects your stack, architecture, and conventions, then provides intelligent slash commands to automate common development tasks.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npx polyforgeai install
16
+ ```
17
+
18
+ This symlinks PolyForge skills and rules into `~/.claude/`, making them available in any Claude Code session.
19
+
20
+ ## Quick Start
21
+
22
+ 1. Install PolyForge
23
+ 2. Open Claude Code in your project
24
+ 3. Run `/init` — PolyForge scans your project and generates an optimized configuration
25
+ 4. Use any command: `/pr-review`, `/fix #123`, `/brainstorm`, etc.
26
+
27
+ ## Commands
28
+
29
+ | Command | Description |
30
+ |---------|-------------|
31
+ | `/init` | Scan project, detect stack/architecture, generate config interactively |
32
+ | `/pr-review` | Review a PR with fresh context — checks CI, code quality, security |
33
+ | `/analyse-db` | Connect to DB (Docker or direct), generate `docs/DB.md` schema documentation |
34
+ | `/analyse-code` | Full codebase analysis — patterns, security, performance, config issues |
35
+ | `/report-issue` | Detect and create issues on GitHub/Jira/GitLab |
36
+ | `/fix #N` | Fix an issue — branch, implement, test, PR (autonomy level configurable) |
37
+ | `/fix-ci` | Diagnose and fix CI/CD failures — loops max 3 times then reports |
38
+ | `/brainstorm` | Free-form brainstorming — produces action plan with parallelizable tasks |
39
+ | `/generate-doc` | Generate/update Claude-optimized documentation (CLAUDE.md, docs, rules) |
40
+
41
+ ## How It Works
42
+
43
+ PolyForge uses Claude Code's native extension points:
44
+
45
+ - **Skills** (`.claude/skills/`) — Each command is a SKILL.md that Claude Code loads on demand
46
+ - **Rules** (`.claude/rules/`) — Golden principles enforced across all interactions
47
+ - **Hooks** — Pipeline verification (tests, lint, vulncheck) before push/PR
48
+
49
+ ### Project Configuration
50
+
51
+ After `/init`, your project gets:
52
+
53
+ ```
54
+ .claude/
55
+ polyforge.json # Project config (stack, tracker, autonomy, pipeline)
56
+ rules/
57
+ polyforge-*.md # Stack-specific rules (scoped by file path)
58
+ skills/ # (symlinked from PolyForge install)
59
+ CLAUDE.md # Short, high-signal project summary (<200 lines)
60
+ docs/
61
+ CONTEXT.md # Detailed architecture and project context
62
+ tmp/ # PolyForge working directory (gitignored)
63
+ ```
64
+
65
+ ### Autonomy Levels
66
+
67
+ Configured per project during `/init`:
68
+
69
+ - **Full auto**: PolyForge branches, fixes, tests, and creates PRs autonomously
70
+ - **Semi-auto**: PolyForge proposes changes, waits for approval before applying
71
+
72
+ ### Permissions & Hands-Free Mode
73
+
74
+ By default, Claude Code asks for permission on every file edit and shell command. If you chose "full auto" during `/init`, you'll be asked whether to grant full permissions for the project.
75
+
76
+ **Via `/init` (persistent, per-project):**
77
+ Generates a `.claude/settings.json` that auto-approves all operations in the project directory. You can revert by deleting the file.
78
+
79
+ **Via CLI flag (one-time, any project):**
80
+ ```bash
81
+ claude --dangerously-skip-permissions
82
+ ```
83
+ Launches a single session with all permissions granted. Nothing is saved — next session returns to normal.
84
+
85
+ ### Skill Management
86
+
87
+ Install everything or pick what you need:
88
+
89
+ ```bash
90
+ npx polyforgeai install # Install all skills & rules
91
+ npx polyforgeai install --force # Reinstall, overwriting existing
92
+ npx polyforgeai add-skill pr-review fix # Install specific skills only
93
+ npx polyforgeai remove-skill analyse-db # Remove a skill
94
+ npx polyforgeai list # See available skills & install status
95
+ ```
96
+
97
+ ### Issue Tracker Integration
98
+
99
+ Auto-detected during `/init`:
100
+ - **GitHub Issues** — detected via `gh api`
101
+ - **Jira** — detected from `.env`, `.jira` config
102
+ - **GitLab** — detected from git remote
103
+
104
+ ## Design Principles
105
+
106
+ - **Positive rules** — all golden principles are phrased as assertions, not negations (proven more effective with LLMs)
107
+ - **Fresh context** — PR reviews use isolated subagents to avoid author bias
108
+ - **Circuit breakers** — max 3 retries on any failing operation, then switch strategy or ask for help
109
+ - **Progressive disclosure** — context is loaded on-demand, not upfront, to preserve the context window
110
+ - **Hooks enforce, rules guide** — deterministic checks (tests, lint) are hooks; advisory guidance stays in rules
111
+
112
+ ## Update
113
+
114
+ ```bash
115
+ npx polyforgeai update
116
+ ```
117
+
118
+ ## Uninstall
119
+
120
+ ```bash
121
+ npx polyforgeai uninstall
122
+ ```
123
+
124
+ ## Requirements
125
+
126
+ - Node.js >= 18
127
+ - [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code)
128
+ - [`gh` CLI](https://cli.github.com/) (for GitHub integration)
129
+
130
+ > **Note:** PolyForge is built on Claude Code's native extension system (skills, rules, hooks). It requires Claude Code as its runtime and does not support other AI models or providers. The skills are plain markdown and could be adapted to other tools in the future, but the orchestration (subagents, worktrees, context management) relies on Claude Code.
131
+
132
+ ## Contributing
133
+
134
+ Contributions are welcome! Please:
135
+
136
+ 1. Fork the repository
137
+ 2. Create a feature branch (`git checkout -b feature/my-feature`)
138
+ 3. Run tests (`node --test tests/**/*.test.js`)
139
+ 4. Commit your changes
140
+ 5. Open a pull request
141
+
142
+ ## License
143
+
144
+ [MIT](LICENSE)
@@ -0,0 +1,252 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { resolve, dirname } from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ import { existsSync, mkdirSync, symlinkSync, readlinkSync, unlinkSync, readFileSync, readdirSync, statSync, lstatSync } from 'fs';
6
+ import { homedir } from 'os';
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const ROOT = resolve(__dirname, '..');
10
+ const CLAUDE_DIR = resolve(homedir(), '.claude');
11
+ const FORCE = process.argv.includes('--force');
12
+
13
+ const pkg = JSON.parse(readFileSync(resolve(ROOT, 'package.json'), 'utf-8'));
14
+
15
+ const commands = {
16
+ install,
17
+ uninstall,
18
+ update,
19
+ 'add-skill': addSkill,
20
+ 'remove-skill': removeSkill,
21
+ list: listSkills,
22
+ help,
23
+ '--version': version,
24
+ '-v': version,
25
+ };
26
+
27
+ const command = process.argv[2] || 'help';
28
+
29
+ if (!commands[command]) {
30
+ console.error(`Unknown command: ${command}`);
31
+ commands.help();
32
+ process.exit(1);
33
+ }
34
+
35
+ commands[command]();
36
+
37
+ function version() {
38
+ console.log(`polyforge v${pkg.version}`);
39
+ }
40
+
41
+ function install() {
42
+ console.log(`\nPolyForge v${pkg.version} — Installing skills & rules\n`);
43
+
44
+ const targets = [
45
+ { src: resolve(ROOT, 'skills'), dest: resolve(CLAUDE_DIR, 'skills'), type: 'skills' },
46
+ { src: resolve(ROOT, 'rules'), dest: resolve(CLAUDE_DIR, 'rules'), type: 'rules' },
47
+ ];
48
+
49
+ for (const { src, dest, type } of targets) {
50
+ if (!existsSync(src)) continue;
51
+
52
+ mkdirSync(dest, { recursive: true });
53
+
54
+ const entries = readdirSync(src);
55
+ for (const entry of entries) {
56
+ const srcPath = resolve(src, entry);
57
+ const destPath = resolve(dest, entry.startsWith('polyforge-') ? entry : `polyforge-${entry}`);
58
+
59
+ if (existsSync(destPath)) {
60
+ if (isSymlinkTo(destPath, srcPath)) {
61
+ console.log(` ✓ ${type}/${entry} (already linked)`);
62
+ continue;
63
+ }
64
+ if (FORCE) {
65
+ safeUnlink(destPath);
66
+ symlinkSync(srcPath, destPath);
67
+ console.log(` ↻ ${type}/${entry} → replaced (--force)`);
68
+ continue;
69
+ }
70
+ console.log(` ⚠ ${type}/${entry} exists — skipping (use --force to overwrite)`);
71
+ continue;
72
+ }
73
+
74
+ symlinkSync(srcPath, destPath);
75
+ console.log(` + ${type}/${entry} → linked`);
76
+ }
77
+ }
78
+
79
+ console.log('\n✓ PolyForge installed. Use /init in Claude Code to configure a project.\n');
80
+ }
81
+
82
+ function uninstall() {
83
+ console.log('\nPolyForge — Uninstalling\n');
84
+
85
+ const dirs = [
86
+ resolve(CLAUDE_DIR, 'skills'),
87
+ resolve(CLAUDE_DIR, 'rules'),
88
+ ];
89
+
90
+ for (const dir of dirs) {
91
+ if (!existsSync(dir)) continue;
92
+
93
+ const entries = readdirSync(dir);
94
+ for (const entry of entries) {
95
+ if (!entry.startsWith('polyforge-')) continue;
96
+ const fullPath = resolve(dir, entry);
97
+ if (safeUnlink(fullPath)) {
98
+ console.log(` - Removed ${entry}`);
99
+ }
100
+ }
101
+ }
102
+
103
+ console.log('\n✓ PolyForge uninstalled.\n');
104
+ }
105
+
106
+ function update() {
107
+ console.log(`Updating PolyForge to v${pkg.version}...`);
108
+ uninstall();
109
+ install();
110
+ }
111
+
112
+ function addSkill() {
113
+ const names = process.argv.slice(3).filter(a => !a.startsWith('--'));
114
+ if (names.length === 0) {
115
+ console.error('Usage: polyforge add-skill <name> [name2 ...]\n');
116
+ console.log('Available skills:');
117
+ getAvailableSkills().forEach(s => console.log(` - ${s}`));
118
+ process.exit(1);
119
+ }
120
+
121
+ const available = getAvailableSkills();
122
+ const skillsDest = resolve(CLAUDE_DIR, 'skills');
123
+ mkdirSync(skillsDest, { recursive: true });
124
+
125
+ for (const name of names) {
126
+ if (!isValidSkillName(name) || !available.includes(name)) {
127
+ console.log(` ✗ Unknown skill: "${name}". Available: ${available.join(', ')}`);
128
+ continue;
129
+ }
130
+
131
+ const srcPath = resolve(ROOT, 'skills', name);
132
+ const destPath = resolve(skillsDest, `polyforge-${name}`);
133
+
134
+ if (existsSync(destPath)) {
135
+ if (isSymlinkTo(destPath, srcPath)) {
136
+ console.log(` ✓ ${name} (already installed)`);
137
+ } else if (FORCE) {
138
+ safeUnlink(destPath);
139
+ symlinkSync(srcPath, destPath);
140
+ console.log(` ↻ ${name} → replaced (--force)`);
141
+ } else {
142
+ console.log(` ⚠ ${name} exists — skipping (use --force to overwrite)`);
143
+ }
144
+ continue;
145
+ }
146
+
147
+ symlinkSync(srcPath, destPath);
148
+ console.log(` + ${name} → installed`);
149
+ }
150
+ }
151
+
152
+ function removeSkill() {
153
+ const names = process.argv.slice(3).filter(a => !a.startsWith('--'));
154
+ if (names.length === 0) {
155
+ console.error('Usage: polyforge remove-skill <name> [name2 ...]');
156
+ process.exit(1);
157
+ }
158
+
159
+ const skillsDest = resolve(CLAUDE_DIR, 'skills');
160
+
161
+ for (const name of names) {
162
+ if (!isValidSkillName(name)) {
163
+ console.log(` ✗ Invalid skill name: "${name}"`);
164
+ continue;
165
+ }
166
+
167
+ const destPath = resolve(skillsDest, `polyforge-${name}`);
168
+ if (!existsSync(destPath)) {
169
+ console.log(` - ${name} (not installed)`);
170
+ continue;
171
+ }
172
+
173
+ if (safeUnlink(destPath)) {
174
+ console.log(` - ${name} → removed`);
175
+ } else {
176
+ console.error(` ✗ Failed to remove ${name}`);
177
+ }
178
+ }
179
+ }
180
+
181
+ function listSkills() {
182
+ const available = getAvailableSkills();
183
+ const skillsDest = resolve(CLAUDE_DIR, 'skills');
184
+
185
+ console.log('\nPolyForge Skills:\n');
186
+ for (const name of available) {
187
+ const destPath = resolve(skillsDest, `polyforge-${name}`);
188
+ const installed = existsSync(destPath);
189
+ console.log(` ${installed ? '✓' : '○'} ${name}`);
190
+ }
191
+ console.log('');
192
+ }
193
+
194
+ function getAvailableSkills() {
195
+ const skillsDir = resolve(ROOT, 'skills');
196
+ if (!existsSync(skillsDir)) return [];
197
+ return readdirSync(skillsDir).filter(entry =>
198
+ statSync(resolve(skillsDir, entry)).isDirectory()
199
+ );
200
+ }
201
+
202
+ function help() {
203
+ console.log(`
204
+ PolyForge v${pkg.version} — Self-adaptive Claude Code plugin
205
+
206
+ Usage:
207
+ npx polyforge install [--force] Install all skills & rules into ~/.claude/
208
+ npx polyforge uninstall Remove all PolyForge skills & rules
209
+ npx polyforge update Reinstall (uninstall + install)
210
+ npx polyforge add-skill <name> Install a specific skill [--force]
211
+ npx polyforge remove-skill <name> Remove a specific skill
212
+ npx polyforge list Show available skills and install status
213
+ npx polyforge --version Show version
214
+ npx polyforge help Show this help
215
+
216
+ After install, use these slash commands in Claude Code:
217
+ /init Scan & configure current project
218
+ /pr-review Review a PR (fresh context + CI check)
219
+ /analyse-db Analyze database schema
220
+ /analyse-code Full codebase analysis
221
+ /report-issue Detect & report issues
222
+ /fix Fix a specific issue
223
+ /fix-ci Diagnose & fix CI failures (max 3 retries)
224
+ /brainstorm Brainstorm a feature or fix
225
+ /generate-doc Generate Claude-optimized documentation
226
+ `);
227
+ }
228
+
229
+ function isSymlinkTo(linkPath, targetPath) {
230
+ try {
231
+ return readlinkSync(linkPath) === targetPath;
232
+ } catch {
233
+ return false;
234
+ }
235
+ }
236
+
237
+ function isValidSkillName(name) {
238
+ return /^[a-z0-9-]+$/.test(name) && !name.includes('..');
239
+ }
240
+
241
+ function safeUnlink(filepath) {
242
+ try {
243
+ const stat = lstatSync(filepath);
244
+ if (stat.isSymbolicLink() || stat.isFile()) {
245
+ unlinkSync(filepath);
246
+ return true;
247
+ }
248
+ } catch {
249
+ // skip
250
+ }
251
+ return false;
252
+ }
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+ # PolyForge pre-commit hook
3
+ # Blocks commits with .env files and runs tests
4
+
5
+ set -e
6
+
7
+ # Block .env files from being committed
8
+ STAGED_ENV=$(git diff --cached --name-only | grep -E '\.env(\..+)?$' || true)
9
+ if [ -n "$STAGED_ENV" ]; then
10
+ echo "[PolyForge] Blocked: .env files must not be committed:"
11
+ echo "$STAGED_ENV"
12
+ echo "Add them to .gitignore instead."
13
+ exit 1
14
+ fi
15
+
16
+ # Run tests
17
+ if [ -f "package.json" ]; then
18
+ npm test 2>&1 || { echo "[PolyForge] Tests failed — commit blocked"; exit 1; }
19
+ elif [ -f "composer.json" ]; then
20
+ composer test 2>&1 || php vendor/bin/phpunit 2>&1 || { echo "[PolyForge] Tests failed — commit blocked"; exit 1; }
21
+ elif [ -f "go.mod" ]; then
22
+ go test ./... 2>&1 || { echo "[PolyForge] Tests failed — commit blocked"; exit 1; }
23
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
24
+ python -m pytest 2>&1 || { echo "[PolyForge] Tests failed — commit blocked"; exit 1; }
25
+ fi
26
+
27
+ echo "[PolyForge] ✓ Pre-commit checks passed"
@@ -0,0 +1,45 @@
1
+ #!/bin/bash
2
+ # PolyForge pre-push verification hook
3
+ # Runs tests, linter, and vulncheck before allowing push
4
+ #
5
+ # Install: Add to .claude/settings.json hooks or use as git pre-push hook
6
+
7
+ set -e
8
+
9
+ CONFIG_FILE=".claude/polyforge.json"
10
+
11
+ if [ ! -f "$CONFIG_FILE" ]; then
12
+ echo "[PolyForge] No config found. Run /init first."
13
+ exit 0
14
+ fi
15
+
16
+ echo "[PolyForge] Running pre-push verification pipeline..."
17
+
18
+ # Detect and run test command
19
+ if [ -f "package.json" ]; then
20
+ echo " → Running tests (npm)..."
21
+ npm test 2>&1 || { echo " ✗ Tests failed"; exit 1; }
22
+ elif [ -f "composer.json" ]; then
23
+ echo " → Running tests (composer)..."
24
+ composer test 2>&1 || php vendor/bin/phpunit 2>&1 || { echo " ✗ Tests failed"; exit 1; }
25
+ elif [ -f "go.mod" ]; then
26
+ echo " → Running tests (go)..."
27
+ go test ./... 2>&1 || { echo " ✗ Tests failed"; exit 1; }
28
+ elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
29
+ echo " → Running tests (python)..."
30
+ python -m pytest 2>&1 || { echo " ✗ Tests failed"; exit 1; }
31
+ fi
32
+
33
+ # Detect and run linter
34
+ if [ -f ".eslintrc.js" ] || [ -f ".eslintrc.cjs" ] || [ -f ".eslintrc.json" ] || [ -f ".eslintrc.yml" ] || [ -f "eslint.config.js" ] || [ -f "eslint.config.mjs" ] || [ -f "eslint.config.cjs" ] || [ -f "eslint.config.ts" ]; then
35
+ echo " → Running linter (eslint)..."
36
+ npx eslint . 2>&1 || { echo " ✗ Lint failed"; exit 1; }
37
+ elif [ -f "phpstan.neon" ] || [ -f "phpstan.neon.dist" ]; then
38
+ echo " → Running linter (phpstan)..."
39
+ php vendor/bin/phpstan analyse 2>&1 || { echo " ✗ Lint failed"; exit 1; }
40
+ elif [ -f ".golangci.yml" ] || [ -f ".golangci.yaml" ]; then
41
+ echo " → Running linter (golangci-lint)..."
42
+ golangci-lint run 2>&1 || { echo " ✗ Lint failed"; exit 1; }
43
+ fi
44
+
45
+ echo "[PolyForge] ✓ All checks passed"
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "polyforgeai",
3
+ "version": "0.1.0",
4
+ "description": "Self-adaptive Claude Code plugin for automated software development workflows",
5
+ "bin": {
6
+ "polyforge": "./bin/polyforge.js"
7
+ },
8
+ "scripts": {
9
+ "test": "node --test tests/**/*.test.js",
10
+ "polyforge": "node bin/polyforge.js"
11
+ },
12
+ "keywords": [
13
+ "claude",
14
+ "claude-code",
15
+ "ai",
16
+ "developer-tools",
17
+ "code-review",
18
+ "automation",
19
+ "skills",
20
+ "workflow"
21
+ ],
22
+ "author": "kiloumap",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/Vekta/polyforge.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/Vekta/polyforge/issues"
30
+ },
31
+ "homepage": "https://github.com/Vekta/polyforge#readme",
32
+ "engines": {
33
+ "node": ">=18.0.0"
34
+ },
35
+ "type": "module",
36
+ "files": [
37
+ "bin/",
38
+ "skills/",
39
+ "rules/",
40
+ "hooks/",
41
+ "templates/",
42
+ "LICENSE"
43
+ ],
44
+ "dependencies": {},
45
+ "devDependencies": {}
46
+ }
@@ -0,0 +1,22 @@
1
+ # PolyForge Golden Principles
2
+
3
+ ## Code Quality
4
+ 1. Every change includes tests that verify the new behavior
5
+ 2. Functions have a single responsibility
6
+ 3. Error handling is explicit — every error path has intentional handling
7
+
8
+ ## Architecture
9
+ 4. Dependencies flow inward — infrastructure depends on domain, not the reverse
10
+ 5. Business logic lives in the service/domain layer, not in controllers or repositories
11
+ 6. External services are accessed through interfaces/abstractions
12
+ 7. Configuration comes from environment variables
13
+
14
+ ## Workflow
15
+ 8. Commits are atomic — one logical change per commit
16
+ 9. Documentation stays in sync with code changes
17
+ 10. Flag breaking changes explicitly with migration steps
18
+
19
+ ## Resilience
20
+ 11. Retry a failing approach at most 3 times — then try a different angle or ask for help
21
+ 12. Same error with same fix twice means the approach is wrong — switch strategy
22
+ 13. Scope investigations to specific files or directories — avoid reading the entire codebase
@@ -0,0 +1,18 @@
1
+ # PolyForge Security Rules
2
+
3
+ ## Secrets
4
+ 1. Credentials, API keys, and tokens live in environment variables
5
+ 2. Example env files (`.env.example`) use placeholder values only
6
+
7
+ ## Input Validation
8
+ 3. All user input is validated at system boundaries (controllers, API handlers)
9
+ 4. Shell commands use argument arrays, not string concatenation with user input
10
+
11
+ ## Authentication & Authorization
12
+ 5. Every endpoint that modifies data requires authentication
13
+ 6. Authorization checks happen at the service layer, not just the controller
14
+ 7. Sensitive operations require re-authentication or confirmation
15
+
16
+ ## Data Protection
17
+ 8. Sensitive data is excluded from logs and error messages
18
+ 9. API responses include only the fields the consumer needs
@@ -0,0 +1,14 @@
1
+ # PolyForge Testing Rules
2
+
3
+ ## Structure
4
+ 1. Test names describe behavior: "it should {expected} when {condition}"
5
+ 2. Each test verifies one behavior
6
+ 3. Test data uses factories or fixtures, not hardcoded magic values
7
+
8
+ ## Coverage
9
+ 4. Every public method in a service has at least one test
10
+ 5. Critical paths (auth, payments, data mutations) have thorough test coverage
11
+
12
+ ## Quality
13
+ 6. Tests that pass without the implementation being correct are rewritten
14
+ 7. Time-dependent tests use frozen clocks; order-dependent tests use explicit setup