用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/G1Joshi/Agent-Skills --skill hexagonal命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | hexagonal |
| description | Hexagonal architecture ports and adapters. Use for testable systems. |
Hexagonal Architecture aims to create a loosely coupled application component that can easily connect to their software environment by "ports" and "adapters". It treats the database, the web UI, and external APIs as interchangeable "details" (infrastructure).
// --- CORE (Inside the Hexagon) ---
// Port (Driver Port - Input)
type UserService interface {
Register(name string) error
}
// Port (Driven Port - Output)
type UserRepository interface {
Save(user User) error
}
// Application Service (Implementation)
type UserServiceImpl struct {
repo UserRepository
}
func (s *UserServiceImpl) Register(name string) error {
return s.repo.Save(User{Name: name})
}
// --- ADAPTERS (Outside the Hexagon) ---
// Driving Adapter (REST API)
{
svc.Register(r.FormValue())
}
PostgresRepo { db *sql.DB }
Save(u User) { ... }
Interfaces that define the entry and exit points of the application.
Concrete implementations that bridge the gap between the Ports and the outside world.
Because the core depends on interfaces (Ports), you can implement "Fake" adapters (e.g., InMemoryRepository) to test complex business logic without spinning up Docker containers.
Do:
Don't:
sql.Rows) into the Core.| Error | Cause | Solution |
|---|---|---|
Leakage | Logic depends on specific library types. | Wrap external types in domain-specific DTOs/Interfaces. |
Complexity | Too many interfaces for simple logic. | Start with a simple Service/Repository split and evolve. |