Skip to content

GitHub Spec Kit

GitHub Spec Kit là toolkit open source để thực hành Spec-Driven Development với AI coding agents. Nó cung cấp CLI, templates và workflow kiểu slash-command để đi từ constitution đến specification, clarification, plan, tasks, analysis và implementation.

Hãy hiểu Spec Kit là SDD workflow scaffold, không phải app framework và cũng không phải enterprise governance system đầy đủ.

mermaid
flowchart TB
    A[Project principles] --> B[Constitution]
    B --> C[Feature specification]
    C --> D[Clarifications]
    D --> E[Implementation plan]
    E --> F[Task list]
    F --> G[Implementation]
    G --> H[Analyze and validate]

Mental model

Spec Kit giống một "compiler" từ product intent sang executable work:

text
Human intent
  -> /speckit.specify
Specification
  -> /speckit.clarify
Resolved ambiguity
  -> /speckit.plan
Technical plan
  -> /speckit.tasks
Executable work
  -> /speckit.implement
Code and tests

Core artifacts

ArtifactVai tròVì sao quan trọng
ConstitutionNguyên tắc cấp projectGiữ stable rules về quality, testing, architecture, UX, performance
Feature specWhat và whyNgăn agent nhảy vào implementation quá sớm
ClarificationCâu hỏi mởÉp ambiguity lộ ra trước khi code
PlanHowKết nối spec với architecture và technical choices
TasksWork breakdownTạo đơn vị executable cho agent hoặc human
Analyze/checklistConsistency checkBắt gap trước implementation

Workflow chi tiết

mermaid
sequenceDiagram
    participant U as User
    participant A as Agent
    participant R as Repo

    U->>A: Initialize Spec Kit
    A->>R: Create constitution and templates
    U->>A: Specify feature intent
    A->>R: Draft feature spec
    U->>A: Clarify
    A->>U: Ask focused questions
    U->>A: Answer
    A->>R: Update spec
    U->>A: Plan
    A->>R: Create implementation plan
    U->>A: Tasks
    A->>R: Create task list
    U->>A: Implement
    A->>R: Code, tests, docs

Điểm mạnh

  1. Giảm ambiguity ở requirement. Phần lớn lỗi AI coding là lỗi hiểu intent, không phải lỗi syntax.
  2. Tách what/why khỏi how. Tránh quyết định database, framework hoặc architecture quá sớm.
  3. Constitution tạo luật nền ổn định. Không cần nhắc lại testing, accessibility, architecture boundary trong từng prompt.
  4. Artifact dễ review theo vai trò. Product review spec, architect review plan, engineer review tasks.
  5. Hợp với multi-agent. Shared spec đáng tin hơn chat history.

Điểm yếu

Điểm yếuHệ quả thực tế
Không tự biết spec có đúng domain khôngDomain expert vẫn phải review
Spec viết hay có thể tạo tự tin giảTài liệu nghe đủ nhưng thiếu hidden constraints
Không phải full governanceApproval matrix, audit trail, security review, production readiness cần bổ sung
Có thể spec driftCode đổi nhưng spec không đổi thì source of truth vỡ
Task nhỏ thấy nặngCopy edit hoặc bug nhỏ không cần full SDD

Use case tốt nhất

Use caseVì sao Spec Kit hợp
Feature product mớiLàm rõ user journey và acceptance criteria
Greenfield MVP có scope rõTạo nền spec/plan/tasks từ đầu
API designContract rõ trước khi code
Refactor giữ behaviorĐịnh nghĩa expected behavior trước khi đổi internal
Team học AI workflowCommand flow rõ, có cấu trúc

Khi không nên dùng làm primary

Chọn framework khác khi:

  • Enterprise approval/audit là vấn đề chính: ưu tiên AWS AI-DLC.
  • Dự án dài nhiều phase là vấn đề chính: ưu tiên GSD.
  • Vấn đề chính là agent coding thiếu discipline: ưu tiên Superpowers.
  • Task quá nhỏ để dùng full spec-plan-task.

Ví dụ: forgot password

Spec Kit sẽ ép lộ ra các câu hỏi quan trọng:

BướcOutput
ConstitutionSecurity rules: token expiration, no user enumeration, audit reset events
SpecifyUser có thể yêu cầu reset password qua email
ClarifyToken sống bao lâu? Rate limit? Email copy? Tenant boundary?
PlanEndpoint, token model, email service, UI flow
TasksBackend model, API route, email integration, UI, tests
ImplementCode và verification

Giá trị không chỉ là tài liệu. Giá trị là ngăn agent tự đưa ra assumption bảo mật và UX.

Hướng dẫn triển khai cấp chuyên gia

Dùng phần này khi bạn muốn vận hành Spec Kit như workflow lặp lại trong team, không chỉ như một prompt helper.

Bước 1: Chốt ranh giới source of truth

Trước khi cài gì, hãy quyết định Spec Kit sở hữu phần nào.

Quyết địnhKhuyến nghị
Feature intentDo Spec Kit specs sở hữu
Architecture decisionsPlan tham chiếu, nhưng ADR dài hạn có thể nằm riêng
Implementation tasksDo Spec Kit task artifacts sở hữu trước khi chuyển sang issue tracker
Sprint/project managementDo tracker của team sở hữu; Spec Kit feed dữ liệu vào
Test evidenceDo CI sở hữu, link ngược lại implementation summary

Anti-pattern: Jira, README, PR description và Spec Kit specs cùng mô tả một requirement nhưng mỗi nơi một kiểu.

Bước 2: Cài và initialize

Upstream khuyến nghị cài Specify CLI rồi initialize project với agent integration phù hợp.

bash
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git@vX.Y.Z
specify init my-project --integration copilot
cd my-project

Với repo có sẵn, initialize ngay trong repo và kiểm tra generated files trước khi commit. Commit đầu tiên chỉ nên chứa scaffolding và project principles.

Bước 3: Viết constitution như engineering contract

Constitution không phải trang khẩu hiệu. Hãy coi nó là hợp đồng kỹ thuật ngắn gọn.

Khu vựcVí dụ rule
TestingBehavior-changing tasks phải có automated tests trước khi xem là done
ArchitectureDependency mới cần justification rõ trong plan
UXFlow user-facing phải có loading, empty, error, success states
SecurityAuth, authorization và privacy assumptions phải rõ trong spec
PerformanceEndpoint mới phải nêu expected latency hoặc giải thích vì sao không quan trọng
AccessibilityInteractive UI phải dùng được bằng keyboard và screen reader

Tránh rule mơ hồ như "viết code tốt". Constitution phải review được.

Bước 4: Chạy feature loop

mermaid
flowchart LR
    A[Constitution] --> B[Specify]
    B --> C[Clarify]
    C --> D[Plan]
    D --> E[Tasks]
    E --> F[Analyze]
    F --> G[Implement]
    G --> H[Verify]
    H --> I[Update spec nếu behavior đổi]

Với feature có security, data, migration hoặc UX risk, hãy dùng clarification và analysis thật kỹ.

Bước 5: Review đúng vai trò

ArtifactReviewer chínhCâu hỏi review
SpecProduct/domain ownerĐây có phải user outcome đúng không?
ClarificationsProduct + engineeringUnknowns đã được trả lời hoặc defer có chủ ý chưa?
PlanTech lead/architectApproach có đơn giản, compatible, maintainable không?
TasksSenior engineerTask có executable và testable độc lập không?
ImplementationEngineer/reviewerCode có đáp ứng spec và tests không?

Spec Kit thất bại khi một người approve mọi tầng một cách hình thức.

Bước 6: Biến tasks thành delivery units

Task tốt nên:

  • Đủ nhỏ cho một PR hoặc một agent session.
  • Có thứ tự dependency.
  • Nêu file/module khi có thể.
  • Đi kèm test hoặc verification.
  • Link được với acceptance criteria.

Nếu task quá rộng, yêu cầu agent chia theo vertical slice: data, API, UI, tests, migration, docs.

Bước 7: Chỉ dùng presets/extensions sau khi base flow ổn

Spec Kit hỗ trợ presets để customize templates và extensions để thêm workflow.

Nhu cầuDùng
Enforce spec sections theo công tyPreset
Thêm workflow command mớiExtension
Traceability cho compliancePreset
Tích hợp Jira hoặc external toolExtension
Localize terminologyPreset

Đừng customize quá sớm. Chạy 3 feature thật bằng default workflow trước, rồi mới nhận diện gap lặp lại.

Playbook tối ưu

Cho startup

Dùng Spec Kit cho feature ảnh hưởng behavior. Bỏ qua cho UI polish nhỏ. Spec nên ngắn nhưng bắt buộc có acceptance criteria và non-goals.

Cho enterprise

Tạo organization presets cho:

  • Security/privacy sections.
  • Data classification.
  • NFR checklist.
  • Architecture decision references.
  • Test evidence links.
  • Release readiness.

Cho độ tin cậy của AI agent

Thêm rule:

Nếu spec và implementation conflict, dừng lại và hỏi nên update spec hay sửa code.

Rule này giảm spec drift âm thầm.

Definition of done cho Spec Kit

Feature chỉ done khi:

  1. Spec có acceptance criteria và non-goals.
  2. Clarifications được trả lời hoặc defer rõ.
  3. Plan giải thích technical choices chính.
  4. Tasks map được với acceptance criteria.
  5. Tests verify behavior quan trọng.
  6. Implementation summary link ngược về spec.
  7. Behavior change được phản ánh lại trong spec.

Maturity levels

LevelHành vi
Level 1: Prompt disciplineDùng /speckit.specify cho feature lớn
Level 2: Artifact disciplineDùng clarify, plan, tasks, analysis đều đặn
Level 3: Team workflowProduct review spec, tech lead review plan, engineers execute tasks
Level 4: Organizational workflowPresets enforce security, NFR, domain language, compliance
Level 5: Continuous specificationBugs, incidents và analytics feed ngược vào specs

Built as a static bilingual AI engineering stack guide.