universal-dev-standards 5.0.0-rc.8 → 5.0.0
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.
- package/bin/uds.js +5 -3
- package/bundled/ai/standards/acceptance-criteria-traceability.ai.yaml +178 -0
- package/bundled/ai/standards/agent-dispatch.ai.yaml +69 -0
- package/bundled/ai/standards/ai-command-behavior.ai.yaml +45 -0
- package/bundled/ai/standards/api-design-standards.ai.yaml +192 -0
- package/bundled/ai/standards/branch-completion.ai.yaml +82 -0
- package/bundled/ai/standards/change-batching-standards.ai.yaml +195 -0
- package/bundled/ai/standards/database-standards.ai.yaml +220 -0
- package/bundled/ai/standards/error-codes.ai.yaml +37 -2
- package/bundled/ai/standards/git-worktree.ai.yaml +77 -0
- package/bundled/ai/standards/logging.ai.yaml +21 -2
- package/bundled/ai/standards/model-selection.ai.yaml +81 -0
- package/bundled/ai/standards/pipeline-integration-standards.ai.yaml +184 -0
- package/bundled/ai/standards/systematic-debugging.ai.yaml +73 -0
- package/bundled/ai/standards/verification-evidence.ai.yaml +84 -0
- package/bundled/ai/standards/workflow-enforcement.ai.yaml +253 -0
- package/bundled/core/acceptance-criteria-traceability.md +293 -0
- package/bundled/core/agent-dispatch.md +149 -0
- package/bundled/core/ai-command-behavior.md +239 -0
- package/bundled/core/api-design-standards.md +938 -0
- package/bundled/core/branch-completion.md +158 -0
- package/bundled/core/change-batching-standards.md +257 -0
- package/bundled/core/checkin-standards.md +43 -6
- package/bundled/core/database-standards.md +828 -0
- package/bundled/core/error-code-standards.md +228 -2
- package/bundled/core/forward-derivation-standards.md +54 -2
- package/bundled/core/git-worktree.md +131 -0
- package/bundled/core/model-selection.md +153 -0
- package/bundled/core/pipeline-integration-standards.md +230 -0
- package/bundled/core/systematic-debugging.md +156 -0
- package/bundled/core/testing-standards.md +49 -39
- package/bundled/core/verification-evidence.md +172 -0
- package/bundled/core/workflow-enforcement.md +132 -0
- package/bundled/locales/zh-CN/CLAUDE.md +2 -2
- package/bundled/locales/zh-CN/README.md +4 -4
- package/bundled/locales/zh-CN/SECURITY.md +92 -0
- package/bundled/locales/zh-CN/core/acceptance-criteria-traceability.md +301 -0
- package/bundled/locales/zh-CN/core/acceptance-test-driven-development.md +47 -0
- package/bundled/locales/zh-CN/core/accessibility-standards.md +124 -0
- package/bundled/locales/zh-CN/core/agent-dispatch.md +113 -0
- package/bundled/locales/zh-CN/core/ai-agreement-standards.md +103 -0
- package/bundled/locales/zh-CN/core/ai-command-behavior.md +247 -0
- package/bundled/locales/zh-CN/core/api-design-standards.md +946 -0
- package/bundled/locales/zh-CN/core/behavior-driven-development.md +48 -0
- package/bundled/locales/zh-CN/core/branch-completion.md +112 -0
- package/bundled/locales/zh-CN/core/change-batching-standards.md +265 -0
- package/bundled/locales/zh-CN/core/checkin-standards.md +43 -5
- package/bundled/locales/zh-CN/core/context-aware-loading.md +106 -0
- package/bundled/locales/zh-CN/core/database-standards.md +836 -0
- package/bundled/locales/zh-CN/core/deployment-standards.md +80 -0
- package/bundled/locales/zh-CN/core/error-code-standards.md +2 -2
- package/bundled/locales/zh-CN/core/forward-derivation-standards.md +493 -0
- package/bundled/locales/zh-CN/core/git-worktree.md +101 -0
- package/bundled/locales/zh-CN/core/model-selection.md +112 -0
- package/bundled/locales/zh-CN/core/performance-standards.md +104 -0
- package/bundled/locales/zh-CN/core/pipeline-integration-standards.md +238 -0
- package/bundled/locales/zh-CN/core/project-context-memory.md +124 -0
- package/bundled/locales/zh-CN/core/requirement-engineering.md +49 -0
- package/bundled/locales/zh-CN/core/security-standards.md +100 -0
- package/bundled/locales/zh-CN/core/systematic-debugging.md +106 -0
- package/bundled/locales/zh-CN/core/test-governance.md +116 -0
- package/bundled/locales/zh-CN/core/testing-standards.md +392 -156
- package/bundled/locales/zh-CN/core/verification-evidence.md +118 -0
- package/bundled/locales/zh-CN/core/virtual-organization-standards.md +104 -0
- package/bundled/locales/zh-CN/core/workflow-enforcement.md +132 -0
- package/bundled/locales/zh-CN/docs/CHEATSHEET.md +27 -1
- package/bundled/locales/zh-CN/docs/CLI-INIT-OPTIONS.md +9 -1
- package/bundled/locales/zh-CN/docs/FEATURE-REFERENCE.md +37 -9
- package/bundled/locales/zh-CN/docs/USER-MANUAL.md +652 -0
- package/bundled/locales/zh-CN/integrations/github-copilot/copilot-instructions.md +1 -1
- package/bundled/locales/zh-CN/integrations/openspec/AGENTS.md +29 -4
- package/bundled/locales/zh-CN/integrations/spec-kit/AGENTS.md +143 -72
- package/bundled/locales/zh-CN/skills/ac-coverage-assistant/SKILL.md +126 -0
- package/bundled/locales/zh-CN/skills/api-design-assistant/SKILL.md +100 -0
- package/bundled/locales/zh-CN/skills/brainstorm-assistant/SKILL.md +119 -0
- package/bundled/locales/zh-CN/skills/ci-cd-assistant/SKILL.md +82 -0
- package/bundled/locales/zh-CN/skills/commands/ac-coverage.md +97 -0
- package/bundled/locales/zh-CN/skills/commands/api-design.md +94 -0
- package/bundled/locales/zh-CN/skills/commands/atdd.md +163 -0
- package/bundled/locales/zh-CN/skills/commands/audit.md +77 -0
- package/bundled/locales/zh-CN/skills/commands/bdd.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/brainstorm.md +87 -0
- package/bundled/locales/zh-CN/skills/commands/changelog.md +63 -0
- package/bundled/locales/zh-CN/skills/commands/check.md +219 -0
- package/bundled/locales/zh-CN/skills/commands/checkin.md +61 -0
- package/bundled/locales/zh-CN/skills/commands/ci-cd.md +77 -0
- package/bundled/locales/zh-CN/skills/commands/commit.md +81 -0
- package/bundled/locales/zh-CN/skills/commands/config.md +207 -0
- package/bundled/locales/zh-CN/skills/commands/coverage.md +74 -0
- package/bundled/locales/zh-CN/skills/commands/database.md +78 -0
- package/bundled/locales/zh-CN/skills/commands/derive-all.md +58 -0
- package/bundled/locales/zh-CN/skills/commands/derive-atdd.md +54 -0
- package/bundled/locales/zh-CN/skills/commands/derive-bdd.md +53 -0
- package/bundled/locales/zh-CN/skills/commands/derive-tdd.md +54 -0
- package/bundled/locales/zh-CN/skills/commands/derive.md +78 -0
- package/bundled/locales/zh-CN/skills/commands/dev-workflow.md +119 -0
- package/bundled/locales/zh-CN/skills/commands/discover.md +86 -0
- package/bundled/locales/zh-CN/skills/commands/docgen.md +67 -0
- package/bundled/locales/zh-CN/skills/commands/docs.md +65 -0
- package/bundled/locales/zh-CN/skills/commands/durable.md +87 -0
- package/bundled/locales/zh-CN/skills/commands/guide.md +52 -0
- package/bundled/locales/zh-CN/skills/commands/incident.md +92 -0
- package/bundled/locales/zh-CN/skills/commands/init.md +272 -0
- package/bundled/locales/zh-CN/skills/commands/methodology.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/metrics.md +73 -0
- package/bundled/locales/zh-CN/skills/commands/migrate.md +92 -0
- package/bundled/locales/zh-CN/skills/commands/pr.md +80 -0
- package/bundled/locales/zh-CN/skills/commands/refactor.md +1 -1
- package/bundled/locales/zh-CN/skills/commands/release.md +62 -0
- package/bundled/locales/zh-CN/skills/commands/requirement.md +54 -0
- package/bundled/locales/zh-CN/skills/commands/reverse-bdd.md +47 -0
- package/bundled/locales/zh-CN/skills/commands/reverse-sdd.md +51 -0
- package/bundled/locales/zh-CN/skills/commands/reverse-tdd.md +51 -0
- package/bundled/locales/zh-CN/skills/commands/reverse.md +63 -0
- package/bundled/locales/zh-CN/skills/commands/review.md +50 -0
- package/bundled/locales/zh-CN/skills/commands/scan.md +76 -0
- package/bundled/locales/zh-CN/skills/commands/sdd-retro.md +40 -0
- package/bundled/locales/zh-CN/skills/commands/sdd.md +379 -0
- package/bundled/locales/zh-CN/skills/commands/security.md +75 -0
- package/bundled/locales/zh-CN/skills/commands/tdd.md +111 -0
- package/bundled/locales/zh-CN/skills/commands/update.md +337 -0
- package/bundled/locales/zh-CN/skills/commit-standards/SKILL.md +1 -2
- package/bundled/locales/zh-CN/skills/database-assistant/SKILL.md +97 -0
- package/bundled/locales/zh-CN/skills/dev-workflow-guide/SKILL.md +145 -0
- package/bundled/locales/zh-CN/skills/durable-execution-assistant/SKILL.md +84 -0
- package/bundled/locales/zh-CN/skills/incident-response-assistant/SKILL.md +107 -0
- package/bundled/locales/zh-CN/skills/metrics-dashboard-assistant/SKILL.md +67 -0
- package/bundled/locales/zh-CN/skills/migration-assistant/SKILL.md +77 -0
- package/bundled/locales/zh-CN/skills/pr-automation-assistant/SKILL.md +90 -0
- package/bundled/locales/zh-CN/skills/security-assistant/SKILL.md +79 -0
- package/bundled/locales/zh-CN/skills/security-scan-assistant/SKILL.md +72 -0
- package/bundled/locales/zh-CN/skills/spec-driven-dev/SKILL.md +73 -10
- package/bundled/locales/zh-CN/skills/spec-driven-dev/guide.md +267 -122
- package/bundled/locales/zh-TW/CLAUDE.md +2 -2
- package/bundled/locales/zh-TW/README.md +4 -4
- package/bundled/locales/zh-TW/SECURITY.md +92 -0
- package/bundled/locales/zh-TW/core/acceptance-criteria-traceability.md +301 -0
- package/bundled/locales/zh-TW/core/acceptance-test-driven-development.md +47 -0
- package/bundled/locales/zh-TW/core/accessibility-standards.md +84 -0
- package/bundled/locales/zh-TW/core/agent-dispatch.md +89 -0
- package/bundled/locales/zh-TW/core/ai-agreement-standards.md +87 -0
- package/bundled/locales/zh-TW/core/ai-command-behavior.md +247 -0
- package/bundled/locales/zh-TW/core/api-design-standards.md +946 -0
- package/bundled/locales/zh-TW/core/behavior-driven-development.md +63 -0
- package/bundled/locales/zh-TW/core/branch-completion.md +76 -0
- package/bundled/locales/zh-TW/core/change-batching-standards.md +265 -0
- package/bundled/locales/zh-TW/core/checkin-standards.md +39 -5
- package/bundled/locales/zh-TW/core/context-aware-loading.md +86 -0
- package/bundled/locales/zh-TW/core/database-standards.md +836 -0
- package/bundled/locales/zh-TW/core/deployment-standards.md +66 -0
- package/bundled/locales/zh-TW/core/error-code-standards.md +230 -4
- package/bundled/locales/zh-TW/core/forward-derivation-standards.md +62 -2
- package/bundled/locales/zh-TW/core/git-worktree.md +104 -0
- package/bundled/locales/zh-TW/core/model-selection.md +83 -0
- package/bundled/locales/zh-TW/core/performance-standards.md +84 -0
- package/bundled/locales/zh-TW/core/pipeline-integration-standards.md +238 -0
- package/bundled/locales/zh-TW/core/project-context-memory.md +79 -0
- package/bundled/locales/zh-TW/core/requirement-engineering.md +79 -0
- package/bundled/locales/zh-TW/core/security-standards.md +74 -0
- package/bundled/locales/zh-TW/core/systematic-debugging.md +95 -0
- package/bundled/locales/zh-TW/core/test-governance.md +88 -0
- package/bundled/locales/zh-TW/core/testing-standards.md +309 -86
- package/bundled/locales/zh-TW/core/verification-evidence.md +94 -0
- package/bundled/locales/zh-TW/core/virtual-organization-standards.md +88 -0
- package/bundled/locales/zh-TW/core/workflow-enforcement.md +132 -0
- package/bundled/locales/zh-TW/docs/CHEATSHEET.md +27 -1
- package/bundled/locales/zh-TW/docs/CLI-INIT-OPTIONS.md +9 -1
- package/bundled/locales/zh-TW/docs/FEATURE-REFERENCE.md +37 -9
- package/bundled/locales/zh-TW/docs/USER-MANUAL.md +652 -0
- package/bundled/locales/zh-TW/integrations/github-copilot/copilot-instructions.md +1 -1
- package/bundled/locales/zh-TW/integrations/openspec/AGENTS.md +29 -4
- package/bundled/locales/zh-TW/integrations/spec-kit/AGENTS.md +142 -71
- package/bundled/locales/zh-TW/skills/ac-coverage-assistant/SKILL.md +127 -0
- package/bundled/locales/zh-TW/skills/ai-friendly-architecture/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/ai-instruction-standards/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/api-design-assistant/SKILL.md +97 -0
- package/bundled/locales/zh-TW/skills/atdd-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/audit-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/bdd-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/brainstorm-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/changelog-guide/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/checkin-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/ci-cd-assistant/SKILL.md +79 -0
- package/bundled/locales/zh-TW/skills/code-review-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/commands/ac-coverage.md +95 -0
- package/bundled/locales/zh-TW/skills/commands/api-design.md +92 -0
- package/bundled/locales/zh-TW/skills/commands/atdd.md +167 -0
- package/bundled/locales/zh-TW/skills/commands/audit.md +75 -0
- package/bundled/locales/zh-TW/skills/commands/bdd.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/brainstorm.md +91 -0
- package/bundled/locales/zh-TW/skills/commands/changelog.md +67 -0
- package/bundled/locales/zh-TW/skills/commands/check.md +223 -0
- package/bundled/locales/zh-TW/skills/commands/checkin.md +65 -0
- package/bundled/locales/zh-TW/skills/commands/ci-cd.md +75 -0
- package/bundled/locales/zh-TW/skills/commands/commit.md +85 -0
- package/bundled/locales/zh-TW/skills/commands/config.md +211 -0
- package/bundled/locales/zh-TW/skills/commands/coverage.md +78 -0
- package/bundled/locales/zh-TW/skills/commands/database.md +76 -0
- package/bundled/locales/zh-TW/skills/commands/derive-all.md +62 -0
- package/bundled/locales/zh-TW/skills/commands/derive-atdd.md +58 -0
- package/bundled/locales/zh-TW/skills/commands/derive-bdd.md +54 -0
- package/bundled/locales/zh-TW/skills/commands/derive-tdd.md +55 -0
- package/bundled/locales/zh-TW/skills/commands/derive.md +79 -0
- package/bundled/locales/zh-TW/skills/commands/dev-workflow.md +120 -0
- package/bundled/locales/zh-TW/skills/commands/discover.md +87 -0
- package/bundled/locales/zh-TW/skills/commands/docgen.md +68 -0
- package/bundled/locales/zh-TW/skills/commands/docs.md +66 -0
- package/bundled/locales/zh-TW/skills/commands/durable.md +85 -0
- package/bundled/locales/zh-TW/skills/commands/guide.md +51 -0
- package/bundled/locales/zh-TW/skills/commands/incident.md +90 -0
- package/bundled/locales/zh-TW/skills/commands/init.md +273 -0
- package/bundled/locales/zh-TW/skills/commands/methodology.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/metrics.md +71 -0
- package/bundled/locales/zh-TW/skills/commands/migrate.md +90 -0
- package/bundled/locales/zh-TW/skills/commands/pr.md +78 -0
- package/bundled/locales/zh-TW/skills/commands/refactor.md +1 -1
- package/bundled/locales/zh-TW/skills/commands/release.md +63 -0
- package/bundled/locales/zh-TW/skills/commands/requirement.md +61 -0
- package/bundled/locales/zh-TW/skills/commands/reverse-bdd.md +54 -0
- package/bundled/locales/zh-TW/skills/commands/reverse-sdd.md +58 -0
- package/bundled/locales/zh-TW/skills/commands/reverse-tdd.md +58 -0
- package/bundled/locales/zh-TW/skills/commands/reverse.md +70 -0
- package/bundled/locales/zh-TW/skills/commands/review.md +57 -0
- package/bundled/locales/zh-TW/skills/commands/scan.md +74 -0
- package/bundled/locales/zh-TW/skills/commands/sdd-retro.md +47 -0
- package/bundled/locales/zh-TW/skills/commands/sdd.md +362 -0
- package/bundled/locales/zh-TW/skills/commands/security.md +73 -0
- package/bundled/locales/zh-TW/skills/commands/tdd.md +115 -0
- package/bundled/locales/zh-TW/skills/commands/update.md +326 -0
- package/bundled/locales/zh-TW/skills/commit-standards/SKILL.md +2 -6
- package/bundled/locales/zh-TW/skills/database-assistant/SKILL.md +94 -0
- package/bundled/locales/zh-TW/skills/dev-workflow-guide/SKILL.md +140 -0
- package/bundled/locales/zh-TW/skills/docs-generator/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/documentation-guide/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/durable-execution-assistant/SKILL.md +81 -0
- package/bundled/locales/zh-TW/skills/error-code-guide/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/forward-derivation/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/git-workflow-guide/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/incident-response-assistant/SKILL.md +104 -0
- package/bundled/locales/zh-TW/skills/logging-guide/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/methodology-system/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/metrics-dashboard-assistant/SKILL.md +64 -0
- package/bundled/locales/zh-TW/skills/migration-assistant/SKILL.md +74 -0
- package/bundled/locales/zh-TW/skills/pr-automation-assistant/SKILL.md +87 -0
- package/bundled/locales/zh-TW/skills/project-discovery/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/refactoring-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/release-standards/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/requirement-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/reverse-engineer/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/security-assistant/SKILL.md +76 -0
- package/bundled/locales/zh-TW/skills/security-scan-assistant/SKILL.md +69 -0
- package/bundled/locales/zh-TW/skills/spec-driven-dev/SKILL.md +74 -14
- package/bundled/locales/zh-TW/skills/spec-driven-dev/guide.md +243 -98
- package/bundled/locales/zh-TW/skills/tdd-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/test-coverage-assistant/SKILL.md +1 -4
- package/bundled/locales/zh-TW/skills/testing-guide/SKILL.md +1 -5
- package/bundled/skills/README.md +11 -0
- package/bundled/skills/ac-coverage-assistant/SKILL.md +127 -0
- package/bundled/skills/ai-collaboration-standards/SKILL.md +10 -0
- package/bundled/skills/ai-friendly-architecture/SKILL.md +10 -0
- package/bundled/skills/ai-instruction-standards/SKILL.md +10 -0
- package/bundled/skills/api-design-assistant/SKILL.md +119 -0
- package/bundled/skills/atdd-assistant/SKILL.md +7 -0
- package/bundled/skills/bdd-assistant/SKILL.md +7 -0
- package/bundled/skills/brainstorm-assistant/SKILL.md +7 -0
- package/bundled/skills/checkin-assistant/SKILL.md +7 -0
- package/bundled/skills/ci-cd-assistant/SKILL.md +97 -0
- package/bundled/skills/code-review-assistant/SKILL.md +7 -0
- package/bundled/skills/commands/README.md +70 -0
- package/bundled/skills/commands/ac-coverage.md +135 -0
- package/bundled/skills/commands/api-design.md +86 -0
- package/bundled/skills/commands/atdd.md +69 -0
- package/bundled/skills/commands/audit.md +69 -0
- package/bundled/skills/commands/bdd.md +101 -0
- package/bundled/skills/commands/brainstorm.md +45 -0
- package/bundled/skills/commands/changelog.md +34 -0
- package/bundled/skills/commands/check.md +52 -1
- package/bundled/skills/commands/checkin.md +46 -0
- package/bundled/skills/commands/ci-cd.md +69 -0
- package/bundled/skills/commands/commit.md +79 -0
- package/bundled/skills/commands/config.md +48 -0
- package/bundled/skills/commands/coverage.md +53 -0
- package/bundled/skills/commands/database.md +70 -0
- package/bundled/skills/commands/derive-all.md +40 -0
- package/bundled/skills/commands/derive-atdd.md +33 -0
- package/bundled/skills/commands/derive-bdd.md +39 -0
- package/bundled/skills/commands/derive-tdd.md +40 -0
- package/bundled/skills/commands/derive.md +47 -0
- package/bundled/skills/commands/dev-workflow.md +104 -7
- package/bundled/skills/commands/discover.md +39 -0
- package/bundled/skills/commands/docgen.md +35 -0
- package/bundled/skills/commands/docs.md +40 -0
- package/bundled/skills/commands/durable.md +79 -0
- package/bundled/skills/commands/incident.md +84 -0
- package/bundled/skills/commands/init.md +55 -0
- package/bundled/skills/commands/methodology.md +72 -0
- package/bundled/skills/commands/metrics.md +65 -0
- package/bundled/skills/commands/migrate.md +84 -0
- package/bundled/skills/commands/pr.md +72 -0
- package/bundled/skills/commands/refactor.md +51 -0
- package/bundled/skills/commands/release.md +60 -0
- package/bundled/skills/commands/requirement.md +38 -0
- package/bundled/skills/commands/reverse-bdd.md +34 -0
- package/bundled/skills/commands/reverse-sdd.md +42 -0
- package/bundled/skills/commands/reverse-tdd.md +40 -0
- package/bundled/skills/commands/reverse.md +41 -0
- package/bundled/skills/commands/review.md +39 -0
- package/bundled/skills/commands/scan.md +68 -0
- package/bundled/skills/commands/sdd-retro.md +48 -0
- package/bundled/skills/commands/sdd.md +220 -0
- package/bundled/skills/commands/security.md +67 -0
- package/bundled/skills/commands/tdd.md +101 -0
- package/bundled/skills/commands/update.md +61 -0
- package/bundled/skills/commit-standards/SKILL.md +8 -2
- package/bundled/skills/database-assistant/SKILL.md +118 -0
- package/bundled/skills/dev-workflow-guide/SKILL.md +53 -7
- package/bundled/skills/dev-workflow-guide/workflow-phases.md +24 -0
- package/bundled/skills/durable-execution-assistant/SKILL.md +116 -0
- package/bundled/skills/forward-derivation/SKILL.md +7 -0
- package/bundled/skills/incident-response-assistant/SKILL.md +132 -0
- package/bundled/skills/methodology-system/SKILL.md +24 -2
- package/bundled/skills/metrics-dashboard-assistant/SKILL.md +109 -0
- package/bundled/skills/migration-assistant/SKILL.md +119 -0
- package/bundled/skills/pr-automation-assistant/SKILL.md +114 -0
- package/bundled/skills/project-discovery/SKILL.md +7 -0
- package/bundled/skills/refactoring-assistant/SKILL.md +7 -0
- package/bundled/skills/release-standards/SKILL.md +7 -0
- package/bundled/skills/requirement-assistant/SKILL.md +7 -0
- package/bundled/skills/reverse-engineer/SKILL.md +7 -0
- package/bundled/skills/security-assistant/SKILL.md +105 -0
- package/bundled/skills/security-scan-assistant/SKILL.md +96 -0
- package/bundled/skills/spec-driven-dev/SKILL.md +84 -4
- package/bundled/skills/spec-driven-dev/guide.md +156 -22
- package/bundled/skills/tdd-assistant/SKILL.md +7 -0
- package/bundled/skills/test-coverage-assistant/SKILL.md +11 -0
- package/bundled/skills/testing-guide/SKILL.md +23 -0
- package/package.json +1 -1
- package/src/commands/check.js +154 -8
- package/src/commands/config.js +231 -104
- package/src/commands/init.js +23 -3
- package/src/commands/update.js +250 -25
- package/src/config/ai-agent-paths.js +16 -0
- package/src/config/workflow-definitions.js +184 -0
- package/src/core/constants.js +6 -0
- package/src/flows/init-flow.js +23 -6
- package/src/i18n/messages.js +51 -3
- package/src/installers/integration-installer.js +67 -2
- package/src/installers/manifest-installer.js +1 -0
- package/src/installers/standards-installer.js +3 -2
- package/src/prompts/init.js +50 -3
- package/src/reconciler/manifest-migrator.js +2 -2
- package/src/reconciler/plan-executor.js +11 -0
- package/src/utils/integration-generator.js +327 -14
- package/src/utils/workflow-gate.js +292 -0
- package/standards-registry.json +160 -5
|
@@ -0,0 +1,946 @@
|
|
|
1
|
+
---
|
|
2
|
+
source: ../../../core/api-design-standards.md
|
|
3
|
+
source_version: 1.0.0
|
|
4
|
+
translation_version: 1.0.0
|
|
5
|
+
last_synced: 2026-03-18
|
|
6
|
+
status: current
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# API 設計標準
|
|
10
|
+
|
|
11
|
+
> **語言**: [English](../../../core/api-design-standards.md) | 繁體中文
|
|
12
|
+
|
|
13
|
+
> 版本: 1.0.0 | 最後更新: 2026-03-18
|
|
14
|
+
|
|
15
|
+
**適用範圍**: 所有軟體專案
|
|
16
|
+
**範疇**: universal
|
|
17
|
+
**業界標準**: OpenAPI 3.x, JSON:API 1.1, Google API Design Guide, RFC 7231 (HTTP 語意)
|
|
18
|
+
**參考資料**: [openapis.org](https://www.openapis.org/), [jsonapi.org](https://jsonapi.org/), [Google API Design Guide](https://cloud.google.com/apis/design), [RFC 7231](https://datatracker.ietf.org/doc/html/rfc7231)
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 目的
|
|
23
|
+
|
|
24
|
+
本標準定義設計、建構與維護 API 的全面性指南。涵蓋 REST、GraphQL 及 gRPC 範式,提供資源命名、版本控制、分頁、錯誤處理、身份驗證與文件撰寫的一致性模式。
|
|
25
|
+
|
|
26
|
+
**參考標準**:
|
|
27
|
+
- [OpenAPI Specification 3.x](https://spec.openapis.org/oas/v3.1.0)
|
|
28
|
+
- [JSON:API 1.1](https://jsonapi.org/format/)
|
|
29
|
+
- [Google API Design Guide](https://cloud.google.com/apis/design)
|
|
30
|
+
- [RFC 7231 — HTTP 語意](https://datatracker.ietf.org/doc/html/rfc7231)
|
|
31
|
+
- [RFC 7807 — HTTP API 問題詳情](https://datatracker.ietf.org/doc/html/rfc7807)
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## REST 設計原則
|
|
36
|
+
|
|
37
|
+
### 資源命名
|
|
38
|
+
|
|
39
|
+
| 規則 | 正確 | 錯誤 |
|
|
40
|
+
|------|------|------|
|
|
41
|
+
| **使用名詞,非動詞** | `/users` | `/getUsers` |
|
|
42
|
+
| **使用複數名詞** | `/articles` | `/article` |
|
|
43
|
+
| **使用 kebab-case** | `/user-profiles` | `/userProfiles`, `/user_profiles` |
|
|
44
|
+
| **使用小寫** | `/orders` | `/Orders` |
|
|
45
|
+
| **巢狀表示關聯** | `/users/123/orders` | `/getUserOrders?userId=123` |
|
|
46
|
+
| **最多 2 層巢狀** | `/users/123/orders` | `/users/123/orders/456/items/789/details` |
|
|
47
|
+
|
|
48
|
+
### HTTP 動詞
|
|
49
|
+
|
|
50
|
+
| 動詞 | 用途 | 請求主體 | 冪等性 | 安全性 |
|
|
51
|
+
|------|------|---------|--------|--------|
|
|
52
|
+
| **GET** | 取得資源 | 無 | 是 | 是 |
|
|
53
|
+
| **POST** | 建立新資源 | 有 | 否 | 否 |
|
|
54
|
+
| **PUT** | 完整取代資源 | 有 | 是 | 否 |
|
|
55
|
+
| **PATCH** | 部分更新資源 | 有 | 否 | 否 |
|
|
56
|
+
| **DELETE** | 移除資源 | 選用 | 是 | 否 |
|
|
57
|
+
| **HEAD** | 與 GET 相同但不含主體 | 無 | 是 | 是 |
|
|
58
|
+
| **OPTIONS** | 描述通訊選項 | 無 | 是 | 是 |
|
|
59
|
+
|
|
60
|
+
### HTTP 狀態碼
|
|
61
|
+
|
|
62
|
+
#### 成功 (2xx)
|
|
63
|
+
|
|
64
|
+
| 代碼 | 意義 | 使用時機 |
|
|
65
|
+
|------|------|---------|
|
|
66
|
+
| **200 OK** | 一般成功 | GET、PUT、PATCH、含主體的 DELETE |
|
|
67
|
+
| **201 Created** | 資源已建立 | POST(包含 `Location` 標頭) |
|
|
68
|
+
| **202 Accepted** | 請求已接受,非同步處理中 | 長時間執行的操作 |
|
|
69
|
+
| **204 No Content** | 成功但無主體 | DELETE、無回應主體的 PUT |
|
|
70
|
+
|
|
71
|
+
#### 用戶端錯誤 (4xx)
|
|
72
|
+
|
|
73
|
+
| 代碼 | 意義 | 使用時機 |
|
|
74
|
+
|------|------|---------|
|
|
75
|
+
| **400 Bad Request** | 格式錯誤的請求 | 無效 JSON、缺少必要欄位 |
|
|
76
|
+
| **401 Unauthorized** | 需要身份驗證 | 無 token、token 過期 |
|
|
77
|
+
| **403 Forbidden** | 權限不足 | 有效 token,角色不符 |
|
|
78
|
+
| **404 Not Found** | 資源不存在 | 無效的資源 ID |
|
|
79
|
+
| **405 Method Not Allowed** | 不支援的 HTTP 方法 | 對唯讀端點使用 POST |
|
|
80
|
+
| **409 Conflict** | 狀態衝突 | 重複建立、版本衝突 |
|
|
81
|
+
| **422 Unprocessable Entity** | 驗證錯誤 | 有效 JSON 但不符商業邏輯 |
|
|
82
|
+
| **429 Too Many Requests** | 超過速率限制 | 包含 `Retry-After` 標頭 |
|
|
83
|
+
|
|
84
|
+
#### 伺服器錯誤 (5xx)
|
|
85
|
+
|
|
86
|
+
| 代碼 | 意義 | 使用時機 |
|
|
87
|
+
|------|------|---------|
|
|
88
|
+
| **500 Internal Server Error** | 非預期伺服器錯誤 | 未處理的例外 |
|
|
89
|
+
| **502 Bad Gateway** | 上游服務錯誤 | 依賴服務故障 |
|
|
90
|
+
| **503 Service Unavailable** | 暫時無法使用 | 維護、過載 |
|
|
91
|
+
| **504 Gateway Timeout** | 上游逾時 | 依賴服務逾時 |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## URL 結構
|
|
96
|
+
|
|
97
|
+
### 基礎 URL 格式
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
https://api.example.com/v1/resources
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
| 組成元素 | 慣例 | 範例 |
|
|
104
|
+
|----------|------|------|
|
|
105
|
+
| **協定** | 必須使用 HTTPS | `https://` |
|
|
106
|
+
| **子網域** | 使用 `api.` 前綴 | `api.example.com` |
|
|
107
|
+
| **版本** | 路徑前綴 | `/v1/` |
|
|
108
|
+
| **資源** | 複數名詞、kebab-case | `/user-profiles` |
|
|
109
|
+
|
|
110
|
+
### 資源階層
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
# 集合
|
|
114
|
+
GET /users
|
|
115
|
+
|
|
116
|
+
# 特定資源
|
|
117
|
+
GET /users/123
|
|
118
|
+
|
|
119
|
+
# 子資源集合(1 層巢狀)
|
|
120
|
+
GET /users/123/orders
|
|
121
|
+
|
|
122
|
+
# 特定子資源(2 層巢狀 — 上限)
|
|
123
|
+
GET /users/123/orders/456
|
|
124
|
+
|
|
125
|
+
# 避免更深層巢狀 — 使用頂層搭配篩選
|
|
126
|
+
GET /order-items?order_id=456
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 資源操作
|
|
130
|
+
|
|
131
|
+
對於非 CRUD 操作,使用子資源動作:
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
# 可接受的動作模式
|
|
135
|
+
POST /users/123/activate
|
|
136
|
+
POST /orders/456/cancel
|
|
137
|
+
POST /reports/generate
|
|
138
|
+
|
|
139
|
+
# 避免動詞式 URL
|
|
140
|
+
POST /activateUser # 錯誤
|
|
141
|
+
POST /cancelOrder # 錯誤
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## API 版本控制策略
|
|
147
|
+
|
|
148
|
+
### 比較矩陣
|
|
149
|
+
|
|
150
|
+
| 策略 | 範例 | 優點 | 缺點 |
|
|
151
|
+
|------|------|------|------|
|
|
152
|
+
| **URL 路徑** | `/v1/users` | 明確、易於路由、可快取 | URL 汙染、較難遷移 |
|
|
153
|
+
| **標頭** | `Accept-Version: v1` | 乾淨的 URL | 隱藏、不易在瀏覽器測試 |
|
|
154
|
+
| **查詢參數** | `/users?v=1` | 易於新增 | 容易忽略、快取問題 |
|
|
155
|
+
| **內容協商** | `Accept: application/vnd.api.v1+json` | 符合標準 | 複雜、難以發現 |
|
|
156
|
+
|
|
157
|
+
### 決策指南
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
是否需要同時支援多個版本?
|
|
161
|
+
├── 是 → URL 路徑版本控制(最明確)
|
|
162
|
+
└── 否 → 是否優先考慮乾淨的 URL?
|
|
163
|
+
├── 是 → 標頭版本控制
|
|
164
|
+
└── 否 → URL 路徑版本控制(較簡單)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 建議方式:URL 路徑版本控制
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
https://api.example.com/v1/users
|
|
171
|
+
https://api.example.com/v2/users
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### 版本生命週期
|
|
175
|
+
|
|
176
|
+
| 階段 | 持續時間 | 動作 |
|
|
177
|
+
|------|----------|------|
|
|
178
|
+
| **現行** | 積極開發中 | 完整支援、新功能 |
|
|
179
|
+
| **支援中** | 後繼版本發布後 6-12 個月 | 僅限錯誤修復、安全修補 |
|
|
180
|
+
| **已棄用** | 3-6 個月通知期 | Sunset 標頭、遷移指南 |
|
|
181
|
+
| **已終止** | 棄用期結束後 | 回傳 410 Gone 與遷移資訊 |
|
|
182
|
+
|
|
183
|
+
### 棄用標頭
|
|
184
|
+
|
|
185
|
+
```http
|
|
186
|
+
Sunset: Sat, 01 Jan 2028 00:00:00 GMT
|
|
187
|
+
Deprecation: true
|
|
188
|
+
Link: <https://api.example.com/v2/docs>; rel="successor-version"
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## 請求/回應標準
|
|
194
|
+
|
|
195
|
+
### 內容標頭
|
|
196
|
+
|
|
197
|
+
```http
|
|
198
|
+
# 請求
|
|
199
|
+
Content-Type: application/json
|
|
200
|
+
Accept: application/json
|
|
201
|
+
|
|
202
|
+
# 回應
|
|
203
|
+
Content-Type: application/json; charset=utf-8
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### JSON 命名慣例
|
|
207
|
+
|
|
208
|
+
| 慣例 | 使用於 | 範例 |
|
|
209
|
+
|------|--------|------|
|
|
210
|
+
| **camelCase** | JSON 屬性 | `firstName`, `createdAt` |
|
|
211
|
+
| **kebab-case** | URL 路徑 | `/user-profiles` |
|
|
212
|
+
| **snake_case** | 查詢參數 | `?sort_by=created_at` |
|
|
213
|
+
|
|
214
|
+
### 標準回應封裝
|
|
215
|
+
|
|
216
|
+
```json
|
|
217
|
+
{
|
|
218
|
+
"data": {
|
|
219
|
+
"id": "123",
|
|
220
|
+
"type": "user",
|
|
221
|
+
"attributes": {
|
|
222
|
+
"firstName": "John",
|
|
223
|
+
"lastName": "Doe",
|
|
224
|
+
"email": "john@example.com",
|
|
225
|
+
"createdAt": "2026-03-18T10:30:00Z"
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
"meta": {
|
|
229
|
+
"requestId": "req-abc-123",
|
|
230
|
+
"timestamp": "2026-03-18T10:30:00Z"
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 集合回應封裝
|
|
236
|
+
|
|
237
|
+
```json
|
|
238
|
+
{
|
|
239
|
+
"data": [
|
|
240
|
+
{ "id": "1", "type": "user", "attributes": { "firstName": "John" } },
|
|
241
|
+
{ "id": "2", "type": "user", "attributes": { "firstName": "Jane" } }
|
|
242
|
+
],
|
|
243
|
+
"meta": {
|
|
244
|
+
"totalCount": 150,
|
|
245
|
+
"page": 1,
|
|
246
|
+
"pageSize": 20,
|
|
247
|
+
"requestId": "req-abc-124"
|
|
248
|
+
},
|
|
249
|
+
"links": {
|
|
250
|
+
"self": "/v1/users?page=1&limit=20",
|
|
251
|
+
"next": "/v1/users?page=2&limit=20",
|
|
252
|
+
"last": "/v1/users?page=8&limit=20"
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 日期/時間格式
|
|
258
|
+
|
|
259
|
+
- 一律使用 **ISO 8601** 格式:`2026-03-18T10:30:00Z`
|
|
260
|
+
- API 回應一律使用 **UTC** 時區
|
|
261
|
+
- 接受含時區的輸入,轉換為 UTC 儲存
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## 分頁
|
|
266
|
+
|
|
267
|
+
### 策略比較
|
|
268
|
+
|
|
269
|
+
| 策略 | 適用場景 | 優點 | 缺點 |
|
|
270
|
+
|------|----------|------|------|
|
|
271
|
+
| **偏移量式** | 簡單列表、有頁碼的 UI | 易於實作、可跳至特定頁 | 資料變動時不一致、大資料集效能差 |
|
|
272
|
+
| **游標式** | 即時動態、大資料集 | 一致性佳、效能好 | 無法跳頁、游標不透明 |
|
|
273
|
+
| **鍵集式** | 已排序的大資料集 | 效能極佳 | 需要穩定排序鍵 |
|
|
274
|
+
|
|
275
|
+
### 偏移量式分頁
|
|
276
|
+
|
|
277
|
+
```
|
|
278
|
+
GET /v1/users?page=2&limit=20
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
```json
|
|
282
|
+
{
|
|
283
|
+
"data": [...],
|
|
284
|
+
"meta": {
|
|
285
|
+
"page": 2,
|
|
286
|
+
"limit": 20,
|
|
287
|
+
"totalCount": 150,
|
|
288
|
+
"totalPages": 8
|
|
289
|
+
},
|
|
290
|
+
"links": {
|
|
291
|
+
"first": "/v1/users?page=1&limit=20",
|
|
292
|
+
"prev": "/v1/users?page=1&limit=20",
|
|
293
|
+
"self": "/v1/users?page=2&limit=20",
|
|
294
|
+
"next": "/v1/users?page=3&limit=20",
|
|
295
|
+
"last": "/v1/users?page=8&limit=20"
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### 游標式分頁
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
GET /v1/events?limit=20&cursor=eyJpZCI6MTAwfQ==
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"data": [...],
|
|
309
|
+
"meta": {
|
|
310
|
+
"limit": 20,
|
|
311
|
+
"hasMore": true
|
|
312
|
+
},
|
|
313
|
+
"links": {
|
|
314
|
+
"self": "/v1/events?limit=20",
|
|
315
|
+
"next": "/v1/events?limit=20&cursor=eyJpZCI6MTIwfQ=="
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 預設值
|
|
321
|
+
|
|
322
|
+
| 參數 | 預設值 | 上限 |
|
|
323
|
+
|------|--------|------|
|
|
324
|
+
| `page` | 1 | - |
|
|
325
|
+
| `limit` / `page_size` | 20 | 100 |
|
|
326
|
+
| `cursor` | null(從頭開始) | - |
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 篩選、排序與欄位選擇
|
|
331
|
+
|
|
332
|
+
### 篩選
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
# 簡單相等
|
|
336
|
+
GET /v1/users?status=active
|
|
337
|
+
|
|
338
|
+
# 括號表示法(推薦用於複雜篩選)
|
|
339
|
+
GET /v1/users?filter[status]=active&filter[role]=admin
|
|
340
|
+
|
|
341
|
+
# 範圍篩選
|
|
342
|
+
GET /v1/orders?filter[created_at][gte]=2026-01-01&filter[created_at][lte]=2026-03-18
|
|
343
|
+
|
|
344
|
+
# 多值(逗號分隔)
|
|
345
|
+
GET /v1/users?filter[role]=admin,editor
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### 排序
|
|
349
|
+
|
|
350
|
+
```
|
|
351
|
+
# 升序(預設)
|
|
352
|
+
GET /v1/users?sort=created_at
|
|
353
|
+
|
|
354
|
+
# 降序(加 - 前綴)
|
|
355
|
+
GET /v1/users?sort=-created_at
|
|
356
|
+
|
|
357
|
+
# 多欄位排序(逗號分隔)
|
|
358
|
+
GET /v1/users?sort=-created_at,last_name
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
### 欄位選擇(稀疏欄位集)
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
# 選擇特定欄位
|
|
365
|
+
GET /v1/users?fields=id,first_name,email
|
|
366
|
+
|
|
367
|
+
# 依資源類型選擇欄位(JSON:API 風格)
|
|
368
|
+
GET /v1/articles?fields[article]=title,body&fields[author]=name
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### 搜尋
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
# 全文搜尋
|
|
375
|
+
GET /v1/users?q=john+doe
|
|
376
|
+
|
|
377
|
+
# 範圍搜尋
|
|
378
|
+
GET /v1/users?search[name]=john&search[email]=example.com
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 身份驗證模式
|
|
384
|
+
|
|
385
|
+
### 決策矩陣
|
|
386
|
+
|
|
387
|
+
| 方法 | 適用場景 | 複雜度 | 安全等級 |
|
|
388
|
+
|------|----------|--------|----------|
|
|
389
|
+
| **API Key** | 伺服器對伺服器、內部 API | 低 | 中 |
|
|
390
|
+
| **OAuth 2.0** | 第三方存取、使用者授權委派 | 高 | 高 |
|
|
391
|
+
| **JWT Bearer** | 無狀態驗證、微服務 | 中 | 高 |
|
|
392
|
+
| **mTLS** | 服務網格、零信任 | 高 | 極高 |
|
|
393
|
+
|
|
394
|
+
### API Key
|
|
395
|
+
|
|
396
|
+
```http
|
|
397
|
+
# 標頭(建議方式)
|
|
398
|
+
Authorization: ApiKey sk_live_abc123def456
|
|
399
|
+
|
|
400
|
+
# 查詢參數(避免使用 — 會記錄在伺服器日誌中)
|
|
401
|
+
GET /v1/users?api_key=sk_live_abc123def456
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### OAuth 2.0 流程
|
|
405
|
+
|
|
406
|
+
| 流程 | 適用場景 | 用戶端類型 |
|
|
407
|
+
|------|----------|-----------|
|
|
408
|
+
| **Authorization Code + PKCE** | 網頁應用、行動應用 | 公開 |
|
|
409
|
+
| **Client Credentials** | 機器對機器 | 機密 |
|
|
410
|
+
| **Device Code** | IoT、CLI 工具 | 公開(受限輸入) |
|
|
411
|
+
| **Refresh Token** | 長期有效的工作階段 | 任何 |
|
|
412
|
+
|
|
413
|
+
### JWT Bearer Token
|
|
414
|
+
|
|
415
|
+
```http
|
|
416
|
+
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**JWT 最佳實踐:**
|
|
420
|
+
|
|
421
|
+
| 規則 | 要求 |
|
|
422
|
+
|------|------|
|
|
423
|
+
| **演算法** | RS256 或 ES256(非對稱) |
|
|
424
|
+
| **Access token TTL** | 最多 15 分鐘 |
|
|
425
|
+
| **Refresh token TTL** | 7-30 天 |
|
|
426
|
+
| **Payload** | 絕不包含敏感資料(密碼、PII) |
|
|
427
|
+
| **驗證** | 一律驗證簽名、發行者、受眾、到期時間 |
|
|
428
|
+
| **撤銷** | 維護 token 黑名單或使用短期 token |
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## 速率限制
|
|
433
|
+
|
|
434
|
+
### 標準標頭
|
|
435
|
+
|
|
436
|
+
```http
|
|
437
|
+
X-RateLimit-Limit: 1000
|
|
438
|
+
X-RateLimit-Remaining: 994
|
|
439
|
+
X-RateLimit-Reset: 1711036800
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
| 標頭 | 說明 |
|
|
443
|
+
|------|------|
|
|
444
|
+
| `X-RateLimit-Limit` | 視窗內允許的最大請求數 |
|
|
445
|
+
| `X-RateLimit-Remaining` | 目前視窗內剩餘的請求數 |
|
|
446
|
+
| `X-RateLimit-Reset` | 視窗重設的 Unix 時間戳 |
|
|
447
|
+
| `Retry-After` | 重試前等待的秒數(用於 429) |
|
|
448
|
+
|
|
449
|
+
### 速率限制層級
|
|
450
|
+
|
|
451
|
+
| 層級 | 限制 | 視窗 | 適用場景 |
|
|
452
|
+
|------|------|------|----------|
|
|
453
|
+
| **免費** | 100 請求 | 1 小時 | 公開/匿名 |
|
|
454
|
+
| **基本** | 1,000 請求 | 1 小時 | 已驗證使用者 |
|
|
455
|
+
| **專業** | 10,000 請求 | 1 小時 | 付費客戶 |
|
|
456
|
+
| **企業** | 自訂 | 自訂 | 協商的 SLA |
|
|
457
|
+
|
|
458
|
+
### 429 回應
|
|
459
|
+
|
|
460
|
+
```json
|
|
461
|
+
{
|
|
462
|
+
"type": "https://api.example.com/errors/rate-limit-exceeded",
|
|
463
|
+
"title": "Rate Limit Exceeded",
|
|
464
|
+
"status": 429,
|
|
465
|
+
"detail": "You have exceeded the rate limit of 1000 requests per hour.",
|
|
466
|
+
"instance": "/v1/users",
|
|
467
|
+
"retryAfter": 3600
|
|
468
|
+
}
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
### 速率限制策略
|
|
472
|
+
|
|
473
|
+
| 策略 | 說明 | 適用場景 |
|
|
474
|
+
|------|------|----------|
|
|
475
|
+
| **固定視窗** | 在固定時間段內計算請求數 | 簡單實作 |
|
|
476
|
+
| **滑動視窗** | 滾動式時間視窗 | 更精確的限制 |
|
|
477
|
+
| **令牌桶** | 以穩定速率補充令牌 | 允許突發流量 |
|
|
478
|
+
| **漏桶** | 以固定速率處理請求 | 平滑流量 |
|
|
479
|
+
|
|
480
|
+
---
|
|
481
|
+
|
|
482
|
+
## 錯誤回應格式
|
|
483
|
+
|
|
484
|
+
### RFC 7807 問題詳情
|
|
485
|
+
|
|
486
|
+
所有錯誤回應必須遵循 [RFC 7807](https://datatracker.ietf.org/doc/html/rfc7807) Problem Details 格式:
|
|
487
|
+
|
|
488
|
+
```json
|
|
489
|
+
{
|
|
490
|
+
"type": "https://api.example.com/errors/validation-error",
|
|
491
|
+
"title": "Validation Error",
|
|
492
|
+
"status": 422,
|
|
493
|
+
"detail": "The request body contains invalid fields.",
|
|
494
|
+
"instance": "/v1/users",
|
|
495
|
+
"errors": [
|
|
496
|
+
{
|
|
497
|
+
"field": "email",
|
|
498
|
+
"code": "INVALID_FORMAT",
|
|
499
|
+
"message": "Must be a valid email address."
|
|
500
|
+
},
|
|
501
|
+
{
|
|
502
|
+
"field": "age",
|
|
503
|
+
"code": "OUT_OF_RANGE",
|
|
504
|
+
"message": "Must be between 0 and 150."
|
|
505
|
+
}
|
|
506
|
+
],
|
|
507
|
+
"traceId": "req-abc-123"
|
|
508
|
+
}
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
### 必要欄位
|
|
512
|
+
|
|
513
|
+
| 欄位 | 類型 | 說明 |
|
|
514
|
+
|------|------|------|
|
|
515
|
+
| `type` | URI | 錯誤文件的參考連結 |
|
|
516
|
+
| `title` | string | 簡短、人類可讀的摘要 |
|
|
517
|
+
| `status` | integer | HTTP 狀態碼 |
|
|
518
|
+
| `detail` | string | 針對此特定情況的人類可讀說明 |
|
|
519
|
+
|
|
520
|
+
### 選用欄位
|
|
521
|
+
|
|
522
|
+
| 欄位 | 類型 | 說明 |
|
|
523
|
+
|------|------|------|
|
|
524
|
+
| `instance` | URI | 造成錯誤的請求 URI |
|
|
525
|
+
| `errors` | array | 欄位層級的驗證錯誤 |
|
|
526
|
+
| `traceId` | string | 用於除錯的請求追蹤識別碼 |
|
|
527
|
+
|
|
528
|
+
### 常見錯誤類型
|
|
529
|
+
|
|
530
|
+
```json
|
|
531
|
+
// 身份驗證錯誤 (401)
|
|
532
|
+
{
|
|
533
|
+
"type": "https://api.example.com/errors/authentication-required",
|
|
534
|
+
"title": "Authentication Required",
|
|
535
|
+
"status": 401,
|
|
536
|
+
"detail": "A valid access token is required to access this resource."
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// 授權錯誤 (403)
|
|
540
|
+
{
|
|
541
|
+
"type": "https://api.example.com/errors/insufficient-permissions",
|
|
542
|
+
"title": "Insufficient Permissions",
|
|
543
|
+
"status": 403,
|
|
544
|
+
"detail": "You do not have permission to delete this resource."
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// 找不到資源 (404)
|
|
548
|
+
{
|
|
549
|
+
"type": "https://api.example.com/errors/resource-not-found",
|
|
550
|
+
"title": "Resource Not Found",
|
|
551
|
+
"status": 404,
|
|
552
|
+
"detail": "User with ID '999' does not exist."
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
---
|
|
557
|
+
|
|
558
|
+
## GraphQL 設計原則
|
|
559
|
+
|
|
560
|
+
### Schema 設計
|
|
561
|
+
|
|
562
|
+
```graphql
|
|
563
|
+
# 類型使用 PascalCase
|
|
564
|
+
type User {
|
|
565
|
+
id: ID!
|
|
566
|
+
firstName: String!
|
|
567
|
+
lastName: String!
|
|
568
|
+
email: String!
|
|
569
|
+
createdAt: DateTime!
|
|
570
|
+
orders(first: Int, after: String): OrderConnection!
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
# 使用描述性的 input 類型
|
|
574
|
+
input CreateUserInput {
|
|
575
|
+
firstName: String!
|
|
576
|
+
lastName: String!
|
|
577
|
+
email: String!
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
# mutation 使用動詞前綴
|
|
581
|
+
type Mutation {
|
|
582
|
+
createUser(input: CreateUserInput!): CreateUserPayload!
|
|
583
|
+
updateUser(id: ID!, input: UpdateUserInput!): UpdateUserPayload!
|
|
584
|
+
deleteUser(id: ID!): DeleteUserPayload!
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
# Payload 類型含 userErrors
|
|
588
|
+
type CreateUserPayload {
|
|
589
|
+
user: User
|
|
590
|
+
userErrors: [UserError!]!
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
type UserError {
|
|
594
|
+
field: [String!]
|
|
595
|
+
message: String!
|
|
596
|
+
code: UserErrorCode!
|
|
597
|
+
}
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
### 命名慣例
|
|
601
|
+
|
|
602
|
+
| 元素 | 慣例 | 範例 |
|
|
603
|
+
|------|------|------|
|
|
604
|
+
| **類型** | PascalCase | `UserProfile` |
|
|
605
|
+
| **欄位** | camelCase | `firstName` |
|
|
606
|
+
| **列舉** | SCREAMING_SNAKE_CASE | `ORDER_STATUS` |
|
|
607
|
+
| **列舉值** | SCREAMING_SNAKE_CASE | `IN_PROGRESS` |
|
|
608
|
+
| **Mutation** | 動詞 + 名詞 | `createUser`, `updateOrder` |
|
|
609
|
+
| **Query** | 名詞或名詞片語 | `user`, `allUsers` |
|
|
610
|
+
| **Input 類型** | 動作 + 名詞 + `Input` | `CreateUserInput` |
|
|
611
|
+
| **Payload 類型** | 動作 + 名詞 + `Payload` | `CreateUserPayload` |
|
|
612
|
+
|
|
613
|
+
### Relay 風格分頁(Connections)
|
|
614
|
+
|
|
615
|
+
```graphql
|
|
616
|
+
type Query {
|
|
617
|
+
users(first: Int, after: String, last: Int, before: String): UserConnection!
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
type UserConnection {
|
|
621
|
+
edges: [UserEdge!]!
|
|
622
|
+
pageInfo: PageInfo!
|
|
623
|
+
totalCount: Int!
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
type UserEdge {
|
|
627
|
+
node: User!
|
|
628
|
+
cursor: String!
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
type PageInfo {
|
|
632
|
+
hasNextPage: Boolean!
|
|
633
|
+
hasPreviousPage: Boolean!
|
|
634
|
+
startCursor: String
|
|
635
|
+
endCursor: String
|
|
636
|
+
}
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### 錯誤處理
|
|
640
|
+
|
|
641
|
+
```json
|
|
642
|
+
{
|
|
643
|
+
"data": {
|
|
644
|
+
"createUser": {
|
|
645
|
+
"user": null,
|
|
646
|
+
"userErrors": [
|
|
647
|
+
{
|
|
648
|
+
"field": ["input", "email"],
|
|
649
|
+
"message": "Email is already in use.",
|
|
650
|
+
"code": "TAKEN"
|
|
651
|
+
}
|
|
652
|
+
]
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
---
|
|
659
|
+
|
|
660
|
+
## gRPC 服務設計
|
|
661
|
+
|
|
662
|
+
### Proto 檔案慣例
|
|
663
|
+
|
|
664
|
+
```protobuf
|
|
665
|
+
syntax = "proto3";
|
|
666
|
+
|
|
667
|
+
package example.user.v1;
|
|
668
|
+
|
|
669
|
+
option go_package = "example.com/api/user/v1;userv1";
|
|
670
|
+
option java_package = "com.example.api.user.v1";
|
|
671
|
+
|
|
672
|
+
// UserService 管理使用者帳號。
|
|
673
|
+
service UserService {
|
|
674
|
+
// GetUser 依 ID 回傳單一使用者。
|
|
675
|
+
rpc GetUser(GetUserRequest) returns (GetUserResponse);
|
|
676
|
+
|
|
677
|
+
// ListUsers 回傳分頁的使用者清單。
|
|
678
|
+
rpc ListUsers(ListUsersRequest) returns (ListUsersResponse);
|
|
679
|
+
|
|
680
|
+
// CreateUser 建立新的使用者帳號。
|
|
681
|
+
rpc CreateUser(CreateUserRequest) returns (CreateUserResponse);
|
|
682
|
+
|
|
683
|
+
// UpdateUser 更新現有使用者。
|
|
684
|
+
rpc UpdateUser(UpdateUserRequest) returns (UpdateUserResponse);
|
|
685
|
+
|
|
686
|
+
// DeleteUser 移除使用者帳號。
|
|
687
|
+
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty);
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
message GetUserRequest {
|
|
691
|
+
string user_id = 1;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
message GetUserResponse {
|
|
695
|
+
User user = 1;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
message ListUsersRequest {
|
|
699
|
+
int32 page_size = 1;
|
|
700
|
+
string page_token = 2;
|
|
701
|
+
string filter = 3;
|
|
702
|
+
string order_by = 4;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
message ListUsersResponse {
|
|
706
|
+
repeated User users = 1;
|
|
707
|
+
string next_page_token = 2;
|
|
708
|
+
int32 total_size = 3;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
message User {
|
|
712
|
+
string user_id = 1;
|
|
713
|
+
string first_name = 2;
|
|
714
|
+
string last_name = 3;
|
|
715
|
+
string email = 4;
|
|
716
|
+
google.protobuf.Timestamp created_at = 5;
|
|
717
|
+
}
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### 命名慣例
|
|
721
|
+
|
|
722
|
+
| 元素 | 慣例 | 範例 |
|
|
723
|
+
|------|------|------|
|
|
724
|
+
| **套件** | `company.service.version` | `example.user.v1` |
|
|
725
|
+
| **服務** | PascalCase + `Service` | `UserService` |
|
|
726
|
+
| **RPC 方法** | PascalCase 動詞 + 名詞 | `GetUser`, `ListUsers` |
|
|
727
|
+
| **訊息** | PascalCase | `GetUserRequest` |
|
|
728
|
+
| **欄位** | snake_case | `user_id`, `first_name` |
|
|
729
|
+
| **列舉** | PascalCase 類型、UPPER 值 | `Status`, `ACTIVE` |
|
|
730
|
+
|
|
731
|
+
### gRPC 錯誤碼對應
|
|
732
|
+
|
|
733
|
+
| gRPC 代碼 | HTTP 對應 | 說明 |
|
|
734
|
+
|-----------|----------|------|
|
|
735
|
+
| `OK` | 200 | 成功 |
|
|
736
|
+
| `INVALID_ARGUMENT` | 400 | 用戶端指定了無效的引數 |
|
|
737
|
+
| `UNAUTHENTICATED` | 401 | 缺少或無效的身份驗證 |
|
|
738
|
+
| `PERMISSION_DENIED` | 403 | 權限不足 |
|
|
739
|
+
| `NOT_FOUND` | 404 | 資源不存在 |
|
|
740
|
+
| `ALREADY_EXISTS` | 409 | 資源已存在 |
|
|
741
|
+
| `FAILED_PRECONDITION` | 412 | 因系統狀態而拒絕操作 |
|
|
742
|
+
| `RESOURCE_EXHAUSTED` | 429 | 速率限制或配額超出 |
|
|
743
|
+
| `INTERNAL` | 500 | 內部伺服器錯誤 |
|
|
744
|
+
| `UNAVAILABLE` | 503 | 服務不可用 |
|
|
745
|
+
| `DEADLINE_EXCEEDED` | 504 | 操作逾時 |
|
|
746
|
+
|
|
747
|
+
---
|
|
748
|
+
|
|
749
|
+
## API 文件要求
|
|
750
|
+
|
|
751
|
+
### OpenAPI 規格要求
|
|
752
|
+
|
|
753
|
+
每個 REST API 必須具備 OpenAPI 3.x 規格,包含:
|
|
754
|
+
|
|
755
|
+
| 區段 | 必要 | 說明 |
|
|
756
|
+
|------|------|------|
|
|
757
|
+
| `info` | 是 | 標題、版本、描述、聯絡方式 |
|
|
758
|
+
| `servers` | 是 | 所有環境的基礎 URL |
|
|
759
|
+
| `paths` | 是 | 所有端點及其操作 |
|
|
760
|
+
| `components/schemas` | 是 | 所有請求/回應 schema |
|
|
761
|
+
| `components/securitySchemes` | 是 | 身份驗證方法 |
|
|
762
|
+
| `security` | 是 | 預設安全需求 |
|
|
763
|
+
| `tags` | 建議 | 端點的邏輯分組 |
|
|
764
|
+
|
|
765
|
+
### 文件檢查清單
|
|
766
|
+
|
|
767
|
+
- [ ] 每個端點都有摘要與描述
|
|
768
|
+
- [ ] 所有參數都記載了類型、範例和限制條件
|
|
769
|
+
- [ ] POST/PUT/PATCH 提供請求主體範例
|
|
770
|
+
- [ ] 記載所有可能的回應代碼與範例
|
|
771
|
+
- [ ] 指定每個端點的身份驗證需求
|
|
772
|
+
- [ ] 記載速率限制
|
|
773
|
+
- [ ] 記載分頁參數
|
|
774
|
+
- [ ] 記載錯誤回應格式與範例
|
|
775
|
+
|
|
776
|
+
### OpenAPI 範例
|
|
777
|
+
|
|
778
|
+
```yaml
|
|
779
|
+
openapi: 3.1.0
|
|
780
|
+
info:
|
|
781
|
+
title: User Management API
|
|
782
|
+
version: 1.0.0
|
|
783
|
+
description: API for managing user accounts
|
|
784
|
+
contact:
|
|
785
|
+
email: api-support@example.com
|
|
786
|
+
|
|
787
|
+
servers:
|
|
788
|
+
- url: https://api.example.com/v1
|
|
789
|
+
description: Production
|
|
790
|
+
- url: https://api.staging.example.com/v1
|
|
791
|
+
description: Staging
|
|
792
|
+
|
|
793
|
+
paths:
|
|
794
|
+
/users:
|
|
795
|
+
get:
|
|
796
|
+
summary: List all users
|
|
797
|
+
operationId: listUsers
|
|
798
|
+
tags: [Users]
|
|
799
|
+
parameters:
|
|
800
|
+
- name: page
|
|
801
|
+
in: query
|
|
802
|
+
schema:
|
|
803
|
+
type: integer
|
|
804
|
+
default: 1
|
|
805
|
+
- name: limit
|
|
806
|
+
in: query
|
|
807
|
+
schema:
|
|
808
|
+
type: integer
|
|
809
|
+
default: 20
|
|
810
|
+
maximum: 100
|
|
811
|
+
responses:
|
|
812
|
+
'200':
|
|
813
|
+
description: Successfully retrieved users
|
|
814
|
+
content:
|
|
815
|
+
application/json:
|
|
816
|
+
schema:
|
|
817
|
+
$ref: '#/components/schemas/UserListResponse'
|
|
818
|
+
'401':
|
|
819
|
+
$ref: '#/components/responses/Unauthorized'
|
|
820
|
+
'429':
|
|
821
|
+
$ref: '#/components/responses/RateLimited'
|
|
822
|
+
```
|
|
823
|
+
|
|
824
|
+
---
|
|
825
|
+
|
|
826
|
+
## 安全考量
|
|
827
|
+
|
|
828
|
+
### 傳輸安全
|
|
829
|
+
|
|
830
|
+
| 要求 | 標準 |
|
|
831
|
+
|------|------|
|
|
832
|
+
| **HTTPS** | 所有 API 端點皆為必要 |
|
|
833
|
+
| **TLS 版本** | TLS 1.2 最低要求,TLS 1.3 建議 |
|
|
834
|
+
| **HSTS** | 包含 `Strict-Transport-Security` 標頭 |
|
|
835
|
+
| **憑證** | 有效的憑證,生產環境不使用自簽憑證 |
|
|
836
|
+
|
|
837
|
+
### CORS 設定
|
|
838
|
+
|
|
839
|
+
```http
|
|
840
|
+
Access-Control-Allow-Origin: https://app.example.com
|
|
841
|
+
Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
|
|
842
|
+
Access-Control-Allow-Headers: Content-Type, Authorization, X-Request-ID
|
|
843
|
+
Access-Control-Max-Age: 86400
|
|
844
|
+
Access-Control-Allow-Credentials: true
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
| 規則 | 要求 |
|
|
848
|
+
|------|------|
|
|
849
|
+
| **不使用萬用字元(`*`)搭配 credentials** | 指定確切的來源 |
|
|
850
|
+
| **限制方法** | 僅允許需要的 HTTP 方法 |
|
|
851
|
+
| **限制標頭** | 僅允許需要的自訂標頭 |
|
|
852
|
+
| **預檢快取** | 設定 `Max-Age` 以減少 OPTIONS 請求 |
|
|
853
|
+
|
|
854
|
+
### 輸入驗證
|
|
855
|
+
|
|
856
|
+
| 規則 | 實作方式 |
|
|
857
|
+
|------|----------|
|
|
858
|
+
| **驗證所有輸入** | 伺服器端驗證所有參數 |
|
|
859
|
+
| **使用允許清單** | 根據已知的正確模式驗證 |
|
|
860
|
+
| **限制請求大小** | 設定 `Content-Length` 限制(例如 1 MB) |
|
|
861
|
+
| **消毒輸出** | 防止回應中的注入攻擊 |
|
|
862
|
+
| **參數化查詢** | 絕不將使用者輸入串接到查詢中 |
|
|
863
|
+
|
|
864
|
+
### API 安全標頭
|
|
865
|
+
|
|
866
|
+
```http
|
|
867
|
+
X-Content-Type-Options: nosniff
|
|
868
|
+
X-Frame-Options: DENY
|
|
869
|
+
Cache-Control: no-store
|
|
870
|
+
Content-Security-Policy: default-src 'none'
|
|
871
|
+
```
|
|
872
|
+
|
|
873
|
+
---
|
|
874
|
+
|
|
875
|
+
## 快速參考卡
|
|
876
|
+
|
|
877
|
+
### URL 模式
|
|
878
|
+
|
|
879
|
+
```
|
|
880
|
+
[VERB] https://api.{domain}/v{N}/{resources}/{id}/{sub-resources}/{id}
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
### 回應結構
|
|
884
|
+
|
|
885
|
+
```
|
|
886
|
+
成功 → { data, meta, links }
|
|
887
|
+
錯誤 → { type, title, status, detail, errors, traceId }
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
### 必要標頭
|
|
891
|
+
|
|
892
|
+
| 方向 | 標頭 | 值 |
|
|
893
|
+
|------|------|-----|
|
|
894
|
+
| 請求 | `Content-Type` | `application/json` |
|
|
895
|
+
| 請求 | `Accept` | `application/json` |
|
|
896
|
+
| 請求 | `Authorization` | `Bearer {token}` |
|
|
897
|
+
| 回應 | `X-RateLimit-Limit` | `1000` |
|
|
898
|
+
| 回應 | `X-RateLimit-Remaining` | `994` |
|
|
899
|
+
| 回應 | `X-Request-ID` | `req-abc-123` |
|
|
900
|
+
|
|
901
|
+
### HTTP 動詞速查表
|
|
902
|
+
|
|
903
|
+
| 動作 | 動詞 | URL | 狀態碼 |
|
|
904
|
+
|------|------|-----|--------|
|
|
905
|
+
| 列表 | GET | `/users` | 200 |
|
|
906
|
+
| 讀取 | GET | `/users/123` | 200 |
|
|
907
|
+
| 建立 | POST | `/users` | 201 |
|
|
908
|
+
| 完整更新 | PUT | `/users/123` | 200 |
|
|
909
|
+
| 部分更新 | PATCH | `/users/123` | 200 |
|
|
910
|
+
| 刪除 | DELETE | `/users/123` | 204 |
|
|
911
|
+
|
|
912
|
+
---
|
|
913
|
+
|
|
914
|
+
## 相關標準
|
|
915
|
+
|
|
916
|
+
- [錯誤碼標準](error-code-standards.md) - 錯誤碼慣例與目錄
|
|
917
|
+
- [安全標準](security-standards.md) - 身份驗證、授權與安全實踐
|
|
918
|
+
- [日誌標準](logging-standards.md) - API 請求/回應日誌
|
|
919
|
+
- [測試標準](testing-standards.md) - API 測試策略
|
|
920
|
+
- [文件撰寫標準](documentation-writing-standards.md) - 撰寫 API 文件
|
|
921
|
+
|
|
922
|
+
---
|
|
923
|
+
|
|
924
|
+
## 版本歷史
|
|
925
|
+
|
|
926
|
+
| 版本 | 日期 | 變更 |
|
|
927
|
+
|------|------|------|
|
|
928
|
+
| 1.0.0 | 2026-03-18 | 初始版本 |
|
|
929
|
+
|
|
930
|
+
---
|
|
931
|
+
|
|
932
|
+
## 參考資料
|
|
933
|
+
|
|
934
|
+
- [OpenAPI Specification](https://www.openapis.org/)
|
|
935
|
+
- [JSON:API Specification](https://jsonapi.org/)
|
|
936
|
+
- [Google API Design Guide](https://cloud.google.com/apis/design)
|
|
937
|
+
- [RFC 7231 — HTTP/1.1 Semantics and Content](https://datatracker.ietf.org/doc/html/rfc7231)
|
|
938
|
+
- [RFC 7807 — Problem Details for HTTP APIs](https://datatracker.ietf.org/doc/html/rfc7807)
|
|
939
|
+
- [Microsoft REST API Guidelines](https://github.com/microsoft/api-guidelines)
|
|
940
|
+
- [Zalando RESTful API Guidelines](https://opensource.zalando.com/restful-api-guidelines/)
|
|
941
|
+
|
|
942
|
+
---
|
|
943
|
+
|
|
944
|
+
## 授權
|
|
945
|
+
|
|
946
|
+
本標準以 [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) 授權發布。
|