Chuyển đến nội dung
Skillpedia
Lập trình chung15k · #10974

principle-boundary-discipline

Skill này làm gì

Cung cấp cho agent một quy tắc về nơi đặt kiểm tra và xử lý lỗi trong code. Dành cho lập trình viên muốn ít lớp bảo vệ thừa hơn và code dễ kiểm thử hơn.

Khi nào nên dùng

  • ✓Khi bạn đang gắn kiểm tra đầu vào hoặc xử lý lỗi vào một chương trình.
  • ✓Khi cùng các kiểm tra bị lặp lại ở nhiều hàm nội bộ.
  • ✓Khi bạn muốn giữ logic nghiệp vụ trong các hàm thuần túy, dễ kiểm thử.

Liên kết skill

https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-boundary-discipline/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/cursor/plugins/blob/main/harness/pstack/claude-code/skills/principle-boundary-discipline/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Tôi nên kiểm tra cấu hình và phản hồi API ở đâu trong dịch vụ này để phần còn lại của code có thể đơn giản?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent đặt kiểm tra ở các biên, như tham số dòng lệnh, file cấu hình và lời gọi bên ngoài, rồi tin tưởng dữ liệu có kiểu bên trong. Nó giữ logic nghiệp vụ trong các hàm thuần túy hoạt động mà không cần framework.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Boundary Discipline

Place validation, type narrowing, and error handling at system boundaries. Trust internal code unconditionally. Business logic lives in pure functions. The shell is thin and mechanical.

Why: Scattered validation is noisy, redundant, and gives a false sense of safety. Keep logic out of framework wiring so it can be tested without the framework.

The pattern:

  • At boundaries (CLI args, config files, external APIs, network protocols): validate, return errors, handle defensively.
  • Inside the system: typed data, error propagation, no re-validation. Trust the types.
  • Across the boundary. Expose domain concepts, not the boundary's private representation. Keep general-purpose mechanism inside and special-purpose policy at the edge.

Applications:

Validation and error handling:

  • Validate config at parse time (the boundary), not inside business logic
  • Parse raw data into domain types at the boundary
  • Do not re-export transport, storage, framework, or wire types through the public surface
  • No redundant nil checks deep in call chains if the boundary already validated

Code organization:

  • Business logic in pure functions with no framework dependencies
  • Parse functions: pure transforms from raw bytes to typed state
  • Prompt construction: structured state in, string out
  • Scoring and assessment: pure transforms from state to results

The tests:

  • "Is this data crossing a system boundary right now?" If not, validation is redundant.
  • "Can this be a pure function that the shell just calls?" If yes, extract it.
Câu hỏi thường gặp

Vì sao không kiểm tra ở mọi nơi?

Các kiểm tra rải rác thì ồn ào, lặp lại và tạo cảm giác an toàn giả.

Điều gì nên nằm bên trong hệ thống?

Dữ liệu có kiểu và truyền lỗi, không kiểm tra lại những giá trị mà biên đã xác thực.

Vì sao giữ logic ngoài framework?

Để có thể kiểm thử mà không cần khởi động framework.

Chi tiết

Mô tả gốc của tác giả

Apply when wiring validation, error handling, or framework adapters. Concentrate guards at system boundaries (CLI, config, network, external APIs); trust internal types and keep business logic in pure functions.

repo: cursor/plugins

Độ phổ biến

Sao GitHub
15k
Vị trí xếp hạng
#10974
Giấy phép
—
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự