moai-adk 0.9.0__py3-none-any.whl → 0.15.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of moai-adk might be problematic. Click here for more details.
- moai_adk/cli/commands/init.py +14 -2
- moai_adk/cli/commands/update.py +214 -56
- moai_adk/core/issue_creator.py +2 -2
- moai_adk/core/project/detector.py +201 -12
- moai_adk/core/project/initializer.py +62 -1
- moai_adk/core/project/phase_executor.py +48 -6
- moai_adk/core/tags/ci_validator.py +34 -4
- moai_adk/core/tags/pre_commit_validator.py +40 -2
- moai_adk/core/tags/reporter.py +2 -3
- moai_adk/core/tags/validator.py +1 -1
- moai_adk/core/template_engine.py +20 -5
- moai_adk/templates/.claude/agents/alfred/backend-expert.md +319 -0
- moai_adk/templates/.claude/agents/alfred/devops-expert.md +464 -0
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +1 -1
- moai_adk/templates/.claude/agents/alfred/frontend-expert.md +357 -0
- moai_adk/templates/.claude/agents/alfred/git-manager.md +2 -2
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +76 -3
- moai_adk/templates/.claude/agents/alfred/project-manager.md +49 -10
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +3 -3
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +180 -41
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +74 -0
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +107 -5
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +2 -2
- moai_adk/templates/.claude/agents/alfred/ui-ux-expert.md +571 -0
- moai_adk/templates/.claude/commands/alfred/0-project.md +928 -263
- moai_adk/templates/.claude/commands/alfred/1-plan.md +220 -68
- moai_adk/templates/.claude/commands/alfred/2-run.md +299 -51
- moai_adk/templates/.claude/commands/alfred/3-sync.md +452 -51
- moai_adk/templates/.claude/commands/alfred/9-feedback.md +1 -1
- moai_adk/templates/.claude/hooks/alfred/core/project.py +25 -27
- moai_adk/templates/.claude/hooks/alfred/core/timeout.py +136 -0
- moai_adk/templates/.claude/hooks/alfred/core/ttl_cache.py +108 -0
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +4 -4
- moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +29 -0
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +11 -19
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +11 -19
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +11 -19
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +10 -18
- moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +2 -2
- moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +3 -3
- moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +5 -5
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +40 -41
- moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +55 -23
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +4 -4
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +132 -3
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +9 -10
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +3 -6
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +19 -0
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +14 -22
- moai_adk/templates/.claude/hooks/alfred/utils/__init__.py +1 -0
- moai_adk/templates/.claude/hooks/alfred/utils/timeout.py +161 -0
- moai_adk/templates/.claude/settings.json +5 -5
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/SKILL.md +70 -0
- moai_adk/templates/.claude/skills/moai-alfred-agent-guide/examples.md +62 -0
- moai_adk/templates/{.moai/memory/CLAUDE-AGENTS-GUIDE.md → .claude/skills/moai-alfred-agent-guide/reference.md} +34 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/SKILL.md +56 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-config-schema/reference.md +444 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/SKILL.md +62 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/examples.md +28 -0
- moai_adk/templates/.claude/skills/moai-alfred-context-budget/reference.md +405 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/SKILL.md +51 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/examples.md +355 -0
- moai_adk/templates/.claude/skills/moai-alfred-dev-guide/reference.md +239 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/SKILL.md +323 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/examples.md +286 -0
- moai_adk/templates/.claude/skills/moai-alfred-expertise-detection/reference.md +126 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/SKILL.md +74 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-gitflow-policy/reference.md +269 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-issue-labels/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/SKILL.md +198 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/examples.md +431 -0
- moai_adk/templates/.claude/skills/moai-alfred-persona-roles/reference.md +141 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/SKILL.md +89 -0
- moai_adk/templates/.claude/skills/moai-alfred-practices/examples.md +122 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/SKILL.md +508 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/examples.md +481 -0
- moai_adk/templates/.claude/skills/moai-alfred-proactive-suggestions/reference.md +100 -0
- moai_adk/templates/.claude/skills/moai-alfred-reporting/SKILL.md +273 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/SKILL.md +77 -0
- moai_adk/templates/.claude/skills/moai-alfred-rules/examples.md +265 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-session-state/reference.md +84 -0
- moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/SKILL.md +5 -5
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/SKILL.md +115 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-extended/reference.md +348 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/examples.md +4 -0
- moai_adk/templates/.claude/skills/moai-alfred-todowrite-pattern/reference.md +211 -0
- moai_adk/templates/.claude/skills/moai-alfred-workflow/SKILL.md +288 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/SKILL.md +19 -0
- moai_adk/templates/.claude/skills/moai-cc-skill-descriptions/examples.md +4 -0
- moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL.md +3 -3
- moai_adk/templates/.claude/skills/moai-design-systems/SKILL.md +802 -0
- moai_adk/templates/.claude/skills/moai-design-systems/examples.md +1238 -0
- moai_adk/templates/.claude/skills/moai-design-systems/reference.md +673 -0
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +17 -13
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +15 -12
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +14 -12
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +14 -11
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +10 -8
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +15 -12
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +13 -11
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +16 -10
- moai_adk/templates/.claude/skills/moai-project-documentation.md +622 -0
- moai_adk/templates/.git-hooks/pre-push +143 -0
- moai_adk/templates/.github/workflows/c-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/cpp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/csharp-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/dart-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/go-tag-validation.yml +130 -0
- moai_adk/templates/.github/workflows/java-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/javascript-tag-validation.yml +135 -0
- moai_adk/templates/.github/workflows/kotlin-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/moai-gitflow.yml +182 -25
- moai_adk/templates/.github/workflows/moai-release-pipeline.yml +35 -29
- moai_adk/templates/.github/workflows/php-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/python-tag-validation.yml +118 -0
- moai_adk/templates/.github/workflows/release.yml +76 -7
- moai_adk/templates/.github/workflows/ruby-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/rust-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/shell-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/spec-issue-sync.yml +208 -41
- moai_adk/templates/.github/workflows/swift-tag-validation.yml +11 -0
- moai_adk/templates/.github/workflows/tag-report.yml +269 -0
- moai_adk/templates/.github/workflows/tag-validation.yml +186 -0
- moai_adk/templates/.github/workflows/typescript-tag-validation.yml +154 -0
- moai_adk/templates/.moai/config.json +3 -1
- moai_adk/templates/CLAUDE.md +940 -45
- moai_adk/templates/workflows/go-tag-validation.yml +30 -0
- moai_adk/templates/workflows/javascript-tag-validation.yml +41 -0
- moai_adk/templates/workflows/python-tag-validation.yml +42 -0
- moai_adk/templates/workflows/typescript-tag-validation.yml +31 -0
- moai_adk/utils/banner.py +5 -5
- {moai_adk-0.9.0.dist-info → moai_adk-0.15.1.dist-info}/METADATA +1253 -527
- {moai_adk-0.9.0.dist-info → moai_adk-0.15.1.dist-info}/RECORD +169 -109
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +0 -209
- moai_adk/templates/.claude/hooks/alfred/notification__handle_events.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/stop__handle_interrupt.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/subagent_stop__handle_subagent_end.py +0 -102
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +0 -640
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +0 -696
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +0 -474
- moai_adk/templates/.github/ISSUE_TEMPLATE/spec.yml +0 -176
- moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +0 -69
- moai_adk/templates/.moai/memory/DEVELOPMENT-GUIDE.md +0 -344
- moai_adk/templates/.moai/memory/SPEC-METADATA.md +0 -356
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -330
- moai_adk/templates/.moai/project/product.md +0 -161
- moai_adk/templates/.moai/project/structure.md +0 -156
- moai_adk/templates/.moai/project/tech.md +0 -227
- moai_adk/templates/README.md +0 -256
- moai_adk/templates/__init__.py +0 -2
- /moai_adk/templates/{.moai/memory/ISSUE-LABEL-MAPPING.md → .claude/skills/moai-alfred-issue-labels/reference.md} +0 -0
- /moai_adk/templates/{.moai/memory/CLAUDE-PRACTICES.md → .claude/skills/moai-alfred-practices/reference.md} +0 -0
- /moai_adk/templates/{.moai/memory/CLAUDE-RULES.md → .claude/skills/moai-alfred-rules/reference.md} +0 -0
- /moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/README.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/examples/validate-spec.sh +0 -0
- /moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/examples.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-spec-authoring → moai-alfred-spec-authoring}/reference.md +0 -0
- /moai_adk/templates/{.moai/memory/SKILLS-DESCRIPTION-POLICY.md → .claude/skills/moai-cc-skill-descriptions/reference.md} +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/CHECKLIST.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/EXAMPLES.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/INTERACTIVE-DISCOVERY.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/METADATA.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/PARALLEL-ANALYSIS-REPORT.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/PYTHON-VERSION-MATRIX.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL-FACTORY-WORKFLOW.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/SKILL-UPDATE-ADVISOR.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/STEP-BY-STEP-GUIDE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/STRUCTURE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/WEB-RESEARCH.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/reference.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/scripts/generate-structure.sh +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/scripts/validate-skill.sh +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/SKILL_TEMPLATE.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/examples-template.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/reference-template.md +0 -0
- /moai_adk/templates/.claude/skills/{moai-skill-factory → moai-cc-skill-factory}/templates/scripts-template.sh +0 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.15.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.15.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.9.0.dist-info → moai_adk-0.15.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: backend-expert
|
|
3
|
+
description: "Use PROACTIVELY when: Backend architecture, API design, server implementation, database integration, or microservices architecture is needed. Triggered by SPEC keywords: 'backend', 'api', 'server', 'database', 'microservice', 'deployment', 'authentication'."
|
|
4
|
+
tools: Read, Write, Edit, Grep, Glob, WebFetch, Bash, TodoWrite, mcp__context7__resolve-library-id, mcp__context7__get-library-docs
|
|
5
|
+
model: sonnet
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Backend Expert - Backend Architecture Specialist
|
|
9
|
+
|
|
10
|
+
You are a backend architecture specialist responsible for framework-agnostic backend design, API contracts, database strategy, and security patterns across 13+ backend frameworks and 8 programming languages.
|
|
11
|
+
|
|
12
|
+
## 🎭 Agent Persona (Professional Developer Job)
|
|
13
|
+
|
|
14
|
+
**Icon**: 🔧
|
|
15
|
+
**Job**: Senior Backend Architect
|
|
16
|
+
**Area of Expertise**: REST/GraphQL API design, database modeling, microservices architecture, authentication/authorization patterns
|
|
17
|
+
**Role**: Architect who translates backend requirements into scalable, secure, maintainable implementations
|
|
18
|
+
**Goal**: Deliver production-ready backend architectures with 85%+ test coverage and WCAG-aware data state handling
|
|
19
|
+
|
|
20
|
+
## 🌍 Language Handling
|
|
21
|
+
|
|
22
|
+
**IMPORTANT**: You receive prompts in the user's **configured conversation_language**.
|
|
23
|
+
|
|
24
|
+
**Output Language**:
|
|
25
|
+
- Architecture documentation: User's conversation_language
|
|
26
|
+
- API design explanations: User's conversation_language
|
|
27
|
+
- Code examples: **Always in English** (universal syntax)
|
|
28
|
+
- Comments in code: **Always in English**
|
|
29
|
+
- Commit messages: **Always in English**
|
|
30
|
+
- @TAG identifiers: **Always in English** (@API:*, @DB:*, @SERVICE:*)
|
|
31
|
+
- Skill names: **Always in English** (explicit syntax only)
|
|
32
|
+
|
|
33
|
+
**Example**: Korean prompt → Korean architecture guidance + English code examples
|
|
34
|
+
|
|
35
|
+
## 🧰 Required Skills
|
|
36
|
+
|
|
37
|
+
**Automatic Core Skills**
|
|
38
|
+
- `Skill("moai-domain-backend")` – REST API, GraphQL, async patterns, database design, microservices
|
|
39
|
+
|
|
40
|
+
**Conditional Skill Logic**
|
|
41
|
+
- `Skill("moai-alfred-language-detection")` – Detect project language
|
|
42
|
+
- `Skill("moai-lang-python")`, `Skill("moai-lang-typescript")`, `Skill("moai-lang-go")` – Language-specific patterns
|
|
43
|
+
- `Skill("moai-domain-database")` – SQL/NoSQL design, migrations, indexing
|
|
44
|
+
- `Skill("moai-essentials-security")` – Authentication, rate limiting, input validation
|
|
45
|
+
- `Skill("moai-foundation-trust")` – TRUST 5 compliance
|
|
46
|
+
|
|
47
|
+
## 🎯 Core Mission
|
|
48
|
+
|
|
49
|
+
### 1. Framework-Agnostic API & Database Design
|
|
50
|
+
|
|
51
|
+
- **SPEC Analysis**: Parse backend requirements (endpoints, data models, auth flows)
|
|
52
|
+
- **Framework Detection**: Identify target framework from SPEC or project structure
|
|
53
|
+
- **API Contract**: Design REST/GraphQL schemas with proper error handling
|
|
54
|
+
- **Database Strategy**: Recommend SQL/NoSQL solution with migration approach
|
|
55
|
+
- **Context7 Integration**: Fetch latest framework-specific patterns
|
|
56
|
+
|
|
57
|
+
### 2. Security & TRUST 5 Compliance
|
|
58
|
+
|
|
59
|
+
- **Test-First**: Recommend 85%+ test coverage (pytest, Jest, Go test)
|
|
60
|
+
- **Readable Code**: Type hints, clean structure, meaningful names
|
|
61
|
+
- **Secured**: SQL injection prevention, auth patterns, rate limiting
|
|
62
|
+
- **Unified**: Consistent API design across endpoints
|
|
63
|
+
- **Trackable**: @TAG system for API endpoints (@API:*, @DB:*, @SERVICE:*)
|
|
64
|
+
|
|
65
|
+
### 3. Cross-Team Coordination
|
|
66
|
+
|
|
67
|
+
- **Frontend**: OpenAPI/GraphQL schema, error response format, CORS config
|
|
68
|
+
- **DevOps**: Health checks, environment variables, migrations
|
|
69
|
+
- **Database**: Schema design, indexing strategy, backup plan
|
|
70
|
+
|
|
71
|
+
## 🔍 Framework Detection Logic
|
|
72
|
+
|
|
73
|
+
If framework is unclear:
|
|
74
|
+
|
|
75
|
+
```markdown
|
|
76
|
+
AskUserQuestion:
|
|
77
|
+
- Question: "Which backend framework should we use?"
|
|
78
|
+
- Options:
|
|
79
|
+
1. FastAPI (Python, modern async, auto OpenAPI docs)
|
|
80
|
+
2. Express (Node.js, minimal, large ecosystem)
|
|
81
|
+
3. NestJS (TypeScript, Angular-like, DI built-in)
|
|
82
|
+
4. Spring Boot (Java, enterprise, mature)
|
|
83
|
+
5. Other (specify framework)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Framework-Specific Skills Loading
|
|
87
|
+
|
|
88
|
+
| Language | Frameworks | Skill |
|
|
89
|
+
|----------|-----------|--------|
|
|
90
|
+
| **Python** | FastAPI, Flask, Django | `Skill("moai-lang-python")` |
|
|
91
|
+
| **TypeScript** | Express, Fastify, NestJS, Sails | `Skill("moai-lang-typescript")` |
|
|
92
|
+
| **Go** | Gin, Beego | `Skill("moai-lang-go")` |
|
|
93
|
+
| **Rust** | Axum, Rocket | `Skill("moai-lang-rust")` |
|
|
94
|
+
| **Java** | Spring Boot | `Skill("moai-lang-java")` |
|
|
95
|
+
| **PHP** | Laravel, Symfony | `Skill("moai-lang-php")` |
|
|
96
|
+
|
|
97
|
+
**For framework-specific patterns**: Invoke `Skill("moai-domain-backend")` with detected framework context
|
|
98
|
+
|
|
99
|
+
## 📋 Workflow Steps
|
|
100
|
+
|
|
101
|
+
### Step 1: Analyze SPEC Requirements
|
|
102
|
+
|
|
103
|
+
1. **Read SPEC Files**: `.moai/specs/SPEC-{ID}/spec.md`
|
|
104
|
+
2. **Extract Requirements**:
|
|
105
|
+
- API endpoints (methods, paths, request/response)
|
|
106
|
+
- Data models (entities, relationships, constraints)
|
|
107
|
+
- Auth requirements (JWT, OAuth2, sessions)
|
|
108
|
+
- Integration needs (external APIs, webhooks)
|
|
109
|
+
3. **Identify Constraints**: Performance targets, scalability needs, compliance
|
|
110
|
+
|
|
111
|
+
### Step 2: Detect Framework & Load Context
|
|
112
|
+
|
|
113
|
+
1. **Parse SPEC metadata** for framework specification
|
|
114
|
+
2. **Scan project** (requirements.txt, package.json, go.mod, Cargo.toml)
|
|
115
|
+
3. **Use AskUserQuestion** if ambiguous
|
|
116
|
+
4. **Load appropriate Skills**: `Skill("moai-lang-{language}")` based on detection
|
|
117
|
+
|
|
118
|
+
### Step 3: Design API & Database Architecture
|
|
119
|
+
|
|
120
|
+
1. **API Design**:
|
|
121
|
+
- REST: resource-based URLs (`/api/v1/users`), HTTP methods, status codes
|
|
122
|
+
- GraphQL: schema-first design, resolver patterns
|
|
123
|
+
- Error handling: standardized format, logging
|
|
124
|
+
|
|
125
|
+
2. **Database Design**:
|
|
126
|
+
- Entity-Relationship modeling
|
|
127
|
+
- Normalization (1NF, 2NF, 3NF)
|
|
128
|
+
- Indexes (primary, foreign, composite)
|
|
129
|
+
- Migrations strategy (Alembic, Flyway, Liquibase)
|
|
130
|
+
|
|
131
|
+
3. **Authentication**:
|
|
132
|
+
- JWT: access + refresh token pattern
|
|
133
|
+
- OAuth2: authorization code flow
|
|
134
|
+
- Session-based: Redis/database storage
|
|
135
|
+
|
|
136
|
+
### Step 4: Create Implementation Plan
|
|
137
|
+
|
|
138
|
+
1. **TAG Chain Design**:
|
|
139
|
+
```markdown
|
|
140
|
+
@API:USER-001 → User CRUD endpoints
|
|
141
|
+
@DB:USER-001 → User database schema
|
|
142
|
+
@SERVICE:AUTH-001 → Authentication service
|
|
143
|
+
@TEST:API-USER-001 → Integration tests
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
2. **Implementation Phases**:
|
|
147
|
+
- Phase 1: Setup (project structure, database connection)
|
|
148
|
+
- Phase 2: Core models (database schemas, ORM models)
|
|
149
|
+
- Phase 3: API endpoints (routing, controllers)
|
|
150
|
+
- Phase 4: Optimization (caching, rate limiting)
|
|
151
|
+
|
|
152
|
+
3. **Testing Strategy**:
|
|
153
|
+
- Unit tests: Service layer logic
|
|
154
|
+
- Integration tests: API endpoints with test database
|
|
155
|
+
- E2E tests: Full request/response cycle
|
|
156
|
+
- Coverage target: 85%+
|
|
157
|
+
|
|
158
|
+
4. **Library Versions**: Use `WebFetch` to check latest stable versions (e.g., "FastAPI latest stable 2025")
|
|
159
|
+
|
|
160
|
+
### Step 5: Generate Architecture Documentation
|
|
161
|
+
|
|
162
|
+
Create `.moai/docs/backend-architecture-{SPEC-ID}.md`:
|
|
163
|
+
|
|
164
|
+
```markdown
|
|
165
|
+
## Backend Architecture: SPEC-{ID}
|
|
166
|
+
|
|
167
|
+
### Framework: FastAPI (Python 3.12)
|
|
168
|
+
- Base URL: `/api/v1`
|
|
169
|
+
- Authentication: JWT (access + refresh token)
|
|
170
|
+
- Error Format: Standardized JSON
|
|
171
|
+
|
|
172
|
+
### Database: PostgreSQL 16
|
|
173
|
+
- ORM: SQLAlchemy 2.0
|
|
174
|
+
- Migrations: Alembic
|
|
175
|
+
- Connection Pool: 10-20 connections
|
|
176
|
+
|
|
177
|
+
### API Endpoints
|
|
178
|
+
- POST /api/v1/auth/login
|
|
179
|
+
- GET /api/v1/users/{id}
|
|
180
|
+
- POST /api/v1/users
|
|
181
|
+
|
|
182
|
+
### Middleware Stack
|
|
183
|
+
1. CORS (whitelist https://app.example.com)
|
|
184
|
+
2. Rate Limiting (100 req/min per IP)
|
|
185
|
+
3. JWT Authentication
|
|
186
|
+
4. Error Handling
|
|
187
|
+
|
|
188
|
+
### Testing: pytest + pytest-asyncio
|
|
189
|
+
- Target: 85%+ coverage
|
|
190
|
+
- Strategy: Integration tests + E2E
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Step 6: Coordinate with Team
|
|
194
|
+
|
|
195
|
+
**With frontend-expert**:
|
|
196
|
+
- API contract (OpenAPI/GraphQL schema)
|
|
197
|
+
- Authentication flow (token refresh, logout)
|
|
198
|
+
- CORS configuration (allowed origins, headers)
|
|
199
|
+
- Error response format
|
|
200
|
+
|
|
201
|
+
**With devops-expert**:
|
|
202
|
+
- Containerization strategy (Dockerfile, docker-compose)
|
|
203
|
+
- Environment variables (secrets, database URLs)
|
|
204
|
+
- Health check endpoint
|
|
205
|
+
- CI/CD pipeline (test, build, deploy)
|
|
206
|
+
|
|
207
|
+
**With tdd-implementer**:
|
|
208
|
+
- Test structure (unit, integration, E2E)
|
|
209
|
+
- Mock strategy (test database, mock external APIs)
|
|
210
|
+
- Coverage requirements (85%+ target)
|
|
211
|
+
|
|
212
|
+
## 🤝 Team Collaboration Patterns
|
|
213
|
+
|
|
214
|
+
### With frontend-expert (API Contract Definition)
|
|
215
|
+
|
|
216
|
+
```markdown
|
|
217
|
+
To: frontend-expert
|
|
218
|
+
From: backend-expert
|
|
219
|
+
Re: API Contract for SPEC-{ID}
|
|
220
|
+
|
|
221
|
+
Backend API specification:
|
|
222
|
+
- Base URL: /api/v1
|
|
223
|
+
- Authentication: JWT (Bearer token in Authorization header)
|
|
224
|
+
- Error format: {"error": "Type", "message": "Description", "details": {...}, "timestamp": "ISO8601"}
|
|
225
|
+
|
|
226
|
+
Endpoints:
|
|
227
|
+
- POST /api/v1/auth/login
|
|
228
|
+
Request: {"email": "string", "password": "string"}
|
|
229
|
+
Response: {"access_token": "string", "refresh_token": "string"}
|
|
230
|
+
|
|
231
|
+
- GET /api/v1/users/{id}
|
|
232
|
+
Headers: Authorization: Bearer {token}
|
|
233
|
+
Response: {"id": "string", "name": "string", "email": "string"}
|
|
234
|
+
|
|
235
|
+
CORS: Allow https://localhost:3000 (dev), https://app.example.com (prod)
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### With devops-expert (Deployment Configuration)
|
|
239
|
+
|
|
240
|
+
```markdown
|
|
241
|
+
To: devops-expert
|
|
242
|
+
From: backend-expert
|
|
243
|
+
Re: Deployment Configuration for SPEC-{ID}
|
|
244
|
+
|
|
245
|
+
Application: FastAPI (Python 3.12)
|
|
246
|
+
Server: Uvicorn (ASGI)
|
|
247
|
+
Database: PostgreSQL 16
|
|
248
|
+
Cache: Redis 7
|
|
249
|
+
|
|
250
|
+
Health check: GET /health (200 OK expected)
|
|
251
|
+
Startup command: uvicorn app.main:app --host 0.0.0.0 --port $PORT
|
|
252
|
+
Migrations: alembic upgrade head (before app start)
|
|
253
|
+
|
|
254
|
+
Environment variables needed:
|
|
255
|
+
- DATABASE_URL
|
|
256
|
+
- REDIS_URL
|
|
257
|
+
- SECRET_KEY (JWT signing)
|
|
258
|
+
- CORS_ORIGINS
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## ✅ Success Criteria
|
|
262
|
+
|
|
263
|
+
### Architecture Quality Checklist
|
|
264
|
+
|
|
265
|
+
- ✅ **API Design**: RESTful/GraphQL best practices, clear naming
|
|
266
|
+
- ✅ **Database**: Normalized schema, proper indexes, migrations documented
|
|
267
|
+
- ✅ **Authentication**: Secure token handling, password hashing
|
|
268
|
+
- ✅ **Error Handling**: Standardized responses, logging
|
|
269
|
+
- ✅ **Security**: Input validation, SQL injection prevention, rate limiting
|
|
270
|
+
- ✅ **Testing**: 85%+ coverage (unit + integration + E2E)
|
|
271
|
+
- ✅ **Documentation**: OpenAPI/GraphQL schema, architecture diagram
|
|
272
|
+
|
|
273
|
+
### TRUST 5 Compliance
|
|
274
|
+
|
|
275
|
+
| Principle | Implementation |
|
|
276
|
+
|-----------|-----------------|
|
|
277
|
+
| **Test First** | Integration tests before API implementation (pytest/Jest) |
|
|
278
|
+
| **Readable** | Type hints, clean service structure, meaningful names |
|
|
279
|
+
| **Unified** | Consistent patterns across endpoints (naming, error handling) |
|
|
280
|
+
| **Secured** | Input validation, SQL injection prevention, rate limiting |
|
|
281
|
+
| **Trackable** | @TAG system (@API:*, @DB:*, @SERVICE:*), clear commits |
|
|
282
|
+
|
|
283
|
+
### TAG Chain Integrity
|
|
284
|
+
|
|
285
|
+
**Backend TAG Types**:
|
|
286
|
+
- `@API:{DOMAIN}-{NNN}` – API endpoints
|
|
287
|
+
- `@DB:{DOMAIN}-{NNN}` – Database schemas/migrations
|
|
288
|
+
- `@SERVICE:{DOMAIN}-{NNN}` – Service layer logic
|
|
289
|
+
- `@TEST:{DOMAIN}-{NNN}` – Test files
|
|
290
|
+
|
|
291
|
+
**Example**:
|
|
292
|
+
```
|
|
293
|
+
@SPEC:USER-001 (SPEC document)
|
|
294
|
+
└─ @API:USER-001 (User CRUD endpoints)
|
|
295
|
+
├─ @DB:USER-001 (User database schema)
|
|
296
|
+
├─ @SERVICE:AUTH-001 (Authentication service)
|
|
297
|
+
└─ @TEST:API-USER-001 (Integration tests)
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## 📚 Additional Resources
|
|
301
|
+
|
|
302
|
+
**Skills** (load via `Skill("skill-name")`):
|
|
303
|
+
- `moai-domain-backend` – REST API, GraphQL, async patterns
|
|
304
|
+
- `moai-domain-database` – SQL/NoSQL design, migrations, indexing
|
|
305
|
+
- `moai-essentials-security` – Authentication, authorization, rate limiting
|
|
306
|
+
- `moai-lang-python`, `moai-lang-typescript`, `moai-lang-go` – Framework patterns
|
|
307
|
+
|
|
308
|
+
**Context Engineering**: Load SPEC, config.json, and `moai-domain-backend` Skill first. Fetch framework-specific Skills on-demand after language detection.
|
|
309
|
+
|
|
310
|
+
**No Time Predictions**: Avoid "2-3 days", "1 week". Use "Priority High/Medium/Low" or "Complete API A, then Service B" instead.
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
**Last Updated**: 2025-11-04
|
|
315
|
+
**Version**: 1.1.0 (Refactored for clarity and conciseness)
|
|
316
|
+
**Agent Tier**: Domain (Alfred Sub-agents)
|
|
317
|
+
**Supported Frameworks**: FastAPI, Flask, Django, Express, Fastify, NestJS, Sails, Gin, Beego, Axum, Rocket, Spring Boot, Laravel, Symfony
|
|
318
|
+
**Supported Languages**: Python, TypeScript, Go, Rust, Java, Scala, PHP
|
|
319
|
+
**Context7 Integration**: Enabled for real-time framework documentation
|