autoworkflow 1.2.0 → 2.0.1

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/README.md CHANGED
@@ -1,250 +1,327 @@
1
- # autoworkflow
1
+ # AutoWorkflow - System Prompt Layer for Claude Code
2
2
 
3
- Zero-config code quality enforcement. Just install and commit.
3
+ > **Claude is the enforcement engine.** System prompts control the workflow. Scripts and hooks provide backup enforcement.
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/autoworkflow.svg)](https://www.npmjs.com/package/autoworkflow)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ A system prompt architecture that controls Claude Code's behavior through triggers, loops, gates, and routing. When you use Claude Code in VS Code with this project, Claude automatically follows a structured 9-phase workflow for all coding tasks.
7
6
 
8
- ## Install
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ### Via npm (Recommended)
12
+
13
+ ```bash
14
+ npm install autoworkflow
15
+ ```
16
+
17
+ Then copy files to your project:
9
18
 
10
19
  ```bash
11
- npm install autoworkflow --save-dev
20
+ # Copy all workflow files
21
+ cp -r node_modules/autoworkflow/CLAUDE.md .
22
+ cp -r node_modules/autoworkflow/system ./system
23
+ cp -r node_modules/autoworkflow/instructions ./instructions
24
+ cp -r node_modules/autoworkflow/.claude ./.claude
25
+ cp -r node_modules/autoworkflow/scripts ./scripts
26
+ cp -r node_modules/autoworkflow/hooks ./hooks
27
+
28
+ # Optional: Copy VS Code settings
29
+ cp -r node_modules/autoworkflow/.vscode ./.vscode
30
+
31
+ # Optional: Copy config examples
32
+ cp node_modules/autoworkflow/.prettierrc .
33
+ cp node_modules/autoworkflow/eslint.config.example.js ./eslint.config.js
34
+ cp node_modules/autoworkflow/tsconfig.example.json ./tsconfig.json
35
+
36
+ # Setup git hooks
37
+ npm run setup:hooks
12
38
  ```
13
39
 
14
- **That's it.** Enforcement is now active on all commits.
40
+ ### Manual Installation
41
+
42
+ Clone or download this repository and copy the files to your project.
15
43
 
16
- ## What Happens
44
+ ---
45
+
46
+ ## How It Works
17
47
 
18
48
  ```
19
- npm install autoworkflow
20
-
21
-
22
- ┌──────────────────────────────────┐
23
- Auto-setup (postinstall): │
24
- │ ✓ Creates .husky/pre-commit │
25
- │ ✓ Creates .husky/commit-msg │
26
- Creates enforce.config.json
27
- ✓ Creates CLAUDE.md
28
- ✓ Creates .vscode/settings.json
29
- Creates .vscode/tasks.json
30
- ✓ Adds prepare script
31
- └──────────────────────────────────┘
32
-
33
-
34
- Every "git commit" runs checks automatically
49
+ ┌─────────────────────────────────────────────────────────────┐
50
+ CLAUDE.md (Entry Point) │
51
+ │ Loaded automatically by Claude Code │
52
+ └───────────────────────────┬─────────────────────────────────┘
53
+
54
+
55
+ ┌─────────────────────────────────────────────────────────────┐
56
+ system/ (Control Layer)
57
+
58
+ triggers.md loops.md │ gates.md router.md │
59
+ WHEN to act HOW to WHAT │ WHERE to │
60
+ │ │ repeat blocks route │
61
+ └───────────────────────────┬─────────────────────────────────┘
62
+
63
+
64
+ ┌─────────────────────────────────────────────────────────────┐
65
+ │ instructions/ (Content Layer) │
66
+ │ │
67
+ │ CLAUDE.md │ AI_RULES.md │ BLUEPRINT.md │
68
+ │ Workflow │ Standards │ Project spec │
69
+ └───────────────────────────┬─────────────────────────────────┘
70
+
71
+
72
+ ┌─────────────────────────────────────────────────────────────┐
73
+ │ Backup Enforcement (Runtime Layer) │
74
+ │ │
75
+ │ scripts/ │ hooks/ │ npm scripts │
76
+ │ Automation │ Git hooks │ Verification │
77
+ └─────────────────────────────────────────────────────────────┘
35
78
  ```
36
79
 
37
- **Note:** Existing files are never overwritten.
80
+ ---
38
81
 
39
- ## Default Checks
82
+ ## The Workflow
40
83
 
41
- | Check | Blocking | Auto-Fix |
42
- | ---------------------- | -------- | -------- |
43
- | No TODO/FIXME comments | ✅ | - |
44
- | No console.log | ✅ | - |
45
- | TypeScript errors | ✅ | - |
46
- | ESLint errors | ✅ | ✅ |
47
- | Circular dependencies | ✅ | - |
48
- | Commit message format | ✅ | - |
84
+ When you ask Claude to do something, it follows this 9-phase workflow:
49
85
 
50
- ## How It Works
86
+ ```
87
+ ANALYZE → PLAN → CONFIRM → IMPLEMENT → VERIFY → FIX → AUDIT → COMMIT → UPDATE
88
+ ```
51
89
 
52
- ### Pre-Commit Hook
90
+ | Phase | What Claude Does |
91
+ |-------|------------------|
92
+ | **ANALYZE** | Reads relevant files, checks BLUEPRINT.md |
93
+ | **PLAN** | Designs approach, shows categorized suggestions |
94
+ | **CONFIRM** | Waits for your approval |
95
+ | **IMPLEMENT** | Makes changes (only after approval) |
96
+ | **VERIFY** | Runs `npm run verify` (typecheck + lint) |
97
+ | **FIX** | Fixes errors, loops back to VERIFY |
98
+ | **AUDIT** | Checks for orphan features, circular deps |
99
+ | **COMMIT** | Creates conventional commit (after approval) |
100
+ | **UPDATE** | Updates BLUEPRINT.md if new feature/route/API added |
53
101
 
54
- Every time you run `git commit`, autoworkflow:
102
+ ### Session Start
55
103
 
56
- 1. Runs all enabled checks
57
- 2. If ESLint fails, auto-fixes and retries (up to 5 attempts)
58
- 3. Blocks commit if any blocking check fails
59
- 4. Allows commit if all checks pass
104
+ At the start of every session, Claude:
105
+ 1. Checks if `instructions/BLUEPRINT.md` exists
106
+ 2. If missing Runs `/audit project` to generate it
107
+ 3. If exists Reads AI_RULES.md + BLUEPRINT.md and proceeds
60
108
 
61
- ### Commit Message Validation
109
+ ---
62
110
 
63
- Enforces [Conventional Commits](https://www.conventionalcommits.org/):
111
+ ## Blocking Gates
64
112
 
65
- ```bash
66
- # ✅ Valid
67
- git commit -m "feat: add user authentication"
68
- git commit -m "fix(api): resolve timeout issue"
69
- git commit -m "docs: update installation guide"
70
-
71
- # ❌ Invalid (blocked)
72
- git commit -m "fixed stuff"
73
- git commit -m "WIP"
74
- ```
113
+ Claude will STOP and cannot proceed if:
75
114
 
76
- ## Configuration
77
-
78
- Edit `enforce.config.json` in your project root:
79
-
80
- ```json
81
- {
82
- "rules": {
83
- "no-todo-comments": {
84
- "enabled": true,
85
- "blocking": true,
86
- "patterns": ["TODO", "FIXME", "XXX", "HACK"]
87
- },
88
- "no-console-logs": {
89
- "enabled": true,
90
- "blocking": true
91
- },
92
- "typescript": {
93
- "enabled": true,
94
- "blocking": true,
95
- "command": "npx tsc --noEmit"
96
- },
97
- "eslint": {
98
- "enabled": true,
99
- "blocking": true,
100
- "autoFix": true,
101
- "command": "npx eslint . --max-warnings 0",
102
- "fixCommand": "npx eslint . --fix"
103
- },
104
- "circular-deps": {
105
- "enabled": true,
106
- "blocking": true,
107
- "paths": ["src/"]
108
- }
109
- },
110
- "fixLoop": {
111
- "enabled": true,
112
- "maxAttempts": 5,
113
- "autoFixRules": ["eslint"]
114
- },
115
- "commitMessage": {
116
- "enabled": true,
117
- "pattern": "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\(.+\\))?: .{1,72}$"
118
- }
119
- }
120
- ```
115
+ | Gate | Blocks If |
116
+ |------|-----------|
117
+ | `plan_approval_gate` | You haven't approved the plan |
118
+ | `verify_gate` | TypeScript or ESLint errors exist |
119
+ | `audit_gate` | Orphan features or circular dependencies |
120
+ | `pre_commit_gate` | TODO/FIXME, console.log, bad commit format |
121
121
 
122
- ### Rule Options
122
+ ---
123
123
 
124
- | Option | Type | Description |
125
- | ------------ | ------- | -------------------------------------- |
126
- | `enabled` | boolean | Enable/disable the rule |
127
- | `blocking` | boolean | If true, fails the commit on violation |
128
- | `autoFix` | boolean | Enable auto-fix for this rule |
129
- | `command` | string | Custom check command |
130
- | `fixCommand` | string | Custom fix command |
124
+ ## Available Commands
131
125
 
132
- ### Disable a Rule
126
+ | Command | Purpose |
127
+ |---------|---------|
128
+ | `/analyze [task]` | Analyze codebase for a task |
129
+ | `/plan [task]` | Create implementation plan |
130
+ | `/build [feature]` | Full workflow for features |
131
+ | `/verify` | Run TypeScript + ESLint |
132
+ | `/fix` | Fix verification errors |
133
+ | `/audit` | Run UI + cycle audits |
134
+ | `/audit project` | Full project scan → generates BLUEPRINT.md |
135
+ | `/suggest [task]` | Generate suggestions |
136
+ | `/commit [msg]` | Pre-commit check + commit |
133
137
 
134
- ```json
135
- {
136
- "rules": {
137
- "no-console-logs": { "enabled": false }
138
- }
139
- }
140
- ```
138
+ ---
141
139
 
142
- ### Non-Blocking Warning
140
+ ## Hard Rules
143
141
 
144
- ```json
145
- {
146
- "rules": {
147
- "circular-deps": { "enabled": true, "blocking": false }
148
- }
149
- }
150
- ```
142
+ Claude enforces these automatically:
151
143
 
152
- ## CLI Commands
144
+ - **No orphan features** - Backend MUST have corresponding UI
145
+ - **No TODO/FIXME** - Complete the work, don't leave placeholders
146
+ - **No console.log** - No debug logs in production code
147
+ - **No circular deps** - Clean architecture required
148
+ - **Conventional commits** - `type(scope): description` format
153
149
 
150
+ ---
151
+
152
+ ## npm Scripts
153
+
154
+ ### Verification
154
155
  ```bash
155
- # Run all checks manually
156
- npx autoworkflow run
156
+ npm run verify # TypeScript + ESLint
157
+ npm run typecheck # TypeScript only
158
+ npm run lint # ESLint only
159
+ npm run format # Prettier format
160
+ ```
157
161
 
158
- # List all rules and their status
159
- npx autoworkflow list
162
+ ### Audits
163
+ ```bash
164
+ npm run audit:ui # Check orphan features (BLOCKING)
165
+ npm run audit:cycles # Check circular deps (BLOCKING)
166
+ npm run audit:all # Run all audits
167
+ ```
160
168
 
161
- # Validate a commit message
162
- npx autoworkflow commit-msg .git/COMMIT_EDITMSG
169
+ ### Workflow Automation
170
+ ```bash
171
+ npm run dyad:status # Show workflow status
172
+ npm run dyad:verify # Run verification
173
+ npm run dyad:commit # Commit with checks
174
+ npm run dyad:full # Full workflow
175
+ ```
163
176
 
164
- # Show help
165
- npx autoworkflow --help
177
+ ### Setup
178
+ ```bash
179
+ npm run setup:hooks # Install git hooks
166
180
  ```
167
181
 
168
- ## Fix Loop
182
+ ---
169
183
 
170
- When ESLint (or other auto-fixable rules) fail:
184
+ ## File Structure
171
185
 
172
186
  ```
173
- [1/5] ESLint... ❌
174
- src/app.ts: 'unused' is defined but never used
187
+ autoworkflow/
188
+ ├── CLAUDE.md # Entry point (Claude reads this first)
189
+
190
+ ├── system/ # Control Layer
191
+ │ ├── triggers.md # Event → Action mappings
192
+ │ ├── loops.md # Verify/fix cycle definitions
193
+ │ ├── gates.md # Blocking checkpoints
194
+ │ └── router.md # Task type routing
195
+
196
+ ├── instructions/ # Content Layer
197
+ │ ├── CLAUDE.md # Workflow steps (9 phases)
198
+ │ ├── AI_RULES.md # Coding standards
199
+ │ └── BLUEPRINT.md # Project specification
200
+
201
+ ├── .claude/ # Claude Code Integration
202
+ │ ├── settings.json # Settings + hard rules
203
+ │ └── commands/ # Slash command definitions
204
+ │ ├── analyze.md
205
+ │ ├── plan.md
206
+ │ ├── build.md
207
+ │ ├── verify.md
208
+ │ ├── fix.md
209
+ │ ├── audit.md
210
+ │ ├── suggest.md
211
+ │ └── commit.md
212
+
213
+ ├── scripts/ # Automation Scripts
214
+ │ ├── setup.sh # Initial setup
215
+ │ ├── autoworkflow.sh # Workflow automation
216
+ │ ├── check-ui-enforcement.sh
217
+ │ ├── run-verification.sh
218
+ │ └── ensure-no-errors.sh
219
+
220
+ ├── hooks/ # Git Hooks (backup enforcement)
221
+ │ ├── pre-commit # Blocks bad commits
222
+ │ └── commit-msg # Validates commit messages
223
+
224
+ ├── .vscode/ # VS Code Integration (optional)
225
+ │ ├── settings.json # Editor settings
226
+ │ ├── tasks.json # Runnable tasks
227
+ │ └── extensions.json # Recommended extensions
228
+
229
+ ├── .prettierrc # Prettier config
230
+ ├── eslint.config.example.js # ESLint config template
231
+ └── tsconfig.example.json # TypeScript config template
232
+ ```
175
233
 
176
- 🔧 Attempting auto-fix...
177
- ✅ Fixed: ESLint
234
+ ---
178
235
 
179
- 🔄 Fix Loop - Attempt 2/5
236
+ ## Why This Approach?
180
237
 
181
- [1/5] ESLint...
238
+ ### Dual Enforcement Strategy
182
239
 
183
- ALL CHECKS PASSED
184
- ```
240
+ **Primary: Claude as Enforcement Engine**
241
+ - Claude reads instructions from system prompts
242
+ - Claude follows the 9-phase workflow
243
+ - Claude enforces rules proactively as it works
244
+ - Claude explains what's happening
185
245
 
186
- ## Skip Enforcement (Emergency)
246
+ **Backup: Scripts & Git Hooks**
247
+ - Git hooks catch anything Claude misses
248
+ - Scripts automate verification
249
+ - Pre-commit blocks bad code from reaching the repo
187
250
 
188
- ```bash
189
- git commit --no-verify -m "emergency: hotfix for production"
190
- ```
251
+ ### Benefits
191
252
 
192
- Use sparingly. All skipped commits are your responsibility.
253
+ | Feature | Benefit |
254
+ |---------|---------|
255
+ | System prompts | No runtime code to maintain |
256
+ | Portable | Just copy files to any project |
257
+ | Transparent | Claude explains the workflow |
258
+ | Flexible | Claude adapts to context |
259
+ | Suggestions | Proactively improves code quality |
260
+ | Git hooks | Backup enforcement layer |
261
+ | npm scripts | Easy automation |
193
262
 
194
- ## Requirements
263
+ ---
195
264
 
196
- - Node.js >= 18.0.0
197
- - Git repository (initialized with `git init`)
265
+ ## Customization
198
266
 
199
- ### Optional Peer Dependencies
267
+ ### Adding Your Coding Standards
268
+ Edit `instructions/AI_RULES.md`:
269
+ ```markdown
270
+ ## ALWAYS
271
+ - Use TypeScript strict mode
272
+ - Handle all error cases
273
+ - Add loading states for async
200
274
 
201
- - TypeScript >= 5.0.0 (for TypeScript checks)
202
- - ESLint >= 8.0.0 (for ESLint checks)
275
+ ## NEVER
276
+ - Use `any` type
277
+ - Leave console.logs
278
+ - Skip error handling
279
+ ```
203
280
 
204
- ## VSCode Integration
281
+ ### Adding Your Project Spec
282
+ Edit `instructions/BLUEPRINT.md`:
283
+ ```markdown
284
+ ## Features
285
+ - [ ] User authentication
286
+ - [ ] Dashboard page
287
+ - [ ] Settings panel
205
288
 
206
- ### Auto-Fix on Save
289
+ ## Data Model
290
+ User: id, email, name, role
291
+ ```
207
292
 
208
- The generated `.vscode/settings.json` enables:
293
+ ### Adjusting Gates
294
+ Edit `system/gates.md` to change what blocks progress.
209
295
 
210
- - **Format on save** with Prettier
211
- - **ESLint auto-fix** on save
212
- - **Organize imports** on save
213
- - **Remove unused imports** on save
214
- - **Tailwind CSS** class sorting (clsx/cn support)
296
+ ### Adjusting Loops
297
+ Edit `system/loops.md` to change retry behavior.
215
298
 
216
- ### Quick Tasks (Cmd+Shift+B)
299
+ ---
217
300
 
218
- The generated `.vscode/tasks.json` provides:
301
+ ## Requirements
219
302
 
220
- | Task | Description |
221
- |------|-------------|
222
- | Autoworkflow: Run Checks | Run all enforcement checks |
223
- | Autoworkflow: TypeScript Check | TypeScript only |
224
- | Autoworkflow: ESLint Fix | Fix all ESLint issues |
225
- | Autoworkflow: List Rules | Show rule status |
226
- | Dev Server | Start npm run dev |
227
- | Quick Commit | Stage all + commit with prompt |
303
+ - VS Code with Claude Code extension
304
+ - Node.js 18+ (for npm scripts)
305
+ - TypeScript, ESLint, Prettier (for verification)
228
306
 
229
- ## AI Integration (CLAUDE.md)
307
+ ---
230
308
 
231
- The generated `CLAUDE.md` instructs Claude/AI assistants to:
309
+ ## What Gets Copied
232
310
 
233
- - Follow a structured workflow (Analyze Plan Confirm → Implement)
234
- - Show 3-tier suggestions (Required/Recommended/Optional)
235
- - Ask for confirmation before implementing
236
- - Use conventional commit messages
237
- - Respect all enforcement rules
311
+ When you install via npm, these files are available to copy:
238
312
 
239
- ## Uninstall
313
+ | Category | Files | Required? |
314
+ |----------|-------|-----------|
315
+ | Entry point | `CLAUDE.md` | ✅ Yes |
316
+ | Control layer | `system/` | ✅ Yes |
317
+ | Content layer | `instructions/` | ✅ Yes |
318
+ | Claude integration | `.claude/` | ✅ Yes |
319
+ | Automation | `scripts/` | Recommended |
320
+ | Git hooks | `hooks/` | Recommended |
321
+ | VS Code | `.vscode/` | Optional |
322
+ | Configs | `.prettierrc`, `*.example.*` | Optional |
240
323
 
241
- ```bash
242
- npm uninstall autoworkflow
243
- rm -rf .husky
244
- rm enforce.config.json
245
- rm CLAUDE.md
246
- rm -rf .vscode # Only if you want to remove VSCode settings
247
- ```
324
+ ---
248
325
 
249
326
  ## License
250
327
 
@@ -0,0 +1,83 @@
1
+ /**
2
+ * eslint.config.example.js
3
+ * AutoWorkflow ESLint Configuration
4
+ *
5
+ * This is a reference configuration that enforces the rules
6
+ * defined in CLAUDE.md and instructions/AI_RULES.md
7
+ *
8
+ * Copy to your project as: eslint.config.js
9
+ */
10
+
11
+ import js from '@eslint/js'
12
+ import globals from 'globals'
13
+ import reactHooks from 'eslint-plugin-react-hooks'
14
+ import reactRefresh from 'eslint-plugin-react-refresh'
15
+ import tseslint from 'typescript-eslint'
16
+
17
+ export default tseslint.config(
18
+ { ignores: ['dist', 'node_modules', 'coverage'] },
19
+ {
20
+ extends: [js.configs.recommended, ...tseslint.configs.recommended],
21
+ files: ['**/*.{ts,tsx}'],
22
+ languageOptions: {
23
+ ecmaVersion: 2020,
24
+ globals: globals.browser,
25
+ },
26
+ plugins: {
27
+ 'react-hooks': reactHooks,
28
+ 'react-refresh': reactRefresh,
29
+ },
30
+ rules: {
31
+ // ─────────────────────────────────────────────────────────────
32
+ // React Rules
33
+ // ─────────────────────────────────────────────────────────────
34
+ ...reactHooks.configs.recommended.rules,
35
+ 'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
36
+
37
+ // ─────────────────────────────────────────────────────────────
38
+ // TypeScript Rules (from AI_RULES.md)
39
+ // ─────────────────────────────────────────────────────────────
40
+ '@typescript-eslint/no-unused-vars': 'error',
41
+ '@typescript-eslint/no-explicit-any': 'error',
42
+ '@typescript-eslint/no-non-null-assertion': 'error',
43
+ '@typescript-eslint/explicit-function-return-type': 'off',
44
+ '@typescript-eslint/consistent-type-imports': [
45
+ 'error',
46
+ { prefer: 'type-imports' },
47
+ ],
48
+
49
+ // ─────────────────────────────────────────────────────────────
50
+ // Console Rules (BLOCKING - from CLAUDE.md)
51
+ // ─────────────────────────────────────────────────────────────
52
+ 'no-console': ['error', { allow: ['warn', 'error'] }],
53
+
54
+ // ─────────────────────────────────────────────────────────────
55
+ // Code Quality Rules (from AI_RULES.md)
56
+ // ─────────────────────────────────────────────────────────────
57
+ 'max-lines': ['warn', { max: 300, skipBlankLines: true, skipComments: true }],
58
+ 'max-lines-per-function': ['warn', { max: 75, skipBlankLines: true, skipComments: true }],
59
+ complexity: ['warn', 15],
60
+ 'no-nested-ternary': 'error',
61
+ eqeqeq: ['error', 'always'],
62
+
63
+ // ─────────────────────────────────────────────────────────────
64
+ // Best Practices
65
+ // ─────────────────────────────────────────────────────────────
66
+ 'prefer-const': 'error',
67
+ 'no-var': 'error',
68
+ 'object-shorthand': 'error',
69
+ 'prefer-template': 'error',
70
+ 'prefer-arrow-callback': 'error',
71
+ 'no-duplicate-imports': 'error',
72
+
73
+ // ─────────────────────────────────────────────────────────────
74
+ // Accessibility Rules (optional but recommended)
75
+ // ─────────────────────────────────────────────────────────────
76
+ // Note: Install eslint-plugin-jsx-a11y for these
77
+ // 'jsx-a11y/alt-text': 'error',
78
+ // 'jsx-a11y/anchor-has-content': 'error',
79
+ // 'jsx-a11y/aria-props': 'error',
80
+ // 'jsx-a11y/click-events-have-key-events': 'warn',
81
+ },
82
+ }
83
+ )