# Kry System

> Act 3 — Dữ liệu + Kiến trúc (cửa 1 chiều). Trigger khi user gõ /kry-system, hoặc nói 'thiết kế data model', 'schema cho app', 'kiến trúc hệ thống', 'dựng nền kỹ thuật', 'chốt stack + database', 'auth thế nào', sau khi đã có UX spec từ /kry-ux. Skill define TƯƠI cho app này: entity→bảng→field→ràng buộc + state machine + boundary/contract + auth/role (RLS) + stack + host. Spawn agent challenger-sys…

- **Type:** Skill
- **Install:** `agentstack add skill-dangpm-kry-build-pipeline-kry-system`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [dangpm](https://agentstack.voostack.com/s/dangpm)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [dangpm](https://github.com/dangpm)
- **Source:** https://github.com/dangpm/kry-build-pipeline/tree/master/skills/kry-system

## Install

```sh
agentstack add skill-dangpm-kry-build-pipeline-kry-system
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# /kry-system — Act 3: Dữ liệu + Kiến trúc

Dựng **nền** mà mọi thứ phía sau bám vào. Đây là **cửa 1 chiều** — schema sai sau khi có data thật phải migration + backfill + downtime, đắt gấp 10-100x sửa UI. Nên làm kỹ, 1 lần, với agent phản biện gác cửa.

> Vị trí: `/kry-debrief → /kry-ux → ` **`/kry-system`** ` → /kry-ui → /kry-plan→cook→qc → /kry-done → /kry-docs → /kry-update ↺`
> Define **TƯƠI** cho app này, KHÔNG bê khuôn. Stack mặc định bạn (Next 16 + Supabase + Tailwind) chỉ là điểm xuất phát — chốt theo nhu cầu thật.

## Nguyên tắc

- **Data model sinh từ business rule + entity trong Brief**, không bịa. Mỗi rule "không huỷ → trừ buổi" → 1 state transition. Mỗi entity → 1 bảng.
- **Best part is no part** — bảng/field nào không phục vụ rule nào → xoá.
- Mọi quyết định cửa-1-chiều phải qua `challenger-system` trước khi chốt.

## Workflow

### Bước 1 — Đọc input
Đọc Business Brief (act 1) + UX spec (act 2): lấy entities, business rules, integrations, vai. Trong project có code → công cụ đọc codebase để hiểu hệ sẵn.

### Bước 2 — Draft nền (define tươi)
1. **Data model:** entity → bảng → field → kiểu → ràng buộc (unique/FK/check/not-null). Vẽ **ERD Mermaid**.
2. **State machine:** mỗi entity có vòng đời (vd order: pending→paid→expired) → Mermaid stateDiagram.
3. **Boundary/contract:** mỗi integration (payment/email/chữ ký số/hoá đơn/webhook) — input/output, fail/retry/idempotency.
4. **Auth/role:** vai nào đọc/ghi row nào → bảng RLS policy. Secret để đâu.
5. **Stack + host:** chốt (default Next16 + Supabase + VPS/Vercel) + lý do nếu lệch default.

### Bước 3 — Spawn `challenger-system`
**BẮT BUỘC** spawn agent `challenger-system` (Nguyên-lý × Gu) bới: data integrity · race/idempotency · security/RLS · boundary fail · soft-delete/audit · scale · lifecycle. Nhận ≥3 challenge → trả lời/sửa nền. Lặp tới khi không còn 🔴.

### Bước 4 — Output
```
ERD (Mermaid) + State machines + Schema (SQL/migration outline)
+ Contracts table + RLS policy + Stack decision (DECISIONS/*.md)
```
Lưu vào project + có thể đẩy . Đây là input cho `/kry-plan` (chia lát) + `test-runner` (test vs ràng buộc).

### Bước 5 — Hand off `/kry-ui`
Cập nhật `.kry/state.json` (act=3 done, next=kry-ui) → `/kry-ui` để định nghĩa ngôn ngữ thiết kế.

## Anti-pattern
- ❌ Bịa entity/field không từ rule nào → xoá
- ❌ Bỏ qua challenger-system (cửa 1 chiều mà không phản biện = tự sát)
- ❌ Quên idempotency cho webhook · quên RLS · quên audit/soft-delete (nocode hay quên)
- ❌ Chốt UI/màu ở đây (đó là act 4)
- ❌ Để secret trong schema/repo
- ❌ Output English

## Triggers
- "/kry-system", "thiết kế data model", "schema cho app", "kiến trúc hệ thống", "chốt stack + database", "auth thế nào"

## Quan hệ
Agent: `challenger-system`. Trước: `/kry-ux`. Sau: `/kry-ui`. Khác doc kiến trúc (ARCHITECTURE.md tổng quan) — kry-system đi sâu data + ràng buộc + RLS để code không sai.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [dangpm](https://github.com/dangpm)
- **Source:** [dangpm/kry-build-pipeline](https://github.com/dangpm/kry-build-pipeline)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-dangpm-kry-build-pipeline-kry-system
- Seller: https://agentstack.voostack.com/s/dangpm
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
