cc-codeconductor 0.4.3 → 1.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/README.md +95 -95
- package/dist/cli/errors.d.ts +65 -0
- package/dist/core/compilation/compile-checker.d.ts +51 -0
- package/dist/core/config/codeconductor-config.d.ts +42 -0
- package/dist/core/config/config-loader.d.ts +11 -0
- package/dist/core/filesystem/credential-guard.d.ts +18 -0
- package/dist/core/goal/goal-planner.d.ts +8 -0
- package/dist/core/goal/goal-state.d.ts +15 -0
- package/dist/core/loop/git-stats.d.ts +13 -0
- package/dist/core/loop/loop-engine.d.ts +79 -0
- package/dist/core/memory/episodic-store.d.ts +6 -0
- package/dist/core/memory/operational-state.d.ts +6 -0
- package/dist/core/orchestrator/runtime-orchestrator.d.ts +25 -0
- package/dist/core/planner/product-planner.d.ts +18 -0
- package/dist/core/presets/package-paths.d.ts +4 -0
- package/dist/core/product-graph/graph-store.d.ts +11 -0
- package/dist/core/product-graph/paths.d.ts +18 -0
- package/dist/core/verification/verification-runner.d.ts +57 -0
- package/dist/domain/loop/loop-state.d.ts +74 -0
- package/dist/domain/product/entities.d.ts +11 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +23721 -15064
- package/dist/library.js +2595 -0
- package/dist/utils/result.d.ts +36 -0
- package/dist/validation/schemas.d.ts +3660 -0
- package/package.json +15 -2
- package/policy.yml +12 -11
- package/presets/agy/AGENTS.md +11 -5
- package/presets/agy/gates/pre-commit/GATE.md +136 -0
- package/presets/agy/skills/cc-fix/SKILL.md +2 -2
- package/presets/agy/skills/cc-tdd-cycle/SKILL.md +11 -0
- package/presets/agy/skills/evaluation/SKILL.md +6 -0
- package/presets/agy/skills/openspec/SKILL.md +32 -0
- package/presets/agy/workflows/cc-api-contract.md +12 -0
- package/presets/agy/workflows/cc-ask.md +55 -0
- package/presets/agy/workflows/cc-clarify.md +33 -0
- package/presets/agy/workflows/cc-council.md +31 -7
- package/presets/agy/workflows/cc-db-migration.md +22 -9
- package/presets/agy/workflows/cc-explore.md +37 -0
- package/presets/agy/workflows/cc-feature.md +41 -19
- package/presets/agy/workflows/cc-fix.md +50 -23
- package/presets/agy/workflows/cc-handoff.md +42 -0
- package/presets/agy/workflows/cc-iterative.md +128 -0
- package/presets/agy/workflows/cc-openspec.md +75 -0
- package/presets/agy/workflows/cc-pagespeed.md +12 -0
- package/presets/agy/workflows/cc-prototype.md +39 -0
- package/presets/agy/workflows/cc-refactor.md +12 -0
- package/presets/agy/workflows/cc-review.md +12 -0
- package/presets/agy/workflows/cc-scorecard.md +29 -0
- package/presets/agy/workflows/cc-tdd-cycle.md +24 -0
- package/presets/agy/workflows/cc-test-plan.md +12 -0
- package/presets/agy/workflows/cc-triage.md +35 -0
- package/presets/claude/CLAUDE.md +64 -0
- package/presets/claude/commands/cc/api-contract.md +12 -0
- package/presets/claude/commands/cc/ask.md +55 -0
- package/presets/claude/commands/cc/clarify.md +32 -0
- package/presets/claude/commands/cc/council.md +87 -0
- package/presets/claude/commands/cc/db-migration.md +22 -9
- package/presets/claude/commands/cc/explore.md +36 -0
- package/presets/claude/commands/cc/feature.md +49 -22
- package/presets/claude/commands/cc/fix.md +74 -20
- package/presets/claude/commands/cc/handoff.md +44 -0
- package/presets/claude/commands/cc/iterative.md +132 -0
- package/presets/claude/commands/cc/openspec.md +169 -0
- package/presets/claude/commands/cc/pagespeed.md +12 -0
- package/presets/claude/commands/cc/prototype.md +38 -0
- package/presets/claude/commands/cc/refactor.md +152 -1
- package/presets/claude/commands/cc/review.md +90 -17
- package/presets/claude/commands/cc/scorecard.md +77 -0
- package/presets/claude/commands/cc/tdd-cycle.md +53 -3
- package/presets/claude/commands/cc/test-plan.md +12 -0
- package/presets/claude/commands/cc/triage.md +34 -0
- package/presets/claude/gates/pre-commit/GATE.md +136 -0
- package/presets/claude/settings.json +8 -46
- package/presets/claude/skills/evaluation/SKILL.md +42 -0
- package/presets/claude/skills/openspec/SKILL.md +54 -0
- package/presets/codex/AGENTS.md +62 -5
- package/presets/codex/commands/cc-ask.md +55 -0
- package/presets/codex/gates/pre-commit/GATE.md +136 -0
- package/presets/cursor/.cursorignore +15 -0
- package/presets/cursor/AGENTS.md +504 -0
- package/presets/cursor/agents/architect.md +211 -0
- package/presets/cursor/agents/business-agent.md +44 -0
- package/presets/cursor/agents/complexity-auditor.md +76 -0
- package/presets/cursor/agents/continuous-architect.md +37 -0
- package/presets/cursor/agents/contract-builder.md +75 -0
- package/presets/cursor/agents/docs.md +181 -0
- package/presets/cursor/agents/goal-planner.md +71 -0
- package/presets/cursor/agents/impact-analyst.md +43 -0
- package/presets/cursor/agents/implementer.md +161 -0
- package/presets/cursor/agents/orchestrator.md +377 -0
- package/presets/cursor/agents/repo-explorer.md +100 -0
- package/presets/cursor/agents/reviewer.md +237 -0
- package/presets/cursor/agents/security-reviewer.md +113 -0
- package/presets/cursor/agents/task-coach.md +145 -0
- package/presets/cursor/agents/tester.md +241 -0
- package/presets/cursor/commands/cc/api-contract.md +70 -0
- package/presets/cursor/commands/cc/ask.md +55 -0
- package/presets/cursor/commands/cc/clarify.md +32 -0
- package/presets/cursor/commands/cc/council.md +87 -0
- package/presets/cursor/commands/cc/db-migration.md +71 -0
- package/presets/cursor/commands/cc/explore.md +36 -0
- package/presets/cursor/commands/cc/feature.md +137 -0
- package/presets/cursor/commands/cc/fix.md +148 -0
- package/presets/cursor/commands/cc/handoff.md +41 -0
- package/presets/cursor/commands/cc/iterative.md +133 -0
- package/presets/cursor/commands/cc/openspec.md +159 -0
- package/presets/cursor/commands/cc/pagespeed.md +115 -0
- package/presets/cursor/commands/cc/prototype.md +38 -0
- package/presets/cursor/commands/cc/refactor.md +160 -0
- package/presets/cursor/commands/cc/review.md +149 -0
- package/presets/cursor/commands/cc/scorecard.md +77 -0
- package/presets/cursor/commands/cc/tdd-cycle.md +250 -0
- package/presets/cursor/commands/cc/test-plan.md +150 -0
- package/presets/cursor/commands/cc/triage.md +34 -0
- package/presets/cursor/gates/pre-commit/GATE.md +136 -0
- package/presets/cursor/rules/behavioral-discipline.mdc +14 -0
- package/presets/cursor/rules/context-budget.mdc +12 -0
- package/presets/cursor/rules/orchestration.mdc +12 -0
- package/presets/cursor/rules/yagni-stdlib.mdc +11 -0
- package/presets/cursor/skills/android/SKILL.md +122 -0
- package/presets/cursor/skills/api-versioning/SKILL.md +394 -0
- package/presets/cursor/skills/astro/SKILL.md +322 -0
- package/presets/cursor/skills/auth-token-inspector/SKILL.md +33 -0
- package/presets/cursor/skills/code-review/SKILL.md +208 -0
- package/presets/cursor/skills/conductor-setup/SKILL.md +127 -0
- package/presets/cursor/skills/django-orm/SKILL.md +463 -0
- package/presets/cursor/skills/django-testing/SKILL.md +417 -0
- package/presets/cursor/skills/django-uv/SKILL.md +409 -0
- package/presets/cursor/skills/drizzle-schema-architect/SKILL.md +54 -0
- package/presets/cursor/skills/evaluation/SKILL.md +8 -0
- package/presets/cursor/skills/fastapi-pydantic-strict/SKILL.md +46 -0
- package/presets/cursor/skills/find-skills/SKILL.md +144 -0
- package/presets/cursor/skills/jpa-nplusone-detector/SKILL.md +49 -0
- package/presets/cursor/skills/jpa-postgres/SKILL.md +626 -0
- package/presets/cursor/skills/laravel-specialist/SKILL.md +267 -0
- package/presets/cursor/skills/laravel-specialist/references/eloquent.md +351 -0
- package/presets/cursor/skills/laravel-specialist/references/livewire.md +512 -0
- package/presets/cursor/skills/laravel-specialist/references/queues.md +423 -0
- package/presets/cursor/skills/laravel-specialist/references/routing.md +362 -0
- package/presets/cursor/skills/laravel-specialist/references/testing.md +522 -0
- package/presets/cursor/skills/livewire-alpine-bridge/SKILL.md +39 -0
- package/presets/cursor/skills/multi-agent-orchestration/README.md +144 -0
- package/presets/cursor/skills/multi-agent-orchestration/SKILL.md +579 -0
- package/presets/cursor/skills/multi-agent-orchestration/examples/framework_implementations.py +362 -0
- package/presets/cursor/skills/multi-agent-orchestration/examples/orchestration_patterns.py +411 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/agent_communication.py +334 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/benchmarking.py +341 -0
- package/presets/cursor/skills/multi-agent-orchestration/scripts/workflow_management.py +334 -0
- package/presets/cursor/skills/nextjs-typescript/SKILL.md +394 -0
- package/presets/cursor/skills/openspec/SKILL.md +52 -0
- package/presets/cursor/skills/pagespeed-insights/SKILL.md +445 -0
- package/presets/cursor/skills/pagespeed-insights/reference.md +50 -0
- package/presets/cursor/skills/pagespeed-perf/SKILL.md +281 -0
- package/presets/cursor/skills/php-pro/SKILL.md +210 -0
- package/presets/cursor/skills/php-pro/references/async-patterns.md +412 -0
- package/presets/cursor/skills/php-pro/references/laravel-patterns.md +377 -0
- package/presets/cursor/skills/php-pro/references/modern-php-features.md +323 -0
- package/presets/cursor/skills/php-pro/references/symfony-patterns.md +466 -0
- package/presets/cursor/skills/php-pro/references/testing-quality.md +466 -0
- package/presets/cursor/skills/python/SKILL.md +613 -0
- package/presets/cursor/skills/python-django-stack/SKILL.md +500 -0
- package/presets/cursor/skills/python-fastapi-stack/SKILL.md +464 -0
- package/presets/cursor/skills/security/SKILL.md +384 -0
- package/presets/cursor/skills/seo-analytics-injector/SKILL.md +44 -0
- package/presets/cursor/skills/spring-auth-auditor/SKILL.md +33 -0
- package/presets/cursor/skills/spring-boot-feature/SKILL.md +566 -0
- package/presets/cursor/skills/spring-boot-kotlin/SKILL.md +408 -0
- package/presets/cursor/skills/spring-boot-testing-strategy/SKILL.md +479 -0
- package/presets/cursor/skills/sqlalchemy/SKILL.md +473 -0
- package/presets/cursor/skills/tailwind-responsive-auditor/SKILL.md +32 -0
- package/presets/cursor/skills/tdd-mutation-tester/SKILL.md +28 -0
- package/presets/cursor/skills/testing-tdd/SKILL.md +592 -0
- package/presets/cursor/skills/workflow-orchestration-patterns/SKILL.md +98 -0
- package/presets/cursor/skills/workflow-orchestration-patterns/references/details.md +223 -0
- package/presets/opencode/agents/architect.md +22 -2
- package/presets/opencode/agents/complexity-auditor.md +16 -0
- package/presets/opencode/agents/contract-builder.md +109 -0
- package/presets/opencode/agents/devil.md +158 -0
- package/presets/opencode/agents/docs.md +19 -2
- package/presets/opencode/agents/goal-planner.md +112 -0
- package/presets/opencode/agents/implementer.md +39 -2
- package/presets/opencode/agents/orchestrator.md +124 -19
- package/presets/opencode/agents/planner.md +61 -0
- package/presets/opencode/agents/repo-explorer.md +15 -0
- package/presets/opencode/agents/reviewer.md +53 -2
- package/presets/opencode/agents/security-reviewer.md +159 -0
- package/presets/opencode/agents/task-coach.md +69 -2
- package/presets/opencode/agents/tester.md +18 -2
- package/presets/opencode/commands/cc-api-contract.md +12 -0
- package/presets/opencode/commands/cc-ask.md +55 -0
- package/presets/opencode/commands/cc-clarify.md +31 -0
- package/presets/opencode/commands/cc-council.md +87 -0
- package/presets/opencode/commands/cc-db-migration.md +22 -9
- package/presets/opencode/commands/cc-explore.md +35 -0
- package/presets/opencode/commands/cc-feature.md +41 -19
- package/presets/opencode/commands/cc-fix.md +50 -23
- package/presets/opencode/commands/cc-handoff.md +40 -0
- package/presets/opencode/commands/cc-iterative.md +127 -0
- package/presets/opencode/commands/cc-openspec.md +74 -0
- package/presets/opencode/commands/cc-pagespeed.md +12 -0
- package/presets/opencode/commands/cc-prototype.md +37 -0
- package/presets/opencode/commands/cc-refactor.md +12 -0
- package/presets/opencode/commands/cc-review.md +12 -0
- package/presets/opencode/commands/cc-scorecard.md +28 -0
- package/presets/opencode/commands/cc-tdd-cycle.md +24 -0
- package/presets/opencode/commands/cc-test-plan.md +12 -0
- package/presets/opencode/commands/cc-triage.md +33 -0
- package/presets/opencode/gates/pre-commit/GATE.md +136 -0
- package/presets/opencode/prompts/v0.1.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.2.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.3.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.4.0/DEPRECATED.md +11 -0
- package/presets/opencode/prompts/v0.5.0/architect.md +222 -0
- package/presets/opencode/prompts/v0.5.0/complexity-auditor.md +91 -0
- package/presets/opencode/prompts/v0.5.0/contract-builder.md +84 -0
- package/presets/opencode/prompts/v0.5.0/docs.md +190 -0
- package/presets/opencode/prompts/v0.5.0/goal-planner.md +80 -0
- package/presets/opencode/prompts/v0.5.0/implementer.md +171 -0
- package/presets/opencode/prompts/v0.5.0/orchestrator.md +388 -0
- package/presets/opencode/prompts/v0.5.0/repo-explorer.md +111 -0
- package/presets/opencode/prompts/v0.5.0/reviewer.md +248 -0
- package/presets/opencode/prompts/v0.5.0/security-reviewer.md +123 -0
- package/presets/opencode/prompts/v0.5.0/task-coach.md +156 -0
- package/presets/opencode/prompts/v0.5.0/tester.md +252 -0
- package/presets/opencode/prompts/v0.6.0/implementer.md +35 -0
- package/presets/opencode/prompts/v0.6.0/planner.md +36 -0
- package/presets/opencode/prompts/v0.6.0/reviewer.md +40 -0
- package/presets/opencode/prompts/v1.0.0/README.md +47 -0
- package/presets/opencode/prompts/v1.0.0/architect.md +259 -0
- package/presets/opencode/prompts/v1.0.0/complexity-auditor.md +116 -0
- package/presets/opencode/prompts/v1.0.0/contract-builder.md +120 -0
- package/presets/opencode/prompts/v1.0.0/devil.md +169 -0
- package/presets/opencode/prompts/v1.0.0/docs.md +229 -0
- package/presets/opencode/prompts/v1.0.0/goal-planner.md +123 -0
- package/presets/opencode/prompts/v1.0.0/implementer.md +228 -0
- package/presets/opencode/prompts/v1.0.0/orchestrator.md +474 -0
- package/presets/opencode/prompts/v1.0.0/planner.md +72 -0
- package/presets/opencode/prompts/v1.0.0/repo-explorer.md +147 -0
- package/presets/opencode/prompts/v1.0.0/reviewer.md +295 -0
- package/presets/opencode/prompts/v1.0.0/security-reviewer.md +170 -0
- package/presets/opencode/prompts/v1.0.0/task-coach.md +235 -0
- package/presets/opencode/prompts/v1.0.0/tester.md +298 -0
- package/presets/opencode/skills/evaluation/SKILL.md +6 -0
- package/presets/opencode/skills/openspec/SKILL.md +50 -0
- package/presets/seo-hotel/settings.json +0 -17
- package/presets/templates/BACKLOG.md +33 -0
- package/presets/templates/execution-profile.yml +6 -0
- package/presets/templates/model-comparison.md +11 -0
- package/presets/templates/regression-checklist.yml +10 -0
- package/src/presets/manifests/agy.yml +2 -2
- package/src/presets/manifests/claude.yml +2 -2
- package/src/presets/manifests/codex.yml +2 -2
- package/src/presets/manifests/cursor.yml +19 -3
- package/src/presets/manifests/gemini.yml +2 -2
- package/src/presets/manifests/opencode.yml +2 -2
- package/src/presets/models/agy.yml +97 -49
- package/src/presets/models/claude.yml +83 -39
- package/src/presets/models/codex.yml +83 -40
- package/src/presets/models/cursor.yml +83 -39
- package/src/presets/models/gemini.yml +83 -39
- package/src/presets/models/opencode.yml +78 -34
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: android
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
name: Android + Kotlin (Jetpack Compose & Media3)
|
|
5
|
+
description: >
|
|
6
|
+
Provides expert knowledge for building modern native Android apps using Kotlin, Jetpack Compose, Material Design 3, MVI architecture, Hilt dependency injection, and Media3/ExoPlayer.
|
|
7
|
+
|
|
8
|
+
user-invokable: true
|
|
9
|
+
license: MIT
|
|
10
|
+
metadata:
|
|
11
|
+
author: lgzarturo
|
|
12
|
+
category: mobile
|
|
13
|
+
|
|
14
|
+
compatibility:
|
|
15
|
+
tools: [claude, codex, gemini, agy, opencode]
|
|
16
|
+
stacks:
|
|
17
|
+
languages: [kotlin, java]
|
|
18
|
+
frameworks: [android]
|
|
19
|
+
|
|
20
|
+
risk:
|
|
21
|
+
level: medium
|
|
22
|
+
can_execute_shell: true
|
|
23
|
+
can_modify_files: true
|
|
24
|
+
requires_network: false
|
|
25
|
+
|
|
26
|
+
inputs: []
|
|
27
|
+
|
|
28
|
+
outputs: []
|
|
29
|
+
|
|
30
|
+
quality:
|
|
31
|
+
reviewed_by: codeconductor-core
|
|
32
|
+
version: 0.1.0
|
|
33
|
+
paths:
|
|
34
|
+
- "**/*.kt"
|
|
35
|
+
- "**/AndroidManifest.xml"
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# Android + Kotlin (Jetpack Compose & Media3)
|
|
39
|
+
|
|
40
|
+
This playbook defines the architecture, UI design system, performance guidelines, and testing strategy for native Android applications.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 1. Lead Architect & Modularization
|
|
45
|
+
|
|
46
|
+
### Architecture (MVI / MVVM with Clean Architecture)
|
|
47
|
+
- Prefer **MVI (Model-View-Intent)** for state management. Ensure a strict unidirectional data flow:
|
|
48
|
+
- **UiState**: Single source of truth for the UI state.
|
|
49
|
+
- **UiIntent**: Actions initiated by the user or system.
|
|
50
|
+
- **UiEffect**: One-time events (navigation, toasts, snackbars).
|
|
51
|
+
- Separate the project into clean logical modules:
|
|
52
|
+
- `app`: Application entry point, launcher activity, global dependency injection configuration.
|
|
53
|
+
- `core`: Shared resources, network layer, media playback logic (ExoPlayer/Media3), storage.
|
|
54
|
+
- `feature`: Individual business features (isolated and independent of other features).
|
|
55
|
+
|
|
56
|
+
### Dependency Injection (Hilt)
|
|
57
|
+
- Annotate the Application class with `@HiltAndroidApp`.
|
|
58
|
+
- Annotate Activities and Fragments with `@AndroidEntryPoint`.
|
|
59
|
+
- Use constructor injection for ViewModels with `@HiltViewModel`.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 2. Jetpack Compose UI/UX
|
|
64
|
+
|
|
65
|
+
### Recomposition & State Management
|
|
66
|
+
- Consume `StateFlow` from ViewModels safely using `collectAsStateWithLifecycle()` to respect the activity lifecycle.
|
|
67
|
+
- Keep data models immutable. Mark configuration classes with `@Immutable` or `@Stable` to prevent redundant recompositions.
|
|
68
|
+
- Use `contentType` and `key` in `LazyColumn` and `LazyRow` to optimize item recycling and rendering performance.
|
|
69
|
+
- Avoid fixed hardcoded margins. Apply `WindowInsets` to support modern edge-to-edge screens.
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## 3. Performance & Multimedia (Media3 / ExoPlayer)
|
|
74
|
+
|
|
75
|
+
### Playback & Services
|
|
76
|
+
- Run `ExoPlayer` / `Media3` inside a robust `Foreground Service` (using `MediaSessionService`) to ensure playback continues when the app is in the background.
|
|
77
|
+
- Clean up resources: release player instances in `onDestroy` or when the service is stopped.
|
|
78
|
+
- Control wake locks strictly to avoid draining the user's battery when playback is paused.
|
|
79
|
+
|
|
80
|
+
### Kotlin Coroutines & Threading
|
|
81
|
+
- Always inject `CoroutineDispatcher` instances instead of hardcoding them:
|
|
82
|
+
- `Dispatchers.IO`: Database access, network operations, file reading.
|
|
83
|
+
- `Dispatchers.Default`: CPU-intensive operations (parsing JSON, filtering large lists).
|
|
84
|
+
- `Dispatchers.Main`: UI modifications and light interactions.
|
|
85
|
+
|
|
86
|
+
### R8 & Resource Optimization
|
|
87
|
+
- Enable shrinking and obfuscation in production builds:
|
|
88
|
+
- `isMinifyEnabled = true`
|
|
89
|
+
- `isShrinkResources = true`
|
|
90
|
+
- Convert all static images to the modern `WebP` format to minimize the application binary size.
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## 4. Quality Assurance & Automated Testing
|
|
95
|
+
|
|
96
|
+
### Unit Testing
|
|
97
|
+
- Use JUnit 5 and MockK for mocking dependencies.
|
|
98
|
+
- Test ViewModels and Reducers by asserting StateFlow updates. Use `Turbine` to easily test Kotlin Flows.
|
|
99
|
+
- Mock all multimedia/ExoPlayer components to avoid loading actual audio/video resources in unit tests.
|
|
100
|
+
|
|
101
|
+
### UI Testing
|
|
102
|
+
- Create UI tests using Compose test rules: `createComposeRule()` or `createAndroidComposeRule<MainActivity>()`.
|
|
103
|
+
- Assert correct rendering, visibility states, and user interactions without executing real network calls.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 5. Key Gradle & ADB Commands
|
|
108
|
+
|
|
109
|
+
Use these commands for building, checking code style, running tests, and profiling performance:
|
|
110
|
+
|
|
111
|
+
| Command | Action |
|
|
112
|
+
| ------- | ------ |
|
|
113
|
+
| `./gradlew init` | Initialize a new Gradle project structure. |
|
|
114
|
+
| `./gradlew app:dependencies` | List all dependencies of the application module. |
|
|
115
|
+
| `./gradlew assembleDebug` | Validate compilation and generate debug APK. |
|
|
116
|
+
| `./gradlew ktlintCheck` | Run KtLint check to enforce Kotlin style guidelines. |
|
|
117
|
+
| `./gradlew lintDebug` | Run Android Lint tool to inspect code quality and UI issues. |
|
|
118
|
+
| `./gradlew testDebugUnitTest` | Run unit tests for debug build variant. |
|
|
119
|
+
| `./gradlew connectedAndroidTest` | Run instrumented UI tests on connected emulator or device. |
|
|
120
|
+
| `./gradlew assembleRelease` | Generate release build variant with R8 optimizations. |
|
|
121
|
+
| `adb shell dumpsys batterystats` | Profile system battery consumption metrics. |
|
|
122
|
+
| `adb shell am dumpheap <package> heap.hprof` | Dump application heap memory file for profiling. |
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: api-versioning
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
name: API Versioning
|
|
5
|
+
description: >
|
|
6
|
+
Provides expert knowledge for designing, implementing, and managing REST API
|
|
7
|
+
versioning strategies with deprecation workflows.
|
|
8
|
+
|
|
9
|
+
user-invokable: true
|
|
10
|
+
license: MIT
|
|
11
|
+
metadata:
|
|
12
|
+
author: lgzarturo
|
|
13
|
+
category: api
|
|
14
|
+
|
|
15
|
+
compatibility:
|
|
16
|
+
tools: [claude, codex, gemini, agy, opencode]
|
|
17
|
+
stacks:
|
|
18
|
+
languages: [kotlin, java, typescript, python, go]
|
|
19
|
+
frameworks: [spring-boot, spring-mvc, express, fastapi]
|
|
20
|
+
|
|
21
|
+
risk:
|
|
22
|
+
level: high
|
|
23
|
+
can_execute_shell: false
|
|
24
|
+
can_modify_files: true
|
|
25
|
+
requires_network: false
|
|
26
|
+
|
|
27
|
+
inputs:
|
|
28
|
+
- source_files
|
|
29
|
+
- openapi spec files
|
|
30
|
+
- existing controller classes
|
|
31
|
+
|
|
32
|
+
outputs:
|
|
33
|
+
- versioned controller classes
|
|
34
|
+
- OpenAPI spec updates
|
|
35
|
+
- deprecation headers
|
|
36
|
+
- changelog entries
|
|
37
|
+
- contract test scaffolding
|
|
38
|
+
|
|
39
|
+
quality:
|
|
40
|
+
reviewed_by: codeconductor-core
|
|
41
|
+
version: 0.1.0
|
|
42
|
+
---
|
|
43
|
+
# API Versioning
|
|
44
|
+
|
|
45
|
+
## Versioning Strategies
|
|
46
|
+
|
|
47
|
+
### URL Path Versioning (recommended for breaking changes)
|
|
48
|
+
|
|
49
|
+
```text
|
|
50
|
+
GET /api/v1/users
|
|
51
|
+
GET /api/v2/users
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Tradeoffs:
|
|
55
|
+
|
|
56
|
+
- Explicit and visible in logs, proxies, and browser history
|
|
57
|
+
- Easy to cache at the CDN level — the URL uniquely identifies the resource
|
|
58
|
+
version
|
|
59
|
+
- Easy to route at the load balancer
|
|
60
|
+
- Results in some duplication of controller code
|
|
61
|
+
- Changing the URL violates REST HATEOAS principles, though in practice this is
|
|
62
|
+
acceptable
|
|
63
|
+
|
|
64
|
+
Use this when: you have breaking changes and need maximum visibility and
|
|
65
|
+
cacheability.
|
|
66
|
+
|
|
67
|
+
### Header Versioning
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
GET /api/users
|
|
71
|
+
Accept: application/vnd.myapp+json;version=1
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Tradeoffs:
|
|
75
|
+
|
|
76
|
+
- Cleaner URLs
|
|
77
|
+
- Harder to test manually — browsers and curl require extra flags
|
|
78
|
+
- Cannot be bookmarked or linked directly
|
|
79
|
+
- CDN caching requires `Vary: Accept` header, which reduces cache hit rates
|
|
80
|
+
|
|
81
|
+
Use this when: you need clean URLs and your clients are all programmatic (no
|
|
82
|
+
browsers).
|
|
83
|
+
|
|
84
|
+
### Query Parameter Versioning (avoid)
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
GET /api/users?version=1
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
This approach contaminates resource URLs with transport concerns. The version is
|
|
91
|
+
not part of the resource identity. Do not use it. The only valid exception is
|
|
92
|
+
temporary backward-compat support during a migration window.
|
|
93
|
+
|
|
94
|
+
## When to Version
|
|
95
|
+
|
|
96
|
+
Version when the change is breaking. Not every change requires a version bump.
|
|
97
|
+
|
|
98
|
+
**Breaking — requires new version:**
|
|
99
|
+
|
|
100
|
+
- Removing a field from a response
|
|
101
|
+
- Renaming a field
|
|
102
|
+
- Changing a field's type (e.g., `string` to `object`)
|
|
103
|
+
- Changing the meaning of an existing field
|
|
104
|
+
- Removing an endpoint
|
|
105
|
+
- Changing required fields in a request
|
|
106
|
+
- Changing status codes in a non-additive way
|
|
107
|
+
|
|
108
|
+
**Not breaking — no version bump needed:**
|
|
109
|
+
|
|
110
|
+
- Adding an optional field to a response
|
|
111
|
+
- Adding a new endpoint
|
|
112
|
+
- Adding an optional request parameter
|
|
113
|
+
- Deprecating a field (marking it, but still returning it)
|
|
114
|
+
- Performance improvements
|
|
115
|
+
- Bug fixes that restore documented behavior
|
|
116
|
+
|
|
117
|
+
## Deprecation Process
|
|
118
|
+
|
|
119
|
+
When a version or endpoint is being phased out, follow this process:
|
|
120
|
+
|
|
121
|
+
**Step 1: Mark in OpenAPI.**
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
paths:
|
|
125
|
+
/api/v1/users/{id}:
|
|
126
|
+
get:
|
|
127
|
+
deprecated: true
|
|
128
|
+
description: |
|
|
129
|
+
Deprecated since 2026-05-07. Use /api/v2/users/{id} instead.
|
|
130
|
+
Sunset date: 2026-11-07.
|
|
131
|
+
summary: Get user by ID (deprecated)
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Step 2: Add deprecation headers to responses.**
|
|
135
|
+
|
|
136
|
+
```kotlin
|
|
137
|
+
@GetMapping("/{id}")
|
|
138
|
+
fun getUserV1(@PathVariable id: UUID, response: HttpServletResponse): ResponseEntity<UserV1Response> {
|
|
139
|
+
response.addHeader("Deprecation", "date=\"Wed, 07 May 2026 00:00:00 GMT\"")
|
|
140
|
+
response.addHeader("Sunset", "Mon, 07 Nov 2026 00:00:00 GMT")
|
|
141
|
+
response.addHeader("Link", "</api/v2/users/$id>; rel=\"successor-version\"")
|
|
142
|
+
return ResponseEntity.ok(userService.getById(id).toV1Response())
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Step 3: Document in CHANGELOG.**
|
|
147
|
+
|
|
148
|
+
```markdown
|
|
149
|
+
## Deprecated
|
|
150
|
+
|
|
151
|
+
- `GET /api/v1/users/{id}` — deprecated in favor of `GET /api/v2/users/{id}`.
|
|
152
|
+
Sunset: 2026-11-07.
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
**Step 4: Maintain dual support.**
|
|
156
|
+
|
|
157
|
+
Keep at least two active major versions at all times. When v3 ships, v1 can be
|
|
158
|
+
removed (v2 and v3 remain active).
|
|
159
|
+
|
|
160
|
+
**Step 5: Communicate the sunset date.**
|
|
161
|
+
|
|
162
|
+
Notify consumers before the sunset date through:
|
|
163
|
+
|
|
164
|
+
- API changelog
|
|
165
|
+
- Developer portal announcements
|
|
166
|
+
- Deprecation headers (machine-readable)
|
|
167
|
+
- Direct contact if you have consumer registration data
|
|
168
|
+
|
|
169
|
+
Do not remove a version without a minimum 6-month notice period. 3 months is the
|
|
170
|
+
absolute minimum if forced.
|
|
171
|
+
|
|
172
|
+
## OpenAPI Conventions
|
|
173
|
+
|
|
174
|
+
### One file per version (simple cases)
|
|
175
|
+
|
|
176
|
+
```text
|
|
177
|
+
openapi-v1.yaml
|
|
178
|
+
openapi-v2.yaml
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Each file is self-contained and independently valid.
|
|
182
|
+
|
|
183
|
+
### Single file with version in info (evolving APIs)
|
|
184
|
+
|
|
185
|
+
```yaml
|
|
186
|
+
openapi: '3.1.0'
|
|
187
|
+
info:
|
|
188
|
+
title: Users API
|
|
189
|
+
version: '2.0.0'
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Use `$ref` to share schemas across versions without duplication.
|
|
193
|
+
|
|
194
|
+
### Cross-version schema reuse
|
|
195
|
+
|
|
196
|
+
```yaml
|
|
197
|
+
# schemas/user-base.yaml
|
|
198
|
+
UserBase:
|
|
199
|
+
type: object
|
|
200
|
+
properties:
|
|
201
|
+
id:
|
|
202
|
+
type: string
|
|
203
|
+
format: uuid
|
|
204
|
+
email:
|
|
205
|
+
type: string
|
|
206
|
+
|
|
207
|
+
# openapi-v1.yaml
|
|
208
|
+
components:
|
|
209
|
+
schemas:
|
|
210
|
+
UserResponse:
|
|
211
|
+
allOf:
|
|
212
|
+
- $ref: './schemas/user-base.yaml#/UserBase'
|
|
213
|
+
- properties:
|
|
214
|
+
full_name:
|
|
215
|
+
type: string
|
|
216
|
+
|
|
217
|
+
# openapi-v2.yaml — splits full_name into first_name + last_name
|
|
218
|
+
components:
|
|
219
|
+
schemas:
|
|
220
|
+
UserResponse:
|
|
221
|
+
allOf:
|
|
222
|
+
- $ref: './schemas/user-base.yaml#/UserBase'
|
|
223
|
+
- properties:
|
|
224
|
+
first_name:
|
|
225
|
+
type: string
|
|
226
|
+
last_name:
|
|
227
|
+
type: string
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### Documenting breaking changes
|
|
231
|
+
|
|
232
|
+
Put the breaking change in the endpoint description, not just in a changelog:
|
|
233
|
+
|
|
234
|
+
```yaml
|
|
235
|
+
/api/v2/users/{id}:
|
|
236
|
+
get:
|
|
237
|
+
description: |
|
|
238
|
+
Returns user details.
|
|
239
|
+
|
|
240
|
+
Breaking changes from v1:
|
|
241
|
+
- `full_name` has been replaced by `first_name` and `last_name`
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Spring Boot Implementation
|
|
245
|
+
|
|
246
|
+
### URL path versioning
|
|
247
|
+
|
|
248
|
+
```kotlin
|
|
249
|
+
// V1 controller — never modify once published
|
|
250
|
+
@RestController
|
|
251
|
+
@RequestMapping("/api/v1/users")
|
|
252
|
+
class UserV1Controller(private val userService: UserService) {
|
|
253
|
+
|
|
254
|
+
@GetMapping("/{id}")
|
|
255
|
+
@Deprecated("Use /api/v2/users/{id}", ReplaceWith("UserV2Controller.getUser()"))
|
|
256
|
+
fun getUser(
|
|
257
|
+
@PathVariable id: UUID,
|
|
258
|
+
response: HttpServletResponse
|
|
259
|
+
): ResponseEntity<UserV1Response> {
|
|
260
|
+
response.addHeader("Deprecation", "date=\"Wed, 07 May 2026 00:00:00 GMT\"")
|
|
261
|
+
response.addHeader("Sunset", "Mon, 07 Nov 2026 00:00:00 GMT")
|
|
262
|
+
return when (val result = userService.getById(id)) {
|
|
263
|
+
is UserResult.Found -> ResponseEntity.ok(result.user.toV1Response())
|
|
264
|
+
is UserResult.NotFound -> ResponseEntity.notFound().build()
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// V2 controller — new version, new controller, shared service
|
|
270
|
+
@RestController
|
|
271
|
+
@RequestMapping("/api/v2/users")
|
|
272
|
+
class UserV2Controller(private val userService: UserService) {
|
|
273
|
+
|
|
274
|
+
@GetMapping("/{id}")
|
|
275
|
+
fun getUser(@PathVariable id: UUID): ResponseEntity<UserV2Response> {
|
|
276
|
+
return when (val result = userService.getById(id)) {
|
|
277
|
+
is UserResult.Found -> ResponseEntity.ok(result.user.toV2Response())
|
|
278
|
+
is UserResult.NotFound -> ResponseEntity.notFound().build()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Rules:
|
|
285
|
+
|
|
286
|
+
- Create a new controller for each new version — do not modify the existing one
|
|
287
|
+
- The service layer is shared across versions — only the controller and DTO
|
|
288
|
+
change
|
|
289
|
+
- DTO mapper functions are version-specific: `toV1Response()`, `toV2Response()`
|
|
290
|
+
- Never delete a versioned controller until after the sunset date
|
|
291
|
+
|
|
292
|
+
### DTO versioning
|
|
293
|
+
|
|
294
|
+
```kotlin
|
|
295
|
+
// V1 — original shape
|
|
296
|
+
data class UserV1Response(
|
|
297
|
+
val id: UUID,
|
|
298
|
+
val email: String,
|
|
299
|
+
val full_name: String
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
// V2 — breaking change: split full_name
|
|
303
|
+
data class UserV2Response(
|
|
304
|
+
val id: UUID,
|
|
305
|
+
val email: String,
|
|
306
|
+
val first_name: String,
|
|
307
|
+
val last_name: String
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
// Extension functions for mapping
|
|
311
|
+
fun User.toV1Response(): UserV1Response = UserV1Response(
|
|
312
|
+
id = id,
|
|
313
|
+
email = email,
|
|
314
|
+
full_name = "$firstName $lastName"
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
fun User.toV2Response(): UserV2Response = UserV2Response(
|
|
318
|
+
id = id,
|
|
319
|
+
email = email,
|
|
320
|
+
first_name = firstName,
|
|
321
|
+
last_name = lastName
|
|
322
|
+
)
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Contract Testing
|
|
326
|
+
|
|
327
|
+
Contract tests verify that your API does not break existing consumers before
|
|
328
|
+
changes reach production.
|
|
329
|
+
|
|
330
|
+
**When to run:** in CI, before merging any change that touches a controller,
|
|
331
|
+
DTO, or OpenAPI spec.
|
|
332
|
+
|
|
333
|
+
**Tool: Pact (consumer-driven contracts)**
|
|
334
|
+
|
|
335
|
+
Consumer writes a pact:
|
|
336
|
+
|
|
337
|
+
```kotlin
|
|
338
|
+
// In the consumer service test
|
|
339
|
+
@ExtendWith(PactConsumerTestExt::class)
|
|
340
|
+
class UserServiceConsumerTest {
|
|
341
|
+
|
|
342
|
+
@Pact(consumer = "order-service", provider = "user-service")
|
|
343
|
+
fun getUserPact(builder: PactDslWithProvider): RequestResponsePact {
|
|
344
|
+
return builder
|
|
345
|
+
.given("user with id exists")
|
|
346
|
+
.uponReceiving("a request for user by id")
|
|
347
|
+
.path("/api/v1/users/123e4567-e89b-12d3-a456-426614174000")
|
|
348
|
+
.method("GET")
|
|
349
|
+
.willRespondWith()
|
|
350
|
+
.status(200)
|
|
351
|
+
.body(LambdaDsl.newJsonBody { body ->
|
|
352
|
+
body.uuid("id")
|
|
353
|
+
body.stringType("email")
|
|
354
|
+
body.stringType("full_name")
|
|
355
|
+
}.build())
|
|
356
|
+
.toPact()
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
Provider verifies the pact:
|
|
362
|
+
|
|
363
|
+
```kotlin
|
|
364
|
+
@Provider("user-service")
|
|
365
|
+
@PactFolder("pacts")
|
|
366
|
+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
|
367
|
+
class UserServiceProviderTest {
|
|
368
|
+
|
|
369
|
+
@TestTarget
|
|
370
|
+
lateinit var target: HttpTestTarget
|
|
371
|
+
|
|
372
|
+
@BeforeEach
|
|
373
|
+
fun setUp(@LocalServerPort port: Int) {
|
|
374
|
+
target = HttpTestTarget("localhost", port)
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Rule:** run contract tests in CI before any merge that touches an API surface.
|
|
380
|
+
A broken contract test means a consumer will break in production.
|
|
381
|
+
|
|
382
|
+
## Test Structure Per Version
|
|
383
|
+
|
|
384
|
+
Each API version must have its own test class:
|
|
385
|
+
|
|
386
|
+
```text
|
|
387
|
+
src/test/kotlin/{package}/user/
|
|
388
|
+
controller/
|
|
389
|
+
UserV1ControllerTest.kt # tests for v1 endpoints
|
|
390
|
+
UserV2ControllerTest.kt # tests for v2 endpoints
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
Do not share test cases across versions. V1 behavior must be tested
|
|
394
|
+
independently from V2 — they can diverge.
|