-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path.rules
More file actions
219 lines (155 loc) · 5.66 KB
/
Copy path.rules
File metadata and controls
219 lines (155 loc) · 5.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# kw-app — AI Rules
You are an AI coding agent operating inside the kw-app project.
You MUST follow these rules at all times.
---
## 1. Scope and Authority
These rules define:
- architectural constraints
- workflow discipline
- naming conventions
- testing and quality requirements
You MUST NOT:
- invent alternative architectures
- bypass documented workflows
- inline large code templates unless explicitly requested
- execute commands without proper environment flags
- create multiple documents per one AI session
Procedural details, commands, and examples live in documentation files.
You MUST reference them, not duplicate them.
---
## 2. Architecture (MANDATORY)
This project uses **Rails 7 + dry-rb** with operations-based architecture.
You MUST respect the following layering:
```
Request → Controller → Operation → Model → Database
↓ ↓
Form/ Validation
Contract
```
### Layer Responsibilities
| Layer | Location | Responsibility |
|-------|----------|----------------|
| Models | `app/models/db/` | Thin ActiveRecord (associations, validations, scopes) |
| Operations | `app/components/*/operation/` | Business logic (dry-monads) |
| Contracts/Forms | `app/components/*/contract/` | Input validation (dry-validation) |
| Controllers | `app/controllers/` | Thin HTTP adapters |
| Jobs | `app/jobs/` | Background processing (Sidekiq) |
Full architecture details: `docs/ARCHITECTURE.md`
---
## 3. dry-monads (MANDATORY for Operations)
All service objects/operations MUST use dry-monads.
You MUST:
- Include `Dry::Monads[:result, :do]`
- Return `Success(value)` or `Failure(error)`
- Use `yield` for chaining operations
You MUST NOT:
- Use custom `Result`, `Success`, `Failure` classes from `lib/` (DEPRECATED)
- Use `require 'result'` or similar
Pattern reference: `.agents/skills/dry-monads-patterns/SKILL.md`
---
## 4. Naming Conventions (STRICT)
| Component | Pattern | Example |
|-----------|---------|---------|
| Model | `Db::Resource` | `app/models/db/user.rb` |
| Operation | `Namespace::Operation::Action` | `app/components/users/operation/create.rb` |
| Contract | `Namespace::ContractForm` | `app/components/users/create_form.rb` |
| Job | `ActionJob` | `app/jobs/user_notification_job.rb` |
| Spec | mirrors source + `_spec.rb` | `spec/components/users/operation/create_spec.rb` |
File paths MUST mirror namespaces.
---
## 5. Docker Execution (MANDATORY)
All application commands MUST run inside Docker.
You MUST use:
- `docker-compose exec -T app bundle exec ...` for non-interactive commands
- `docker-compose exec app bundle exec ...` for interactive commands (console)
You MUST NOT:
- Run `bundle exec rspec` on host (wrong Ruby version)
- Run `rails console` on host
Exception: Kamal deployment commands use native Ruby with `chruby 3.2.2`.
Exact commands: `docs/DEV_COMMANDS.md`
---
## 6. Feature Development Workflow
When the user mentions `@feature` or requests a new feature:
You MUST follow the workflow defined in: `docs/FEATURE_WORKFLOW.md`
You MUST:
1. Ask clarifying questions ONE BY ONE (wait for answer)
2. Propose a solution before implementing
3. Wait for explicit approval before writing code
4. Write and run tests before declaring completion
You MUST NOT skip phases.
---
## 7. Testing Discipline (NON-NEGOTIABLE)
- All features MUST include tests
- Tests MUST be written before declaring completion
- Tests MUST run in Docker: `docker-compose exec -T app bundle exec rspec`
- All test failures MUST be fixed before completion
Testing patterns: `.agents/rspec.md`
---
## 8. Permission Boundaries
### ✅ Always Do
- Use Docker for ALL app commands
- Write tests for new features
- Use dry-monads for operations
- Check `docs/KNOWN_ISSUES.md` before debugging
- Run tests before marking work complete
### ⚠️ Ask First (Once Per Thread)
- Production database modifications
- Deployment config changes (`config/deploy.*.yml`)
- Git operations (commit, push, merge, rebase)
- Database migrations (must be reversible)
- Adding gems to Gemfile
- Modifying existing validations or associations
### 🚫 Never Do
- Hardcode secrets or credentials
- Remove security features
- Run tests outside Docker
- Use custom Result classes (deprecated)
- Skip tests
- Modify `vendor/`, `node_modules/`, `.git/`
- Commit `*.key` files
---
## 9. Code Quality Gates
Before completing any task:
- Linter passes (RuboCop)
- Tests pass
- Architecture boundaries respected
- Frozen string literals present (Ruby files)
Quality commands: `docs/DEV_COMMANDS.md`
---
## 10. Code Templates
When generating new components, use templates from: `templates/`
---
## 11. Output Expectations
- Prefer small, focused diffs
- Explain architectural decisions briefly
- Never generate speculative or placeholder code
- Ask for clarification when requirements are ambiguous
- Reference documentation instead of repeating it
---
## 12. Documentation References
| Document | Purpose |
|----------|---------|
| `docs/ARCHITECTURE.md` | Full architecture details |
| `docs/DEV_COMMANDS.md` | All shell commands |
| `docs/FEATURE_WORKFLOW.md` | @feature workflow phases |
| `docs/KNOWN_ISSUES.md` | Known bugs and solutions |
| `AGENTS.md` | Available agents and routing |
| `.agents/` | Individual agent specifications |
| `.agents/skills/` | Deep-dive knowledge modules |
| `templates/` | Code templates |
---
## 13. Tech Stack Reference
| Component | Version |
|-----------|---------|
| Ruby | 3.2.2 |
| Rails | 7.0.8 |
| PostgreSQL | 10.3 |
| Redis | 7 |
| Sidekiq | Background jobs |
| dry-monads | Operations |
| dry-validation | Form validation |
| RSpec | Testing |
| Docker | Development |
| Kamal | Deployment |
---
These rules override default AI behavior.