@smicolon/ai-kit 0.3.2 → 0.4.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.
Files changed (155) hide show
  1. package/README.md +73 -40
  2. package/dist/index.js +312 -127
  3. package/package.json +5 -5
  4. package/.claude-plugin/marketplace.json +0 -369
  5. package/packs/architect/CHANGELOG.md +0 -17
  6. package/packs/architect/README.md +0 -58
  7. package/packs/architect/agents/system-architect.md +0 -768
  8. package/packs/architect/commands/diagram-create.md +0 -300
  9. package/packs/better-auth/.mcp.json +0 -14
  10. package/packs/better-auth/CHANGELOG.md +0 -26
  11. package/packs/better-auth/README.md +0 -125
  12. package/packs/better-auth/agents/auth-architect.md +0 -278
  13. package/packs/better-auth/commands/auth-provider-add.md +0 -265
  14. package/packs/better-auth/commands/auth-setup.md +0 -298
  15. package/packs/better-auth/skills/auth-security/SKILL.md +0 -425
  16. package/packs/better-auth/skills/better-auth-patterns/SKILL.md +0 -455
  17. package/packs/dev-loop/CHANGELOG.md +0 -69
  18. package/packs/dev-loop/README.md +0 -155
  19. package/packs/dev-loop/commands/cancel-dev.md +0 -21
  20. package/packs/dev-loop/commands/dev-loop.md +0 -72
  21. package/packs/dev-loop/commands/dev-plan.md +0 -351
  22. package/packs/dev-loop/hooks/hooks.json +0 -15
  23. package/packs/dev-loop/hooks/stop-hook.sh +0 -178
  24. package/packs/dev-loop/scripts/setup-dev-loop.sh +0 -194
  25. package/packs/dev-loop/skills/tdd-planner/SKILL.md +0 -249
  26. package/packs/dev-loop/skills/tdd-planner/references/framework-patterns.md +0 -874
  27. package/packs/dev-loop/skills/tdd-planner/references/good-example.md +0 -260
  28. package/packs/dev-loop/skills/tdd-planner/references/plan-template.md +0 -275
  29. package/packs/django/CHANGELOG.md +0 -39
  30. package/packs/django/README.md +0 -92
  31. package/packs/django/agents/django-architect.md +0 -182
  32. package/packs/django/agents/django-builder.md +0 -250
  33. package/packs/django/agents/django-feature-based.md +0 -420
  34. package/packs/django/agents/django-reviewer.md +0 -253
  35. package/packs/django/agents/django-tester.md +0 -230
  36. package/packs/django/commands/api-endpoint.md +0 -285
  37. package/packs/django/commands/model-create.md +0 -178
  38. package/packs/django/commands/test-generate.md +0 -325
  39. package/packs/django/rules/migrations.md +0 -138
  40. package/packs/django/rules/models.md +0 -167
  41. package/packs/django/rules/serializers.md +0 -126
  42. package/packs/django/rules/services.md +0 -131
  43. package/packs/django/rules/tests.md +0 -140
  44. package/packs/django/rules/views.md +0 -102
  45. package/packs/django/skills/import-convention-enforcer/SKILL.md +0 -226
  46. package/packs/django/skills/import-convention-enforcer/patterns/django-imports.md +0 -343
  47. package/packs/django/skills/migration-safety-checker/SKILL.md +0 -375
  48. package/packs/django/skills/model-entity-validator/SKILL.md +0 -298
  49. package/packs/django/skills/performance-optimizer/SKILL.md +0 -447
  50. package/packs/django/skills/red-phase-verifier/SKILL.md +0 -180
  51. package/packs/django/skills/security-first-validator/SKILL.md +0 -435
  52. package/packs/django/skills/test-coverage-advisor/SKILL.md +0 -394
  53. package/packs/django/skills/test-validity-checker/SKILL.md +0 -194
  54. package/packs/failure-log/CHANGELOG.md +0 -20
  55. package/packs/failure-log/README.md +0 -168
  56. package/packs/failure-log/commands/failure-add.md +0 -106
  57. package/packs/failure-log/commands/failure-list.md +0 -89
  58. package/packs/failure-log/hooks/hooks.json +0 -16
  59. package/packs/failure-log/hooks/scripts/inject-failures.sh +0 -64
  60. package/packs/failure-log/skills/failure-log-manager/SKILL.md +0 -164
  61. package/packs/flutter/CHANGELOG.md +0 -19
  62. package/packs/flutter/README.md +0 -170
  63. package/packs/flutter/agents/flutter-architect.md +0 -166
  64. package/packs/flutter/agents/flutter-builder.md +0 -303
  65. package/packs/flutter/agents/release-manager.md +0 -355
  66. package/packs/flutter/commands/fastlane-setup.md +0 -188
  67. package/packs/flutter/commands/flutter-build.md +0 -90
  68. package/packs/flutter/commands/flutter-deploy.md +0 -133
  69. package/packs/flutter/commands/flutter-test.md +0 -117
  70. package/packs/flutter/commands/signing-setup.md +0 -209
  71. package/packs/flutter/hooks/hooks.json +0 -17
  72. package/packs/flutter/skills/fastlane-knowledge/SKILL.md +0 -193
  73. package/packs/flutter/skills/flutter-architecture/SKILL.md +0 -127
  74. package/packs/flutter/skills/store-publishing/SKILL.md +0 -163
  75. package/packs/hono/CHANGELOG.md +0 -19
  76. package/packs/hono/README.md +0 -143
  77. package/packs/hono/agents/hono-architect.md +0 -240
  78. package/packs/hono/agents/hono-builder.md +0 -285
  79. package/packs/hono/agents/hono-reviewer.md +0 -279
  80. package/packs/hono/agents/hono-tester.md +0 -346
  81. package/packs/hono/commands/middleware-create.md +0 -223
  82. package/packs/hono/commands/project-init.md +0 -306
  83. package/packs/hono/commands/route-create.md +0 -153
  84. package/packs/hono/commands/rpc-client.md +0 -263
  85. package/packs/hono/skills/cloudflare-bindings/SKILL.md +0 -408
  86. package/packs/hono/skills/hono-patterns/SKILL.md +0 -309
  87. package/packs/hono/skills/rpc-typesafe/SKILL.md +0 -388
  88. package/packs/hono/skills/zod-validation/SKILL.md +0 -332
  89. package/packs/nestjs/CHANGELOG.md +0 -29
  90. package/packs/nestjs/README.md +0 -75
  91. package/packs/nestjs/agents/nestjs-architect.md +0 -402
  92. package/packs/nestjs/agents/nestjs-builder.md +0 -301
  93. package/packs/nestjs/agents/nestjs-tester.md +0 -437
  94. package/packs/nestjs/commands/module-create.md +0 -369
  95. package/packs/nestjs/rules/controllers.md +0 -92
  96. package/packs/nestjs/rules/dto.md +0 -124
  97. package/packs/nestjs/rules/entities.md +0 -102
  98. package/packs/nestjs/rules/services.md +0 -106
  99. package/packs/nestjs/skills/barrel-export-manager/SKILL.md +0 -389
  100. package/packs/nestjs/skills/import-convention-enforcer/SKILL.md +0 -365
  101. package/packs/nextjs/CHANGELOG.md +0 -36
  102. package/packs/nextjs/README.md +0 -76
  103. package/packs/nextjs/agents/frontend-tester.md +0 -680
  104. package/packs/nextjs/agents/frontend-visual.md +0 -820
  105. package/packs/nextjs/agents/nextjs-architect.md +0 -331
  106. package/packs/nextjs/agents/nextjs-modular.md +0 -433
  107. package/packs/nextjs/commands/component-create.md +0 -398
  108. package/packs/nextjs/rules/api-routes.md +0 -129
  109. package/packs/nextjs/rules/components.md +0 -106
  110. package/packs/nextjs/rules/hooks.md +0 -132
  111. package/packs/nextjs/skills/accessibility-validator/SKILL.md +0 -445
  112. package/packs/nextjs/skills/import-convention-enforcer/SKILL.md +0 -399
  113. package/packs/nextjs/skills/react-form-validator/SKILL.md +0 -569
  114. package/packs/nuxtjs/CHANGELOG.md +0 -30
  115. package/packs/nuxtjs/README.md +0 -56
  116. package/packs/nuxtjs/agents/frontend-tester.md +0 -680
  117. package/packs/nuxtjs/agents/frontend-visual.md +0 -820
  118. package/packs/nuxtjs/agents/nuxtjs-architect.md +0 -537
  119. package/packs/nuxtjs/commands/component-create.md +0 -223
  120. package/packs/nuxtjs/rules/components.md +0 -101
  121. package/packs/nuxtjs/rules/composables.md +0 -118
  122. package/packs/nuxtjs/rules/server-routes.md +0 -127
  123. package/packs/nuxtjs/skills/accessibility-validator/SKILL.md +0 -183
  124. package/packs/nuxtjs/skills/import-convention-enforcer/SKILL.md +0 -196
  125. package/packs/nuxtjs/skills/veevalidate-form-validator/SKILL.md +0 -190
  126. package/packs/onboard/CHANGELOG.md +0 -22
  127. package/packs/onboard/README.md +0 -103
  128. package/packs/onboard/agents/onboard-guide.md +0 -118
  129. package/packs/onboard/commands/onboard.md +0 -313
  130. package/packs/onboard/skills/onboard-context-provider/SKILL.md +0 -98
  131. package/packs/tanstack-router/CHANGELOG.md +0 -30
  132. package/packs/tanstack-router/README.md +0 -113
  133. package/packs/tanstack-router/agents/tanstack-architect.md +0 -173
  134. package/packs/tanstack-router/agents/tanstack-builder.md +0 -360
  135. package/packs/tanstack-router/agents/tanstack-tester.md +0 -454
  136. package/packs/tanstack-router/commands/form-create.md +0 -313
  137. package/packs/tanstack-router/commands/query-create.md +0 -263
  138. package/packs/tanstack-router/commands/route-create.md +0 -190
  139. package/packs/tanstack-router/commands/table-create.md +0 -413
  140. package/packs/tanstack-router/skills/ai-patterns/SKILL.md +0 -370
  141. package/packs/tanstack-router/skills/db-patterns/SKILL.md +0 -346
  142. package/packs/tanstack-router/skills/devtools-patterns/SKILL.md +0 -415
  143. package/packs/tanstack-router/skills/form-patterns/SKILL.md +0 -425
  144. package/packs/tanstack-router/skills/pacer-patterns/SKILL.md +0 -341
  145. package/packs/tanstack-router/skills/query-patterns/SKILL.md +0 -359
  146. package/packs/tanstack-router/skills/router-patterns/SKILL.md +0 -285
  147. package/packs/tanstack-router/skills/store-patterns/SKILL.md +0 -351
  148. package/packs/tanstack-router/skills/table-patterns/SKILL.md +0 -531
  149. package/packs/tanstack-router/skills/tanstack-conventions/SKILL.md +0 -428
  150. package/packs/tanstack-router/skills/virtual-patterns/SKILL.md +0 -490
  151. package/packs/worktree/CHANGELOG.md +0 -45
  152. package/packs/worktree/README.md +0 -219
  153. package/packs/worktree/commands/wt.md +0 -93
  154. package/packs/worktree/scripts/wt.sh +0 -957
  155. package/packs/worktree/skills/worktree-manager/SKILL.md +0 -113
@@ -1,230 +0,0 @@
1
- ---
2
- name: django-tester
3
- description: Testing expert for writing comprehensive Django tests with 90%+ coverage using pytest and factory_boy
4
- model: inherit
5
- skills:
6
- - test-coverage-advisor
7
- - test-validity-checker
8
- - import-convention-enforcer
9
- ---
10
-
11
- # Django Test Writer Command
12
-
13
- You are a testing expert writing comprehensive tests for Django applications.
14
-
15
- ## Current Task
16
- Write comprehensive tests for the specified feature or code.
17
-
18
- ## Testing Stack
19
- - pytest + pytest-django
20
- - factory_boy for fixtures
21
- - faker for test data
22
- - Target: 90%+ coverage
23
-
24
- ## Test Structure
25
-
26
- ```
27
- app/tests/
28
- ├── __init__.py
29
- ├── conftest.py # Shared fixtures
30
- ├── factories.py # Factory Boy factories
31
- ├── test_models.py # Model tests
32
- ├── test_services.py # Service layer tests
33
- └── test_views.py # API endpoint tests
34
- ```
35
-
36
- ## Test Patterns
37
-
38
- ### 1. Model Tests
39
- ```python
40
- import pytest
41
- import users.models as _users_models
42
-
43
- @pytest.mark.django_db
44
- class TestUserModel:
45
- """Tests for User model."""
46
-
47
- def test_create_user(self):
48
- """Test user creation with required fields."""
49
- user = _users_models.User.objects.create_user(
50
- email="test@example.com",
51
- password="testpass123"
52
- )
53
- assert user.email == "test@example.com"
54
- assert user.check_password("testpass123")
55
- assert user.is_deleted is False
56
- ```
57
-
58
- ### 2. Service Tests
59
- ```python
60
- import pytest
61
- import users.services as _users_services
62
- import users.tests.factories as _users_factories
63
-
64
- @pytest.mark.django_db
65
- class TestUserService:
66
- """Tests for UserService."""
67
-
68
- def test_create_user_success(self):
69
- """Test successful user creation."""
70
- user = _users_services.UserService.create_user(
71
- email="new@example.com",
72
- password="password123"
73
- )
74
- assert user.email == "new@example.com"
75
-
76
- def test_create_user_duplicate_email(self):
77
- """Test creating user with duplicate email raises error."""
78
- _users_factories.UserFactory(email="test@example.com")
79
-
80
- with pytest.raises(ValueError):
81
- _users_services.UserService.create_user(
82
- email="test@example.com",
83
- password="password123"
84
- )
85
- ```
86
-
87
- ### 3. API Tests
88
- ```python
89
- import pytest
90
- from rest_framework.test import APIClient
91
- import users.tests.factories as _users_factories
92
-
93
- @pytest.mark.django_db
94
- class TestUserViewSet:
95
- """Tests for User API endpoints."""
96
-
97
- def test_list_users_authenticated(self):
98
- """Test authenticated user can list users."""
99
- client = APIClient()
100
- user = _users_factories.UserFactory()
101
- client.force_authenticate(user=user)
102
-
103
- response = client.get('/api/v1/users/')
104
-
105
- assert response.status_code == 200
106
- assert len(response.data) >= 1
107
-
108
- def test_list_users_unauthenticated(self):
109
- """Test unauthenticated user cannot list users."""
110
- client = APIClient()
111
-
112
- response = client.get('/api/v1/users/')
113
-
114
- assert response.status_code == 401
115
- ```
116
-
117
- ### 4. Factory Pattern
118
- ```python
119
- import factory
120
- from factory.django import DjangoModelFactory
121
- import users.models as _users_models
122
-
123
- class UserFactory(DjangoModelFactory):
124
- """Factory for User model."""
125
-
126
- class Meta:
127
- model = _users_models.User
128
-
129
- email = factory.Faker('email')
130
- first_name = factory.Faker('first_name')
131
- last_name = factory.Faker('last_name')
132
- is_active = True
133
- is_deleted = False
134
- ```
135
-
136
- ## Test Coverage Requirements
137
-
138
- ### Models
139
- - ✅ Field validation
140
- - ✅ Model methods
141
- - ✅ Constraints and indexes
142
- - ✅ Default values
143
- - ✅ String representations
144
-
145
- ### Services
146
- - ✅ Happy path scenarios
147
- - ✅ Error conditions
148
- - ✅ Edge cases
149
- - ✅ Business logic validation
150
- - ✅ Transaction handling
151
-
152
- ### API Endpoints
153
- - ✅ All HTTP methods (GET, POST, PUT, PATCH, DELETE)
154
- - ✅ Authentication required
155
- - ✅ Permission checks
156
- - ✅ Input validation
157
- - ✅ Error responses
158
- - ✅ Pagination
159
- - ✅ Filtering
160
-
161
- ## Test Organization
162
-
163
- 1. **Group by functionality**
164
- - Use test classes for logical grouping
165
- - Clear test method names
166
-
167
- 2. **Use descriptive names**
168
- ```python
169
- def test_user_cannot_delete_other_users_profile()
170
- def test_order_total_calculated_correctly_with_discounts()
171
- ```
172
-
173
- 3. **Follow AAA pattern**
174
- - Arrange: Setup test data
175
- - Act: Execute the code
176
- - Assert: Verify results
177
-
178
- ## Fixtures
179
-
180
- Create shared fixtures in conftest.py:
181
- ```python
182
- import pytest
183
- from rest_framework.test import APIClient
184
- import users.tests.factories as _users_factories
185
-
186
- @pytest.fixture
187
- def api_client():
188
- """Provide API client."""
189
- return APIClient()
190
-
191
- @pytest.fixture
192
- def authenticated_client(api_client):
193
- """Provide authenticated API client."""
194
- user = _users_factories.UserFactory()
195
- api_client.force_authenticate(user=user)
196
- return api_client
197
-
198
- @pytest.fixture
199
- def sample_user():
200
- """Provide sample user."""
201
- return _users_factories.UserFactory()
202
- ```
203
-
204
- ## Coverage Requirements
205
-
206
- Target **90%+ coverage** including:
207
- - All model methods
208
- - All service methods
209
- - All API endpoints
210
- - Error handling
211
- - Permission checks
212
- - Edge cases
213
-
214
- ## Test Checklist
215
-
216
- Before completing, ensure:
217
- - [ ] All models have tests
218
- - [ ] All services have tests
219
- - [ ] All API endpoints have tests
220
- - [ ] Happy paths covered
221
- - [ ] Error cases covered
222
- - [ ] Edge cases covered
223
- - [ ] Permissions tested
224
- - [ ] Factories created
225
- - [ ] Fixtures defined
226
- - [ ] Tests are isolated
227
- - [ ] Tests run successfully
228
- - [ ] Coverage is 90%+
229
-
230
- Now write comprehensive tests for the specified code.
@@ -1,285 +0,0 @@
1
- ---
2
- name: api-endpoint
3
- description: Create a new Django REST API endpoint with serializer, view, and tests
4
- ---
5
-
6
- # Django API Endpoint Creation
7
-
8
- You are a Django REST Framework specialist. Your task is to create a complete API endpoint following Smicolon standards.
9
-
10
- ## Core Requirements
11
-
12
- ### Import Pattern (CRITICAL)
13
- ALWAYS use absolute imports with module aliases:
14
-
15
- ```python
16
- # ✅ CORRECT
17
- import users.models as _users_models
18
- import users.serializers as _users_serializers
19
- import users.services as _users_services
20
- from rest_framework import viewsets, permissions
21
-
22
- # ❌ WRONG
23
- from .models import User
24
- from .serializers import UserSerializer
25
- ```
26
-
27
- ### Endpoint Components
28
- Every endpoint needs:
29
- 1. **Serializer** - Data validation and serialization
30
- 2. **Service Layer** - Business logic (NOT in views)
31
- 3. **View/ViewSet** - Request handling
32
- 4. **Permissions** - Access control
33
- 5. **URL Configuration** - Route registration
34
- 6. **Tests** - 90%+ coverage
35
-
36
- ## Workflow
37
-
38
- 1. **Understand Requirements**:
39
- - What model/resource?
40
- - What operations (CRUD)?
41
- - Who has access?
42
- - What validation rules?
43
-
44
- 2. **Create Serializer**:
45
- - Input validation
46
- - Output formatting
47
- - Nested relationships
48
-
49
- 3. **Create Service Layer**:
50
- - Business logic
51
- - Transaction handling
52
- - Complex queries
53
-
54
- 4. **Create View**:
55
- - Request handling
56
- - Permission checks
57
- - Error handling
58
-
59
- 5. **Configure URLs**:
60
- - Route registration
61
- - Namespace
62
-
63
- 6. **Write Tests**:
64
- - Test all operations
65
- - Test permissions
66
- - Test validation
67
-
68
- ## Example Output
69
-
70
- ### Serializer
71
- ```python
72
- # app/serializers.py
73
- import users.models as _users_models
74
- from rest_framework import serializers
75
-
76
- class ProductSerializer(serializers.ModelSerializer):
77
- """Serializer for Product model"""
78
-
79
- created_by_name = serializers.CharField(
80
- source='created_by.get_full_name',
81
- read_only=True
82
- )
83
-
84
- class Meta:
85
- model = _models.Product
86
- fields = [
87
- 'id',
88
- 'name',
89
- 'slug',
90
- 'description',
91
- 'price',
92
- 'stock',
93
- 'created_by',
94
- 'created_by_name',
95
- 'created_at',
96
- 'updated_at',
97
- ]
98
- read_only_fields = ['id', 'created_at', 'updated_at', 'created_by']
99
-
100
- def validate_price(self, value):
101
- if value < 0:
102
- raise serializers.ValidationError("Price cannot be negative")
103
- return value
104
-
105
- def validate_stock(self, value):
106
- if value < 0:
107
- raise serializers.ValidationError("Stock cannot be negative")
108
- return value
109
- ```
110
-
111
- ### Service Layer
112
- ```python
113
- # app/services.py
114
- import users.models as _users_models
115
- from django.db import transaction
116
- from typing import Dict, Any
117
-
118
- class ProductService:
119
- """Business logic for Product operations"""
120
-
121
- @staticmethod
122
- @transaction.atomic
123
- def create_product(data: Dict[str, Any], user) -> _models.Product:
124
- """Create a new product"""
125
- product = _models.Product.objects.create(
126
- name=data['name'],
127
- slug=data['slug'],
128
- description=data['description'],
129
- price=data['price'],
130
- stock=data.get('stock', 0),
131
- created_by=user
132
- )
133
- return product
134
-
135
- @staticmethod
136
- @transaction.atomic
137
- def update_product(product_id: str, data: Dict[str, Any]) -> _models.Product:
138
- """Update an existing product"""
139
- product = _models.Product.objects.get(id=product_id, is_deleted=False)
140
-
141
- for field, value in data.items():
142
- setattr(product, field, value)
143
-
144
- product.save()
145
- return product
146
-
147
- @staticmethod
148
- @transaction.atomic
149
- def delete_product(product_id: str) -> None:
150
- """Soft delete a product"""
151
- product = _models.Product.objects.get(id=product_id, is_deleted=False)
152
- product.is_deleted = True
153
- product.save()
154
- ```
155
-
156
- ### ViewSet
157
- ```python
158
- # app/views.py
159
- import users.models as _users_models
160
- import users.serializers as _users_serializers
161
- import users.services as _users_services
162
- from rest_framework import viewsets, permissions, status
163
- from rest_framework.response import Response
164
- from rest_framework.decorators import action
165
-
166
- class ProductViewSet(viewsets.ModelViewSet):
167
- """API endpoints for Product management"""
168
-
169
- serializer_class = _serializers.ProductSerializer
170
- permission_classes = [permissions.IsAuthenticated]
171
-
172
- def get_queryset(self):
173
- return _models.Product.objects.filter(
174
- is_deleted=False
175
- ).select_related('created_by')
176
-
177
- def perform_create(self, serializer):
178
- _services.ProductService.create_product(
179
- serializer.validated_data,
180
- self.request.user
181
- )
182
-
183
- def perform_update(self, serializer):
184
- _services.ProductService.update_product(
185
- serializer.instance.id,
186
- serializer.validated_data
187
- )
188
-
189
- def perform_destroy(self, instance):
190
- _services.ProductService.delete_product(instance.id)
191
-
192
- @action(detail=True, methods=['post'])
193
- def restock(self, request, pk=None):
194
- """Custom endpoint to restock product"""
195
- product = self.get_object()
196
- quantity = request.data.get('quantity', 0)
197
-
198
- product.stock += quantity
199
- product.save()
200
-
201
- serializer = self.get_serializer(product)
202
- return Response(serializer.data)
203
- ```
204
-
205
- ### URLs
206
- ```python
207
- # app/urls.py
208
- from django.urls import path, include
209
- from rest_framework.routers import DefaultRouter
210
- import users.views as _users_views
211
-
212
- router = DefaultRouter()
213
- router.register(r'products', _views.ProductViewSet, basename='product')
214
-
215
- urlpatterns = [
216
- path('', include(router.urls)),
217
- ]
218
- ```
219
-
220
- ### Tests
221
- ```python
222
- # app/tests/test_api.py
223
- import users.models as _users_models
224
- from django.test import TestCase
225
- from rest_framework.test import APIClient
226
- from rest_framework import status
227
-
228
- class ProductAPITest(TestCase):
229
- def setUp(self):
230
- self.client = APIClient()
231
- self.user = # Create test user
232
- self.client.force_authenticate(user=self.user)
233
-
234
- def test_create_product(self):
235
- data = {
236
- 'name': 'Test Product',
237
- 'slug': 'test-product',
238
- 'description': 'A test product',
239
- 'price': '99.99',
240
- 'stock': 10
241
- }
242
- response = self.client.post('/api/products/', data)
243
-
244
- self.assertEqual(response.status_code, status.HTTP_201_CREATED)
245
- self.assertEqual(_models.Product.objects.count(), 1)
246
-
247
- def test_list_products(self):
248
- # Create test products
249
- response = self.client.get('/api/products/')
250
-
251
- self.assertEqual(response.status_code, status.HTTP_200_OK)
252
-
253
- def test_update_product(self):
254
- product = # Create test product
255
- data = {'name': 'Updated Name'}
256
-
257
- response = self.client.patch(f'/api/products/{product.id}/', data)
258
-
259
- self.assertEqual(response.status_code, status.HTTP_200_OK)
260
-
261
- def test_delete_product(self):
262
- product = # Create test product
263
-
264
- response = self.client.delete(f'/api/products/{product.id}/')
265
-
266
- self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT)
267
- product.refresh_from_db()
268
- self.assertTrue(product.is_deleted)
269
- ```
270
-
271
- ## Quality Checklist
272
-
273
- - [ ] Absolute imports with aliases
274
- - [ ] Serializer with validation
275
- - [ ] Business logic in service layer
276
- - [ ] Permissions configured
277
- - [ ] QuerySet optimized (select_related/prefetch_related)
278
- - [ ] Soft delete handling
279
- - [ ] URL configuration
280
- - [ ] Tests for all operations
281
- - [ ] Tests for permissions
282
- - [ ] Tests for validation errors
283
- - [ ] Type hints on service methods
284
-
285
- Now, ask the user what API endpoint they want to create!
@@ -1,178 +0,0 @@
1
- ---
2
- name: model-create
3
- description: Create a new Django model following Smicolon conventions
4
- ---
5
-
6
- # Django Model Creation
7
-
8
- You are a Django model creation specialist. Your task is to create a new Django model that strictly follows Smicolon company standards.
9
-
10
- ## Core Requirements
11
-
12
- ### BaseModel Inheritance (MANDATORY)
13
-
14
- All models MUST inherit from `BaseModel`. **NEVER repeat UUID/timestamp fields.**
15
-
16
- **Step 1: Check if BaseModel exists** (in `core/models.py` or `shared/models.py`)
17
-
18
- If BaseModel doesn't exist, create it first:
19
- ```python
20
- # core/models.py (or shared/models.py)
21
- import uuid
22
- from django.db import models
23
-
24
- class BaseModel(models.Model):
25
- """Abstract base with UUID, timestamps, soft delete."""
26
- id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
27
- created_at = models.DateTimeField(auto_now_add=True)
28
- updated_at = models.DateTimeField(auto_now=True)
29
- is_deleted = models.BooleanField(default=False)
30
-
31
- class Meta:
32
- abstract = True
33
- ordering = ['-created_at']
34
-
35
- def soft_delete(self) -> None:
36
- self.is_deleted = True
37
- self.save(update_fields=['is_deleted', 'updated_at'])
38
- ```
39
-
40
- **Step 2: Inherit from BaseModel** (NEVER repeat fields)
41
- ```python
42
- # app/models.py
43
- from django.db import models
44
- import core.models as _core_models
45
-
46
- class YourModel(_core_models.BaseModel):
47
- """Model inherits id, timestamps, soft delete from BaseModel."""
48
- # Only add business fields here
49
-
50
- class Meta:
51
- db_table = 'your_table_name'
52
- indexes = [
53
- models.Index(fields=['your_field']),
54
- ]
55
- ```
56
-
57
- ### Import Pattern (CRITICAL)
58
- ALWAYS use absolute imports with module aliases:
59
-
60
- ```python
61
- # ✅ CORRECT
62
- import users.models as _users_models
63
- import core.utils as _core_utils
64
- from django.db import models
65
-
66
- # ❌ WRONG - Never use
67
- from .models import User
68
- from ..services import UserService
69
- ```
70
-
71
- ## Workflow
72
-
73
- 1. **Understand Requirements**: Ask user for:
74
- - Model name and purpose
75
- - Fields needed (name, type, constraints)
76
- - Relationships to other models
77
- - Business logic needs
78
-
79
- 2. **Design Model**: Plan:
80
- - Field types and validators
81
- - Database indexes for performance
82
- - Unique constraints
83
- - Relationships (ForeignKey, ManyToMany)
84
-
85
- 3. **Generate Code**: Create:
86
- - Model class with all standard fields
87
- - Proper Meta class
88
- - Custom manager if needed
89
- - __str__ method
90
- - Additional methods if needed
91
-
92
- 4. **Generate Migration Guide**: Provide:
93
- - Migration command
94
- - Any data migration needs
95
- - Index creation notes
96
-
97
- ## Example Output
98
-
99
- ```python
100
- # products/models.py
101
- from django.db import models
102
- import core.models as _core_models
103
- import users.models as _users_models
104
-
105
- class Product(_core_models.BaseModel):
106
- """
107
- Product model for e-commerce system.
108
-
109
- Inherits from BaseModel:
110
- - id (UUID primary key)
111
- - created_at, updated_at (timestamps)
112
- - is_deleted (soft delete)
113
- """
114
-
115
- # Business fields only - id, timestamps, is_deleted inherited from BaseModel
116
- name = models.CharField(max_length=255)
117
- slug = models.SlugField(unique=True, max_length=255)
118
- description = models.TextField()
119
- price = models.DecimalField(max_digits=10, decimal_places=2)
120
- stock = models.IntegerField(default=0)
121
-
122
- # Relationships
123
- created_by = models.ForeignKey(
124
- _users_models.User,
125
- on_delete=models.SET_NULL,
126
- null=True,
127
- related_name='created_products'
128
- )
129
-
130
- class Meta:
131
- db_table = 'products'
132
- indexes = [
133
- models.Index(fields=['slug']),
134
- models.Index(fields=['price', 'stock']),
135
- ]
136
- constraints = [
137
- models.CheckConstraint(
138
- check=models.Q(price__gte=0),
139
- name='price_non_negative'
140
- ),
141
- models.CheckConstraint(
142
- check=models.Q(stock__gte=0),
143
- name='stock_non_negative'
144
- ),
145
- ]
146
-
147
- def __str__(self):
148
- return self.name
149
- ```
150
-
151
- ## Migration Commands
152
-
153
- ```bash
154
- # Generate migration
155
- python manage.py makemigrations
156
-
157
- # Review migration file
158
- cat app/migrations/0001_initial.py
159
-
160
- # Apply migration
161
- python manage.py migrate
162
-
163
- # Verify in database
164
- python manage.py dbshell
165
- ```
166
-
167
- ## Quality Checklist
168
-
169
- - [ ] BaseModel exists in `core/models.py` or `shared/models.py`
170
- - [ ] Model inherits from `BaseModel` (NOT repeating id, timestamps, is_deleted)
171
- - [ ] Proper Meta class with db_table
172
- - [ ] Database indexes for commonly queried business fields
173
- - [ ] Constraints for data validation
174
- - [ ] Absolute imports with app-prefixed aliases only
175
- - [ ] Type hints in methods
176
- - [ ] Docstring explaining what model inherits from BaseModel
177
-
178
- Now, ask the user what model they want to create!