From ai-first-engineering
Implements features from Gherkin feature files via technical analysis, step definitions, and business logic code generation. Activates on phrases like 'implement feature from feature file' or .feature files present.
npx claudepluginhub cuongtl1992/vibe-skills --plugin ai-first-engineeringThis skill uses the workspace's default tool permissions.
Đọc Gherkin feature file từ living docs → phân tích technical solution → gen step definitions + implementation code. Skill này là bridge từ **WHAT** (feature file) sang **HOW** (code).
Converts Lean PRDs to Gherkin .feature files with Vietnamese steps in mandatory Rule blocks. Use for generating structured BDD scenarios from product specs.
Applies BDD with Gherkin scenarios and TDD Red-Green-Refactor to implement features, fix bugs, and write executable specs/tests before production code.
Authors interactive Gherkin BDD scenarios guiding through Given/When/Then steps with best practices like single When actions and observable outcomes. Outputs .feature files for testing.
Share bugs, ideas, or general feedback.
Đọc Gherkin feature file từ living docs → phân tích technical solution → gen step definitions + implementation code. Skill này là bridge từ WHAT (feature file) sang HOW (code).
Feature file là contract. Code phải thỏa mãn contract đó — không hơn, không kém.
Skill này KHÔNG quyết định stack, framework, hay conventions — đó là việc của CLAUDE.md và existing code trong repo. Skill này chỉ hướng dẫn process: đọc gì → phân tích gì → gen gì → verify gì.
Phase này là bước architecture cho feature-level. KHÔNG skip — gen code mà không có technical analysis sẽ dẫn tới refactor.
Input: .feature file (hoặc nhiều files nếu feature span nhiều module)
Extract:
├── Feature name + narrative → hiểu context
├── Rules → list business rules cần implement
├── Scenarios per Rule → behaviors cần thỏa mãn
├── Tags → test layer (@api/@web/@integration), priority (@p2/@future)
├── # PRD link → đọc PRD nếu cần thêm context
└── # TODO comments → decisions chưa resolve
Đọc repo qua git submodule hoặc trực tiếp:
Scan:
├── CLAUDE.md → stack, conventions, patterns
├── Existing step definitions → pattern đang dùng
├── Domain models / entities → data model hiện tại
├── API routes / controllers → endpoints hiện có
├── Database schema → tables, relationships
└── Related features code → follow existing patterns
Output dạng summary để engineer review:
## Technical Solution: [Feature Name]
### Tổng quan
[1-2 câu: approach chính để implement feature này]
### Components cần thay đổi
| Component | Thay đổi | Lý do (Rule ID) | Impact |
|-----------|----------|-----------------|--------|
| [service/module] | [new/modify/extend] | [BR-Mxx] | [low/medium/high] |
### Data model changes
| Entity | Thay đổi | Fields | Migration? |
|--------|----------|--------|-----------|
| [entity] | [new table / add columns / modify] | [field list] | [yes/no] |
### API changes
| Endpoint | Method | Thay đổi | Guards (Rules) |
|----------|--------|----------|---------------|
| [path] | [GET/POST/...] | [new/modify] | [BR-Mxx] |
### Quyết định kỹ thuật
- [Decision 1]: [option chọn] — *lý do: [ngắn gọn]*
- [Decision 2]: [option chọn] — *lý do: [ngắn gọn]*
### Breaking changes
- [ ] [Mô tả breaking change nếu có] → *ảnh hưởng: [ai/service nào]*
### Implementation order
1. [Component/step đầu tiên] — *vì: [dependency reason]*
2. [Component/step tiếp theo]
3. ...
Sau khi output Technical Solution → DỪNG LẠI, hỏi engineer:
"Technical solution trên có ok không? Cần adjust gì trước khi gen code?"
Chỉ tiếp Phase 2 sau khi engineer confirm.
Nếu engineer muốn lưu, ghi vào living docs:
features/[module]/[feature-name].solution.md
Hoặc ghi tóm tắt trong feature file:
# Solution: [1 dòng tóm tắt approach]
# Components: [list services/modules affected]
# Decision: [key technical decision]
Follow existing patterns TRƯỚC:
Given Minh có gói trả phí đang active có thể đã có)Mapping Gherkin → Step:
Gherkin step → Step definition làm gì
─────────────────────────────────────────────────────────
Given [trạng thái] → Setup test data / fixtures
Given Minh có gói trả phí → Create merchant + active subscription
Given Minh có đơn hàng → Create order with status completed
When [hành động] → Call API / service method / UI action
When Minh yêu cầu xuất → POST /invoices hoặc service.createInvoice()
Then [kết quả] → Assert response / state / side-effect
Then hóa đơn được tạo → Assert invoice exists, status = Draft
Then hệ thống từ chối → Assert error response, no invoice created
Dựa trên tag trong feature file:
@api scenarios:
Given → DB setup / API setup calls
When → HTTP request (REST client)
Then → Assert HTTP response + DB state
@web scenarios:
Given → DB setup + navigate to page
When → Browser interaction (Playwright/Selenium)
Then → Assert page content / UI state
@integration scenarios:
Given → Setup across multiple services
When → Trigger in service A
Then → Assert observable in service B
// BR-M01: Chỉ merchant active mới được xuấtMỗi Business Rule trong feature file → code cụ thể:
Rule type → Code pattern
─────────────────────────────────────────
Permission/Guard → Middleware / guard clause / policy
Validation → Validator class / validation function
State transition → State machine / status update logic
Calculation → Pure function / service method
Side-effect/Notification → Event handler / background job
Uniqueness/Conflict → DB constraint + application check
Default/Auto-fill → Factory / builder / mapper
Time-bound → Scheduler / expiry check
Cascade/Dependency → Transaction / saga / event chain
1. Data model changes (migration nếu cần)
→ Entities, DB schema
2. Core business logic (Rules - Must Have trước)
→ Validation, calculation, state machine
3. API layer (endpoints, controllers)
→ Route, request/response mapping
4. Side-effects (notifications, integrations)
→ Event handlers, background jobs
5. Should Have rules (@p2)
→ Sau khi Must Have green
6. Skip @future/@p3
→ Chỉ có feature file làm documentation
feat(billing): implement invoice submission [BR-M01, BR-M02]Chạy step definitions với feature file:
├── Must Have scenarios → PHẢI green
├── Should Have (@p2) → NÊN green
├── @future/@p3 → Skip (pending)
└── @wip → Expected fail ok
Test fail → Đọc scenario lại:
├── Given sai? → Fix test data setup
├── When sai? → Fix API call / action
├── Then sai? → Bug trong implementation HOẶC scenario không chính xác
│ ├── Implementation bug → fix code
│ └── Scenario không chính xác → flag cho Product review
└── Không rõ → đọc PRD (link trong feature file header)
Engineer prompt:
Implement feature từ features/billing/invoice-submission.feature
Claude Code sẽ:
Phase 1: Technical Analysis
├── Đọc invoice-submission.feature
│ ├── 4 Rules: BR-M01 (permission), BR-M02 (calculation), BR-S01 (form), BR-S02 (notification)
│ ├── 7 Scenarios: 4 @api, 2 @web, 1 @future
│ └── PRD link: https://confluence.../pages/123
├── Scan repo
│ ├── CLAUDE.md: .NET 8, Clean Architecture, EF Core
│ ├── Existing: OrderController, InvoiceEntity (chưa có submit logic)
│ └── Step defs: 12 existing steps trong billing/
├── Output Technical Solution
│ ├── New: InvoiceSubmissionService
│ ├── Modify: InvoiceController (add POST /invoices)
│ ├── New: SubscriptionGuard middleware
│ ├── DB: add column Invoice.SubmittedAt, Invoice.ReferenceNumber
│ └── No breaking changes
└── → HỎI ENGINEER CONFIRM
Phase 2: Step Definitions
├── Reuse: 3 existing steps (merchant setup, order setup, login)
├── New: 4 steps (submit invoice, check status, check error, check total)
└── Files: steps/billing/invoice-submission.steps.cs
Phase 3: Implementation
├── 1. Migration: AddInvoiceSubmissionColumns
├── 2. InvoiceSubmissionService (BR-M01 guard, BR-M02 calc)
├── 3. InvoiceController.Submit() endpoint
├── 4. Skip BR-S02 (@future)
└── Run tests → 6/6 green (1 @future skipped)
references/step-patterns.md — Common step definition patterns theo test layer (@api, @web, @integration)