@punks/cli 3.1.10 → 3.1.12

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.
Files changed (76) hide show
  1. package/dist/BASELINE_CHANGELOG.md +61 -0
  2. package/dist/CHANGELOG.md +57 -0
  3. package/dist/data/subagents/manifest.mjs +11 -6
  4. package/dist/index.js +28 -28
  5. package/dist/skills/agnostic/cli/hi-cli/references/post-command-flow.md +5 -0
  6. package/dist/skills/agnostic/docs/writing-beats/LICENSE +21 -0
  7. package/dist/skills/agnostic/docs/writing-beats/UPSTREAM.md +11 -0
  8. package/dist/skills/agnostic/docs/writing-fragments/LICENSE +21 -0
  9. package/dist/skills/agnostic/docs/writing-fragments/UPSTREAM.md +11 -0
  10. package/dist/skills/agnostic/docs/writing-shape/LICENSE +21 -0
  11. package/dist/skills/agnostic/docs/writing-shape/UPSTREAM.md +11 -0
  12. package/dist/skills/agnostic/frontend/frontend-domain-structure/SKILL.md +24 -42
  13. package/dist/skills/agnostic/frontend/frontend-domain-structure/agents/openai.yaml +1 -1
  14. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/react/structure.md +51 -78
  15. package/dist/skills/agnostic/frontend/frontend-domain-structure/references/structure.md +89 -212
  16. package/dist/skills/agnostic/generic/handoff/LICENSE +21 -0
  17. package/dist/skills/agnostic/generic/handoff/UPSTREAM.md +11 -0
  18. package/dist/skills/agnostic/planning/create-plan/REFERENCE.md +1 -1
  19. package/dist/skills/agnostic/planning/create-plan/SKILL.md +19 -7
  20. package/dist/skills/agnostic/planning/create-plan/references/plan-schema.md +19 -0
  21. package/dist/skills/agnostic/planning/create-plan/references/planner-task-graph.md +27 -10
  22. package/dist/skills/agnostic/planning/implement-spec/SKILL.md +6 -2
  23. package/dist/skills/agnostic/planning/implement-spec/assets/IMPLEMENTATION-NOTES-TEMPLATE.md +22 -6
  24. package/dist/skills/agnostic/planning/implement-spec/references/lifecycle.md +12 -0
  25. package/dist/skills/agnostic/planning/implement-spec/references/parallel-orchestration.md +10 -2
  26. package/dist/skills/agnostic/planning/implement-spec/references/parallel-worker-brief.md +10 -1
  27. package/dist/skills/agnostic/planning/implement-spec/references/parallel.md +2 -0
  28. package/dist/skills/agnostic/quality/autoreview/SKILL.md +11 -2
  29. package/dist/skills/agnostic/quality/codebase-design/LICENSE +21 -0
  30. package/dist/skills/agnostic/quality/codebase-design/UPSTREAM.md +11 -0
  31. package/dist/skills/agnostic/quality/review/LICENSE +21 -0
  32. package/dist/skills/agnostic/quality/review/SKILL.md +16 -11
  33. package/dist/skills/agnostic/quality/review/UPSTREAM.md +11 -0
  34. package/dist/skills/agnostic/quality/tdd/LICENSE +21 -0
  35. package/dist/skills/agnostic/quality/tdd/UPSTREAM.md +11 -0
  36. package/dist/skills/agnostic/research/improve-codebase-architecture/LICENSE +21 -0
  37. package/dist/skills/agnostic/research/improve-codebase-architecture/UPSTREAM.md +11 -0
  38. package/dist/skills/frameworks/effect/effect/SKILL.md +5 -12
  39. package/dist/skills/frameworks/effect/effect/references/CONFIG.md +10 -19
  40. package/dist/skills/frameworks/effect/effect/references/SERVICES_LAYERS.md +3 -63
  41. package/dist/skills/frameworks/effect/effect/references/TESTING.md +2 -72
  42. package/dist/skills/frameworks/effect/effect-backend-structure/SKILL.md +12 -29
  43. package/dist/skills/frameworks/effect/effect-backend-structure/agents/openai.yaml +1 -1
  44. package/dist/skills/frameworks/effect/effect-backend-structure/references/layout.md +9 -9
  45. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/SKILL.md +199 -0
  46. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/UPSTREAM.md +31 -0
  47. package/dist/skills/frameworks/sqlalchemy/sqlalchemy-schema-design/agents/openai.yaml +4 -0
  48. package/dist/skills/languages/python/python-backend-structure/SKILL.md +91 -0
  49. package/dist/skills/languages/python/python-backend-structure/agents/openai.yaml +4 -0
  50. package/dist/skills/languages/python/python-design-patterns/SKILL.md +93 -69
  51. package/dist/skills/languages/python/python-project-structure/SKILL.md +4 -247
  52. package/dist/skills/phases/delivery-phase/SKILL.md +13 -4
  53. package/dist/skills/phases/delivery-phase/phases/closeout.md +3 -0
  54. package/dist/skills/phases/delivery-phase/phases/debug.md +8 -1
  55. package/dist/skills/phases/delivery-phase/phases/implement.md +11 -2
  56. package/dist/skills/phases/delivery-phase/phases/review.md +50 -29
  57. package/dist/skills/phases/delivery-phase/phases/router.md +56 -36
  58. package/dist/skills/phases/delivery-phase/references/artifact-state.md +8 -2
  59. package/dist/skills/phases/delivery-phase/references/phase-handoff.md +60 -10
  60. package/dist/skills/phases/finder-phase/references/root-routing.md +6 -1
  61. package/dist/skills/phases/prototype-phase/agents/openai.yaml +2 -0
  62. package/dist/skills/phases/review-phase/AUTHORING-HANDOFF.md +622 -0
  63. package/dist/skills/phases/review-phase/SKILL.md +11 -42
  64. package/dist/skills/phases/review-phase/agents/openai.yaml +2 -0
  65. package/dist/skills/phases/review-phase/phases/prepare-review.md +105 -0
  66. package/dist/skills/phases/review-phase/phases/retain-report.md +113 -0
  67. package/dist/skills/phases/review-phase/phases/return-route.md +95 -0
  68. package/dist/skills/phases/review-phase/phases/router.md +78 -0
  69. package/dist/skills/phases/review-phase/phases/run-review.md +128 -0
  70. package/dist/skills/phases/review-phase/references/durable-report.md +153 -0
  71. package/dist/skills/phases/review-phase/references/runtime-handoff.md +138 -0
  72. package/dist/skills/phases/review-phase/references/state-graph.md +69 -0
  73. package/dist/skills/phases/review-phase/references/targets.md +156 -0
  74. package/dist/skills/phases/review-phase/scripts/review-contract.mjs +819 -0
  75. package/package.json +56 -2
  76. package/dist/skills/phases/review-phase/REFERENCE.md +0 -147
@@ -7,6 +7,8 @@ description: Python design patterns including KISS, Separation of Concerns, Sing
7
7
 
8
8
  Write maintainable Python code using fundamental design principles. These patterns help you build systems that are easy to understand, test, and modify.
9
9
 
10
+ For backend package topology and import direction, [python-backend-structure](../python-backend-structure/SKILL.md) is authoritative.
11
+
10
12
  ## When to Use This Skill
11
13
 
12
14
  - Designing new components or services
@@ -111,27 +113,34 @@ class UserHandler:
111
113
  # Response formatting
112
114
  return Response({"id": user.id, "email": user.email}, status=201)
113
115
 
114
- # GOOD: Separated concerns
115
- class UserService:
116
- """Business logic only."""
116
+ # GOOD: Parent-owned contracts describe dependencies; child packages own implementations
117
+ class UserRepository(Protocol):
118
+ async def save(self, user: User) -> User:
119
+ ...
120
+
121
+ class CreateUser(Protocol):
122
+ async def __call__(self, data: CreateUserInput) -> User:
123
+ ...
124
+
125
+ class CreateUserAction:
126
+ """Use-case policy."""
117
127
 
118
- def __init__(self, repo: UserRepository) -> None:
119
- self._repo = repo
128
+ def __init__(self, repository: UserRepository) -> None:
129
+ self._repository = repository
120
130
 
121
- async def create_user(self, data: CreateUserInput) -> User:
122
- # Only business rules here
131
+ async def __call__(self, data: CreateUserInput) -> User:
123
132
  user = User(email=data.email, name=data.name)
124
- return await self._repo.save(user)
133
+ return await self._repository.save(user)
125
134
 
126
135
  class UserHandler:
127
136
  """HTTP concerns only."""
128
137
 
129
- def __init__(self, service: UserService) -> None:
130
- self._service = service
138
+ def __init__(self, create_user: CreateUser) -> None:
139
+ self._create_user = create_user
131
140
 
132
141
  async def create_user(self, request: Request) -> Response:
133
142
  data = CreateUserInput(**(await request.json()))
134
- user = await self._service.create_user(data)
143
+ user = await self._create_user(data)
135
144
  return Response(user.to_dict(), status=201)
136
145
  ```
137
146
 
@@ -139,60 +148,70 @@ Now HTTP changes don't affect business logic, and vice versa.
139
148
 
140
149
  ### Pattern 3: Separation of Concerns
141
150
 
142
- Organize code into distinct layers with clear responsibilities.
151
+ Separate runtime call flow from Python import topology. A request may run through a handler, action, and repository capability, but peer packages at the same parent never import one another. They depend on parent-owned contracts and models; composition imports and wires their concrete implementations.
143
152
 
144
153
  ```
145
154
  ┌─────────────────────────────────────────────────────┐
146
- │ API Layer (handlers) │
155
+ │ Transport handler │
147
156
  │ - Parse requests │
148
- │ - Call services │
157
+ │ - Call an injected action contract │
149
158
  │ - Format responses │
150
159
  └─────────────────────────────────────────────────────┘
151
160
  │
161
+ │ runtime call
152
162
  ▼
153
163
  ┌─────────────────────────────────────────────────────┐
154
- │ Service Layer (business logic) │
155
- │ - Domain rules and validation │
156
- │ - Orchestrate operations │
157
- │ - Pure functions where possible │
164
+ │ Action │
165
+ │ - Own use-case policy │
166
+ │ - Call an injected repository contract │
158
167
  └─────────────────────────────────────────────────────┘
159
168
  │
169
+ │ runtime call
160
170
  ▼
161
171
  ┌─────────────────────────────────────────────────────┐
162
- │ Repository Layer (data access) │
163
- │ - SQL queries │
164
- │ - External API calls │
165
- │ - Cache operations │
172
+ │ Repository adapter │
173
+ │ - Persistence reads and writes │
174
+ │ - Durable storage mapping │
175
+ │ - Transaction-shaped operations │
166
176
  └─────────────────────────────────────────────────────┘
167
177
  ```
168
178
 
169
- Each layer depends only on layers below it:
179
+ HTTP clients, external APIs, and caches belong behind integrations or adapters, not persistence repositories.
170
180
 
171
181
  ```python
172
- # Repository: Data access
173
- class UserRepository:
182
+ # Parent-owned contracts and models
183
+ class UserRepository(Protocol):
174
184
  async def get_by_id(self, user_id: str) -> User | None:
175
- row = await self._db.fetchrow(
176
- "SELECT * FROM users WHERE id = $1", user_id
177
- )
178
- return User(**row) if row else None
185
+ ...
186
+
187
+ class GetUser(Protocol):
188
+ async def __call__(self, user_id: str) -> User:
189
+ ...
179
190
 
180
- # Service: Business logic
181
- class UserService:
182
- def __init__(self, repo: UserRepository) -> None:
183
- self._repo = repo
191
+ # Action implementation: imports only parent contracts and models
192
+ class GetUserAction:
193
+ def __init__(self, repository: UserRepository) -> None:
194
+ self._repository = repository
184
195
 
185
- async def get_user(self, user_id: str) -> User:
186
- user = await self._repo.get_by_id(user_id)
196
+ async def __call__(self, user_id: str) -> User:
197
+ user = await self._repository.get_by_id(user_id)
187
198
  if user is None:
188
199
  raise UserNotFoundError(user_id)
189
200
  return user
190
201
 
191
- # Handler: HTTP concerns
192
- @app.get("/users/{user_id}")
193
- async def get_user(user_id: str) -> UserResponse:
194
- user = await user_service.get_user(user_id)
195
- return UserResponse.from_user(user)
202
+ # Transport implementation: imports the parent action contract, not an action package
203
+ class UserHandler:
204
+ def __init__(self, get_user: GetUser) -> None:
205
+ self._get_user = get_user
206
+
207
+ async def handle(self, user_id: str) -> UserResponse:
208
+ user = await self._get_user(user_id)
209
+ return UserResponse.from_user(user)
210
+
211
+ # Parent composition: the only place that imports and selects implementations
212
+ repository: UserRepository = StoredUserRepository(storage)
213
+ get_user: GetUser = GetUserAction(repository)
214
+ handler = UserHandler(get_user)
196
215
  ```
197
216
 
198
217
  ### Pattern 4: Composition Over Inheritance
@@ -308,58 +327,63 @@ def process_order(order: Order) -> Result:
308
327
 
309
328
  ### Pattern 7: Dependency Injection
310
329
 
311
- Pass dependencies through constructors for testability.
330
+ Pass parent-owned capability contracts through constructors. Child implementations import those leaf Protocols; parent composition selects implementations and wires them.
312
331
 
313
332
  ```python
314
- from typing import Protocol
315
-
316
- class Logger(Protocol):
317
- def info(self, msg: str, **kwargs) -> None: ...
318
- def error(self, msg: str, **kwargs) -> None: ...
333
+ class UserRepository(Protocol):
334
+ async def get_by_id(self, user_id: str) -> User | None:
335
+ ...
319
336
 
320
- class Cache(Protocol):
337
+ class UserCache(Protocol):
321
338
  async def get(self, key: str) -> str | None: ...
322
339
  async def set(self, key: str, value: str, ttl: int) -> None: ...
323
340
 
324
- class UserService:
325
- """Service with injected dependencies."""
341
+ class AuditLog(Protocol):
342
+ def info(self, event: str, **fields: str) -> None:
343
+ ...
344
+
345
+ class GetUser(Protocol):
346
+ async def __call__(self, user_id: str) -> User | None:
347
+ ...
326
348
 
349
+ class GetUserAction:
327
350
  def __init__(
328
351
  self,
329
352
  repository: UserRepository,
330
- cache: Cache,
331
- logger: Logger,
353
+ cache: UserCache,
354
+ audit_log: AuditLog,
332
355
  ) -> None:
333
- self._repo = repository
356
+ self._repository = repository
334
357
  self._cache = cache
335
- self._logger = logger
358
+ self._audit_log = audit_log
336
359
 
337
- async def get_user(self, user_id: str) -> User:
338
- # Check cache first
360
+ async def __call__(self, user_id: str) -> User | None:
339
361
  cached = await self._cache.get(f"user:{user_id}")
340
362
  if cached:
341
- self._logger.info("Cache hit", user_id=user_id)
363
+ self._audit_log.info("user_cache_hit", user_id=user_id)
342
364
  return User.from_json(cached)
343
365
 
344
- # Fetch from database
345
- user = await self._repo.get_by_id(user_id)
366
+ user = await self._repository.get_by_id(user_id)
346
367
  if user:
347
368
  await self._cache.set(f"user:{user_id}", user.to_json(), ttl=300)
348
369
 
349
370
  return user
350
371
 
351
- # Production
352
- service = UserService(
353
- repository=PostgresUserRepository(db),
354
- cache=RedisCache(redis),
355
- logger=StructlogLogger(),
372
+ # Parent composition selects implementations and wires the action
373
+ repository: UserRepository = StoredUserRepository(storage)
374
+ cache: UserCache = ExternalUserCache(cache_client)
375
+ audit_log: AuditLog = ApplicationAuditLog(log_sink)
376
+ get_user: GetUser = GetUserAction(
377
+ repository=repository,
378
+ cache=cache,
379
+ audit_log=audit_log,
356
380
  )
357
381
 
358
- # Testing
359
- service = UserService(
382
+ # A focused test supplies the same parent-owned contracts
383
+ get_user = GetUserAction(
360
384
  repository=InMemoryUserRepository(),
361
- cache=FakeCache(),
362
- logger=NullLogger(),
385
+ cache=FakeUserCache(),
386
+ audit_log=RecordingAuditLog(),
363
387
  )
364
388
  ```
365
389
 
@@ -425,9 +449,9 @@ Keep the composition shallow (2-3 levels). If wrapping is the only mechanism, co
425
449
  Duplication that diverges in dangerous ways should be abstracted sooner. The rule of three is a heuristic, not a law. If the copies are already diverging incorrectly, extract immediately and add a test that exercises the shared behavior.
426
450
 
427
451
  **A service layer is importing from the API layer, breaking the dependency direction.**
428
- This is a layering violation. The service layer must not import from handlers. Introduce a shared types/models layer that both can import from, keeping the dependency arrow pointing downward (API → Service → Repository).
452
+ This is an ownership violation. Runtime calls may flow from transport through an action to a repository capability, but sibling packages do not encode that flow by importing one another. Move contracts and models to their honest parent, inject them into children, and let parent composition wire implementations.
429
453
 
430
454
  ## Related Skills
431
455
 
432
456
  - [python-testing-patterns](../python-testing-patterns/SKILL.md) — Test each layer in isolation using the dependency injection structure established here
433
- - [python-project-setup](../python-project-setup/SKILL.md) — Set up project structure and tooling that enforces layer boundaries from the start
457
+ - [python-backend-structure](../python-backend-structure/SKILL.md) — Python backend domains, composition, and import boundaries
@@ -1,252 +1,9 @@
1
1
  ---
2
2
  name: python-project-structure
3
- description: Python project organization, module architecture, and public API design. Use when setting up new projects, organizing modules, defining public interfaces with __all__, or planning directory layouts.
3
+ description: Deprecated compatibility alias for python-backend-structure.
4
+ disable-model-invocation: true
4
5
  ---
5
6
 
6
- # Python Project Structure & Module Architecture
7
+ # Deprecated
7
8
 
8
- Design well-organized Python projects with clear module boundaries, explicit public interfaces, and maintainable directory structures. Good organization makes code discoverable and changes predictable.
9
-
10
- ## When to Use This Skill
11
-
12
- - Starting a new Python project from scratch
13
- - Reorganizing an existing codebase for clarity
14
- - Defining module public APIs with `__all__`
15
- - Deciding between flat and nested directory structures
16
- - Determining test file placement strategies
17
- - Creating reusable library packages
18
-
19
- ## Core Concepts
20
-
21
- ### 1. Module Cohesion
22
-
23
- Group related code that changes together. A module should have a single, clear purpose.
24
-
25
- ### 2. Explicit Interfaces
26
-
27
- Define what's public with `__all__`. Everything not listed is an internal implementation detail.
28
-
29
- ### 3. Flat Hierarchies
30
-
31
- Prefer shallow directory structures. Add depth only for genuine sub-domains.
32
-
33
- ### 4. Consistent Conventions
34
-
35
- Apply naming and organization patterns uniformly across the project.
36
-
37
- ## Quick Start
38
-
39
- ```
40
- myproject/
41
- ├── src/
42
- │ └── myproject/
43
- │ ├── __init__.py
44
- │ ├── services/
45
- │ ├── models/
46
- │ └── api/
47
- ├── tests/
48
- ├── pyproject.toml
49
- └── README.md
50
- ```
51
-
52
- ## Fundamental Patterns
53
-
54
- ### Pattern 1: One Concept Per File
55
-
56
- Each file should focus on a single concept or closely related set of functions. Consider splitting when a file:
57
-
58
- - Handles multiple unrelated responsibilities
59
- - Grows beyond 300-500 lines (varies by complexity)
60
- - Contains classes that change for different reasons
61
-
62
- ```python
63
- # Good: Focused files
64
- # user_service.py - User business logic
65
- # user_repository.py - User data access
66
- # user_models.py - User data structures
67
-
68
- # Avoid: Kitchen sink files
69
- # user.py - Contains service, repository, models, utilities...
70
- ```
71
-
72
- ### Pattern 2: Explicit Public APIs with `__all__`
73
-
74
- Define the public interface for every module. Unlisted members are internal implementation details.
75
-
76
- ```python
77
- # mypackage/services/__init__.py
78
- from .user_service import UserService
79
- from .order_service import OrderService
80
- from .exceptions import ServiceError, ValidationError
81
-
82
- __all__ = [
83
- "UserService",
84
- "OrderService",
85
- "ServiceError",
86
- "ValidationError",
87
- ]
88
-
89
- # Internal helpers remain private by omission
90
- # from .internal_helpers import _validate_input # Not exported
91
- ```
92
-
93
- ### Pattern 3: Flat Directory Structure
94
-
95
- Prefer minimal nesting. Deep hierarchies make imports verbose and navigation difficult.
96
-
97
- ```
98
- # Preferred: Flat structure
99
- project/
100
- ├── api/
101
- │ ├── routes.py
102
- │ └── middleware.py
103
- ├── services/
104
- │ ├── user_service.py
105
- │ └── order_service.py
106
- ├── models/
107
- │ ├── user.py
108
- │ └── order.py
109
- └── utils/
110
- └── validation.py
111
-
112
- # Avoid: Deep nesting
113
- project/core/internal/services/impl/user/
114
- ```
115
-
116
- Add sub-packages only when there's a genuine sub-domain requiring isolation.
117
-
118
- ### Pattern 4: Test File Organization
119
-
120
- Choose one approach and apply it consistently throughout the project.
121
-
122
- **Option A: Colocated Tests**
123
-
124
- ```
125
- src/
126
- ├── user_service.py
127
- ├── test_user_service.py
128
- ├── order_service.py
129
- └── test_order_service.py
130
- ```
131
-
132
- Benefits: Tests live next to the code they verify. Easy to see coverage gaps.
133
-
134
- **Option B: Parallel Test Directory**
135
-
136
- ```
137
- src/
138
- ├── services/
139
- │ ├── user_service.py
140
- │ └── order_service.py
141
- tests/
142
- ├── services/
143
- │ ├── test_user_service.py
144
- │ └── test_order_service.py
145
- ```
146
-
147
- Benefits: Clean separation between production and test code. Standard for larger projects.
148
-
149
- ## Advanced Patterns
150
-
151
- ### Pattern 5: Package Initialization
152
-
153
- Use `__init__.py` to provide a clean public interface for package consumers.
154
-
155
- ```python
156
- # mypackage/__init__.py
157
- """MyPackage - A library for doing useful things."""
158
-
159
- from .core import MainClass, HelperClass
160
- from .exceptions import PackageError, ConfigError
161
- from .config import Settings
162
-
163
- __all__ = [
164
- "MainClass",
165
- "HelperClass",
166
- "PackageError",
167
- "ConfigError",
168
- "Settings",
169
- ]
170
-
171
- __version__ = "1.0.0"
172
- ```
173
-
174
- Consumers can then import directly from the package:
175
-
176
- ```python
177
- from mypackage import MainClass, Settings
178
- ```
179
-
180
- ### Pattern 6: Layered Architecture
181
-
182
- Organize code by architectural layer for clear separation of concerns.
183
-
184
- ```
185
- myapp/
186
- ├── api/ # HTTP handlers, request/response
187
- │ ├── routes/
188
- │ └── middleware/
189
- ├── services/ # Business logic
190
- ├── repositories/ # Data access
191
- ├── models/ # Domain entities
192
- ├── schemas/ # API schemas (Pydantic)
193
- └── config/ # Configuration
194
- ```
195
-
196
- Each layer should only depend on layers below it, never above.
197
-
198
- ### Pattern 7: Domain-Driven Structure
199
-
200
- For complex applications, organize by business domain rather than technical layer.
201
-
202
- ```
203
- ecommerce/
204
- ├── users/
205
- │ ├── models.py
206
- │ ├── services.py
207
- │ ├── repository.py
208
- │ └── api.py
209
- ├── orders/
210
- │ ├── models.py
211
- │ ├── services.py
212
- │ ├── repository.py
213
- │ └── api.py
214
- └── shared/
215
- ├── database.py
216
- └── exceptions.py
217
- ```
218
-
219
- ## File and Module Naming
220
-
221
- ### Conventions
222
-
223
- - Use `snake_case` for all file and module names: `user_repository.py`
224
- - Avoid abbreviations that obscure meaning: `user_repository.py` not `usr_repo.py`
225
- - Match class names to file names: `UserService` in `user_service.py`
226
-
227
- ### Import Style
228
-
229
- Use absolute imports for clarity and reliability:
230
-
231
- ```python
232
- # Preferred: Absolute imports
233
- from myproject.services import UserService
234
- from myproject.models import User
235
-
236
- # Avoid: Relative imports
237
- from ..services import UserService
238
- from . import models
239
- ```
240
-
241
- Relative imports can break when modules are moved or reorganized.
242
-
243
- ## Best Practices Summary
244
-
245
- 1. **Keep files focused** - One concept per file, consider splitting at 300-500 lines (varies by complexity)
246
- 2. **Define `__all__` explicitly** - Make public interfaces clear
247
- 3. **Prefer flat structures** - Add depth only for genuine sub-domains
248
- 4. **Use absolute imports** - More reliable and clearer
249
- 5. **Be consistent** - Apply patterns uniformly across the project
250
- 6. **Match names to content** - File names should describe their purpose
251
- 7. **Separate concerns** - Keep layers distinct and dependencies flowing one direction
252
- 8. **Document your structure** - Include a README explaining the organization
9
+ Use `$python-backend-structure`. This old skill ID remains only as a compatibility redirect and contains no architecture guidance.
@@ -11,7 +11,8 @@ disable-model-invocation: true
11
11
  `delivery-phase` is a reusable phase router.
12
12
 
13
13
  1. Read [phases/router.md](phases/router.md).
14
- 2. Inspect only enough issue, spec, plan, notes, diff, review, validation, and docs state to choose the current gate.
14
+ 2. Inspect only enough issue, spec, plan, notes, diff, retained review, durable
15
+ handoff, validation, and docs state to choose the current gate.
15
16
  3. If approved artifact links or UI Evidence links are present, carry them as routing evidence.
16
17
  4. Load exactly one phase file from `phases/`.
17
18
  5. Complete that phase, write the phase outcome, then stop or re-enter `delivery-phase` to route again.
@@ -32,7 +33,8 @@ Completion of one phase does not imply loading the rest of the chain.
32
33
  - [phases/backlog.md](phases/backlog.md): verify or project the agent-ready spec into delivery backlog items.
33
34
  - [phases/plan.md](phases/plan.md): create or repair the execution-ready plan.
34
35
  - [phases/implement.md](phases/implement.md): execute the accepted plan.
35
- - [phases/review.md](phases/review.md): run mandatory review and classify findings.
36
+ - [phases/review.md](phases/review.md): prepare the explicit review handoff or
37
+ classify findings from a retained report.
36
38
  - [phases/debug.md](phases/debug.md): investigate runtime-evidence failures.
37
39
  - [phases/docs-ingest.md](phases/docs-ingest.md): ingest docs-affecting changes or record a no-op.
38
40
  - [phases/closeout.md](phases/closeout.md): finish stack, tracker, PR, validation, and final report state.
@@ -42,8 +44,15 @@ Completion of one phase does not imply loading the rest of the chain.
42
44
  - Do not read phase files other than `router.md` until the router selects them.
43
45
  - Do not activate child skills at delivery start.
44
46
  - Reuse fresh matching artifacts before loading creation skills.
45
- - A phase may delegate to `create-spec`, `write-backlog`, `create-plan`, `implement-spec`, `review-phase`, `debugging-phase`, `docs-ingest-phase`, or `stack` only from its own phase file.
46
- - After a phase completes, write enough state for future resume. See [references/phase-handoff.md](references/phase-handoff.md).
47
+ - A phase may delegate to `create-spec`, `write-backlog`, `create-plan`,
48
+ `implement-spec`, `debugging-phase`, `docs-ingest-phase`, or `stack` only from
49
+ its own phase file.
50
+ - `review-phase` is user-invoked. Only below the three-pass budget may delivery
51
+ persist `review_due` and return the exact `$review-phase` invocation context,
52
+ then delivery stops. It never invokes that skill itself.
53
+ - After a phase completes, write enough state for future resume. Review-triggered
54
+ repair uses the idempotent fields in
55
+ [references/phase-handoff.md](references/phase-handoff.md).
47
56
 
48
57
  ## Stop Conditions
49
58
 
@@ -9,6 +9,9 @@ docs ingest or no-op, and validation are complete.
9
9
  - Report phase path actually taken; do not imply skipped phases ran.
10
10
  - Report validation commands, browser checks, smoke tests, or manual scenarios.
11
11
  - Report review result and whether findings remain.
12
+ - When fix 3 occurred, require `clean_handoff` linking immutable review-3 report,
13
+ final changes, passing focused validation, and clean status. Do not require a
14
+ fourth review.
12
15
  - Report debugging result or explicit skip reason.
13
16
  - Report docs ingest result or explicit no-op reason.
14
17
  - For UI changes, verify the PR body, PR comment, or PR-ready handoff includes durable before/after `UI Evidence` links.
@@ -16,6 +16,13 @@ Load `debugging-phase` only after this phase is selected.
16
16
  - Speculative parallel fixes are not allowed.
17
17
  - If the bug is broader than delivery scope, capture debt or open a separate
18
18
  debugging goal.
19
+ - Preserve review lineage, `review_count`, `repair_count`, and the opening
20
+ `review_run_id` through the repair.
21
+ - After an ordinary fix with `review_count < 3`, stale the preceding report and
22
+ enter `review_due`.
23
+ - After debug fix 3 (`review_count = 3`, `repair_count = 3`), enter
24
+ `focused_validation`. Failure resumes `debug_active` in epoch 3 without a
25
+ counter change; passing records `clean_handoff`. Fix 3 never opens review 4.
19
26
 
20
27
  ## Completion State
21
28
 
@@ -25,6 +32,6 @@ Write or verify:
25
32
  - root cause or narrowed hypothesis
26
33
  - fix or explicit blocker
27
34
  - rerun validation
28
- - whether another review is required
35
+ - resulting state and preserved counter evidence
29
36
 
30
37
  Then stop or re-enter `delivery-phase` for routing.
@@ -1,7 +1,7 @@
1
1
  # Implement Phase
2
2
 
3
3
  Use this phase when an accepted plan exists and implementation work remains, or
4
- when review returned in-scope non-runtime blockers.
4
+ when a retained review opened `repair_active` for in-scope non-runtime blockers.
5
5
 
6
6
  ## Delegate
7
7
 
@@ -18,6 +18,14 @@ Load `implement-spec` only after this phase is selected.
18
18
  - Parent orchestration owns shared notes and final validation evidence.
19
19
  - For UI work, require `implement-spec` to carry durable before/after links through `UI Evidence Links`; use `repo-asset-management` only through that evidence contract.
20
20
  - If runtime evidence appears during validation, finish the phase handoff and route to debug.
21
+ - Preserve review lineage, `review_count`, `repair_count`, and the opening
22
+ `review_run_id` through the repair.
23
+ - After an ordinary repair with `review_count < 3`, stale the preceding report
24
+ and enter `review_due` with the changed target identity.
25
+ - After fix 3 (`review_count = 3`, `repair_count = 3`), enter
26
+ `focused_validation`. Run only the focused validation required by accepted
27
+ evidence. Failure remains `repair_active` in epoch 3; passing records
28
+ `clean_handoff`. Fix 3 never opens review 4.
21
29
 
22
30
  ## Completion State
23
31
 
@@ -28,6 +36,7 @@ Write or verify:
28
36
  - validation commands and results
29
37
  - UI Evidence links for changed user-visible surfaces, or explicit no-op reason
30
38
  - remaining blockers or follow-up debt
31
- - whether mandatory review is now needed
39
+ - resulting state: `review_due`, `debug_active`, `focused_validation`,
40
+ `clean_handoff`, or blocked
32
41
 
33
42
  Then stop or re-enter `delivery-phase` for routing.