azcodr 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.
Files changed (89) hide show
  1. package/.agents/skills/agentic-architect/SKILL.md +118 -0
  2. package/.agents/skills/agentic-architect/references/agents_md_template.md +59 -0
  3. package/.agents/skills/agentic-architect/references/refinement_workflow.md +32 -0
  4. package/.agents/skills/agentic-architect/references/skill_architecture_inquiry.md +63 -0
  5. package/.agents/skills/agentic-architect/references/skill_template.md +55 -0
  6. package/.agents/skills/agentic-architect/scripts/validate_agentic_configs.sh +163 -0
  7. package/.agents/skills/clean-code-refactor/SKILL.md +91 -0
  8. package/.agents/skills/clean-code-refactor/references/clean_code_smells.md +27 -0
  9. package/.agents/skills/clean-code-refactor/references/design_patterns_ts.md +65 -0
  10. package/.agents/skills/compliance-audit/SKILL.md +120 -0
  11. package/.agents/skills/compliance-audit/references/owasp_top10_controls.md +16 -0
  12. package/.agents/skills/compliance-audit/references/soc2_iso_controls.md +28 -0
  13. package/.agents/skills/lets-build/SKILL.md +164 -0
  14. package/.agents/skills/lets-build/references/architecture_interview_matrix.md +188 -0
  15. package/.agents/skills/lets-build/references/hexagonal_bootstrap_scaffolds.md +113 -0
  16. package/.agents/skills/lets-build/references/project_readme_template.md +79 -0
  17. package/.agents/skills/lets-build/scripts/bootstrap_workspace.sh +68 -0
  18. package/.agents/skills/merge-ai/SKILL.md +90 -0
  19. package/.agents/skills/merge-ai/scripts/audit_divergence.sh +108 -0
  20. package/.agents/skills/merge-ai/scripts/resolve_repo.sh +177 -0
  21. package/.agents/skills/product-analyst/SKILL.md +143 -0
  22. package/.agents/skills/product-analyst/references/backlog_ordering_techniques.md +107 -0
  23. package/.agents/skills/product-analyst/references/gherkin_patterns.md +46 -0
  24. package/.agents/skills/product-analyst/references/invest_checklist.md +38 -0
  25. package/.agents/skills/product-analyst/references/okr_alignment_guide.md +76 -0
  26. package/.agents/skills/product-analyst/references/smart_tasks.md +59 -0
  27. package/.agents/skills/relentless-questioner/SKILL.md +120 -0
  28. package/.agents/skills/relentless-questioner/references/adaptive_question_trees.md +84 -0
  29. package/.gitignore +20 -0
  30. package/AGENTS.md +119 -0
  31. package/LICENSE +21 -0
  32. package/README.md +184 -0
  33. package/bin/azcodr.js +151 -0
  34. package/docs/knowledge/dos_and_donts.md +540 -0
  35. package/docs/knowledge/issue_log.md +25 -0
  36. package/docs/knowledge/knowledge_graph.md +188 -0
  37. package/docs/knowledge/lessons_learned.md +107 -0
  38. package/docs/knowledge/ubiquitous_language.md +23 -0
  39. package/docs/rules/accessibility.md +31 -0
  40. package/docs/rules/advanced_api_patterns.md +104 -0
  41. package/docs/rules/agentic_configuration.md +168 -0
  42. package/docs/rules/api_versioning.md +128 -0
  43. package/docs/rules/application_security.md +23 -0
  44. package/docs/rules/architecture_decision_records.md +42 -0
  45. package/docs/rules/authentication.md +76 -0
  46. package/docs/rules/authorization.md +75 -0
  47. package/docs/rules/caching.md +52 -0
  48. package/docs/rules/clean_code.md +25 -0
  49. package/docs/rules/cloud_native.md +43 -0
  50. package/docs/rules/compliance.md +25 -0
  51. package/docs/rules/container_infrastructure.md +32 -0
  52. package/docs/rules/continuous_deployment.md +24 -0
  53. package/docs/rules/continuous_integration.md +20 -0
  54. package/docs/rules/continuous_learning.md +29 -0
  55. package/docs/rules/database_integrity.md +88 -0
  56. package/docs/rules/database_migrations.md +41 -0
  57. package/docs/rules/database_operations.md +27 -0
  58. package/docs/rules/database_performance.md +44 -0
  59. package/docs/rules/database_transactions.md +81 -0
  60. package/docs/rules/design_patterns.md +40 -0
  61. package/docs/rules/devsecops.md +33 -0
  62. package/docs/rules/domain_driven_design.md +84 -0
  63. package/docs/rules/domain_expertise.md +42 -0
  64. package/docs/rules/error_handling.md +39 -0
  65. package/docs/rules/feature_flags.md +42 -0
  66. package/docs/rules/gof_design_patterns_reference.md +70 -0
  67. package/docs/rules/multitenancy_isolation.md +86 -0
  68. package/docs/rules/product_ownership.md +150 -0
  69. package/docs/rules/project_management.md +66 -0
  70. package/docs/rules/react.md +88 -0
  71. package/docs/rules/relentless_questioning.md +48 -0
  72. package/docs/rules/requirements_engineering.md +113 -0
  73. package/docs/rules/rest_api_conventions.md +62 -0
  74. package/docs/rules/server_driven_ui.md +71 -0
  75. package/docs/rules/tenant_dynamic_schemas.md +88 -0
  76. package/docs/rules/tenant_pluggable_logic.md +59 -0
  77. package/docs/rules/test_driven_development.md +106 -0
  78. package/docs/rules/test_isolation.md +26 -0
  79. package/docs/rules/transactional_email.md +20 -0
  80. package/docs/rules/typescript.md +55 -0
  81. package/docs/rules/ui_navigation.md +20 -0
  82. package/docs/rules/ui_ux_architecture.md +168 -0
  83. package/docs/rules/upstream_synchronization.md +66 -0
  84. package/docs/rules/workflow_state_machines.md +118 -0
  85. package/docs/rules/workspace_isolation.md +25 -0
  86. package/lib/index.js +5 -0
  87. package/lib/scaffold.js +177 -0
  88. package/memory.md +262 -0
  89. package/package.json +49 -0
@@ -0,0 +1,79 @@
1
+ # {{PROJECT_NAME}}
2
+
3
+ > **{{PROJECT_TAGLINE_OR_MISSION}}**
4
+
5
+ ---
6
+
7
+ ## 🌟 Architecture & Stack
8
+
9
+ - **Architecture:** Hexagonal (Ports & Adapters) with strict systemic atomicity and zero-downtime database patterns.
10
+ - **Language & Runtime:** {{LANGUAGE_AND_RUNTIME}}
11
+ - **Package Manager & Build:** {{PACKAGE_MANAGER_AND_BUILD_TOOL}}
12
+ - **Primary Transport:** {{TRANSPORT_PROTOCOL_AND_FRAMEWORK}}
13
+ - **Persistence Engine:** {{DATABASE_ENGINE}} (Migrations via {{MIGRATION_TOOL}})
14
+ - **Multi-Tenancy Isolation:** {{TENANCY_ISOLATION_MODEL}}
15
+ - **Dynamic Extensibility:** Common Expression Language (CEL) / JSON Schema Draft 2020-12
16
+ - **Observability:** OpenTelemetry (OTel) OTLP export over gRPC/HTTP
17
+ - **Security & DevSecOps:** Semgrep SAST, Gitleaks, Trivy scanning, CycloneDX SBOM
18
+
19
+ ---
20
+
21
+ ## 🗂️ Project Structure
22
+
23
+ ```
24
+ .
25
+ ├── specs/ # Canonical contract specifications
26
+ │ ├── openapi/ # OpenAPI 3.1 REST specifications
27
+ │ ├── protobuf/ # Protocol Buffers v3 definitions
28
+ │ ├── schemas/ # Universal JSON Schema Draft 2020-12
29
+ │ └── tokens/ # W3C DTCG Design Tokens
30
+ ├── src/ # Hexagonal Application Source
31
+ │ ├── domain/ # Core Invariant Domain (Entities, Value Objects)
32
+ │ ├── ports/ # Primary (Use Cases) and Secondary (Repositories) Ports
33
+ │ └── adapters/ # Ingress (HTTP/gRPC) and Egress (SQL/Broker) Adapters
34
+ ├── tests/
35
+ │ ├── unit/ # Fast unit tests using test doubles
36
+ │ ├── integration/ # Adapter tests with transactional rollback
37
+ │ ├── contracts/ # Consumer contract tests (Pact)
38
+ │ └── acceptance/ # BDD Gherkin / Cucumber features
39
+ ├── deploy/ # OCI Distroless Dockerfiles & Compose manifests
40
+ ├── docs/rules/ # 41 atomic single-responsibility architectural rules
41
+ ├── memory.md # Master memory hub & Lightweight ADR ledger
42
+ └── AGENTS.md # Lean agentic directives (< 120 lines)
43
+ ```
44
+
45
+ ---
46
+
47
+ ## ⚡ Quickstart & Development
48
+
49
+ ### 1. Prerequisites
50
+ - {{PREREQUISITES_LIST}}
51
+ - Docker & Docker Compose
52
+
53
+ ### 2. Environment Setup
54
+ ```bash
55
+ cp .env.example .env
56
+ ```
57
+
58
+ ### 3. Install Dependencies
59
+ ```bash
60
+ {{INSTALL_COMMAND}}
61
+ ```
62
+
63
+ ### 4. Run Development Environment
64
+ ```bash
65
+ {{DEV_RUN_COMMAND}}
66
+ ```
67
+
68
+ ### 5. Run Tests & Verification
69
+ ```bash
70
+ {{TEST_COMMAND}}
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🏛️ Architecture Governance & Decisions
76
+
77
+ This project is governed by the **41 Atomic Domain Rules** located in [`docs/rules/`](./docs/rules/) and Architectural Decision Records in [`memory.md`](./memory.md):
78
+ - **ADR Ledger:** See [`memory.md`](./memory.md) for ADR-001 through ADR-006.
79
+ - **Architectural Rules:** See [`docs/rules/`](./docs/rules/) for TDD, Clean Code, Multi-Tenancy, Database Integrity, and DevSecOps directives.
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env bash
2
+ # ==============================================================================
3
+ # bootstrap_workspace.sh
4
+ # Deterministic Scaffolder for Hexagonal Multi-Tenant Workspaces
5
+ # ==============================================================================
6
+
7
+ set -euo pipefail
8
+
9
+ WORKSPACE_ROOT="${1:-$(pwd)}"
10
+ LANGUAGE="${2:-generic}"
11
+
12
+ echo "🚀 Initializing Hexagonal Architecture Workspace in: ${WORKSPACE_ROOT}"
13
+ echo "📦 Target Language Profile: ${LANGUAGE}"
14
+ echo "--------------------------------------------------------------"
15
+
16
+ # 1. Create Universal Specification Directories
17
+ echo "1. Scaffolding Contract Specification Directories (specs/)..."
18
+ mkdir -p "${WORKSPACE_ROOT}/specs/protobuf"
19
+ mkdir -p "${WORKSPACE_ROOT}/specs/openapi"
20
+ mkdir -p "${WORKSPACE_ROOT}/specs/schemas"
21
+ mkdir -p "${WORKSPACE_ROOT}/specs/tokens"
22
+
23
+ # 2. Create Universal Hexagonal Source Directories
24
+ echo "2. Scaffolding Hexagonal Source Tree (src/)..."
25
+ mkdir -p "${WORKSPACE_ROOT}/src/domain/entities"
26
+ mkdir -p "${WORKSPACE_ROOT}/src/domain/value_objects"
27
+ mkdir -p "${WORKSPACE_ROOT}/src/domain/services"
28
+ mkdir -p "${WORKSPACE_ROOT}/src/ports/primary"
29
+ mkdir -p "${WORKSPACE_ROOT}/src/ports/secondary"
30
+ mkdir -p "${WORKSPACE_ROOT}/src/adapters/primary"
31
+ mkdir -p "${WORKSPACE_ROOT}/src/adapters/secondary"
32
+
33
+ # 3. Create Universal Test Directories
34
+ echo "3. Scaffolding Test Suites (tests/)..."
35
+ mkdir -p "${WORKSPACE_ROOT}/tests/unit"
36
+ mkdir -p "${WORKSPACE_ROOT}/tests/integration"
37
+ mkdir -p "${WORKSPACE_ROOT}/tests/contracts"
38
+ mkdir -p "${WORKSPACE_ROOT}/tests/acceptance"
39
+
40
+ # 4. Create Deployment & Infrastructure Directories
41
+ echo "4. Scaffolding Deployment Infrastructure (deploy/)..."
42
+ mkdir -p "${WORKSPACE_ROOT}/deploy/docker"
43
+ mkdir -p "${WORKSPACE_ROOT}/deploy/compose"
44
+ mkdir -p "${WORKSPACE_ROOT}/deploy/k8s"
45
+
46
+ # 5. Create Default Design Tokens Spec
47
+ TOKEN_SPEC="${WORKSPACE_ROOT}/specs/tokens/tokens.json"
48
+ if [[ ! -f "${TOKEN_SPEC}" ]]; then
49
+ cat << 'EOF' > "${TOKEN_SPEC}"
50
+ {
51
+ "color": {
52
+ "brand": {
53
+ "primary": { "$value": "#2563eb", "$type": "color" },
54
+ "secondary": { "$value": "#475569", "$type": "color" },
55
+ "accent": { "$value": "#f59e0b", "$type": "color" }
56
+ }
57
+ },
58
+ "dimension": {
59
+ "radius": {
60
+ "base": { "$value": "6px", "$type": "dimension" }
61
+ }
62
+ }
63
+ }
64
+ EOF
65
+ fi
66
+
67
+ echo "--------------------------------------------------------------"
68
+ echo "✅ Hexagonal directory tree and contract specifications scaffolded successfully!"
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: merge-ai
3
+ description: Use when the user invokes /merge-ai or asks to merge generic AI rules, skills, lessons learned, and post-mortems from the current workspace back into the generic azcodr baseline repository. Do not use for merging application business logic or routine Git branches.
4
+ ---
5
+
6
+ # Merge AI Knowledge, Rules & Skills Skill (`/merge-ai`)
7
+
8
+ > **Core Philosophy:** Upstream baseline repositories (e.g. `https://github.com/org/azcodr`) must remain pristine, generic, and untouched until the user explicitly triggers `/merge-ai`. When triggered from any project workspace (e.g. `https://github.com/org/my-project`), detect if the baseline repo is already cloned locally (apply directly) or clone it first, purge all project-specific domain models, colocate DOs and DONTs into atomic rules, and synchronize the generic baseline.
9
+
10
+ ---
11
+
12
+ ## 1. When to Use This Skill
13
+ - The user issues `/merge-ai` or requests syncing AI rules, skills, issue logs, and lessons learned back into the generic baseline repository.
14
+ - User references repository URLs (e.g. Source: `https://github.com/org/my-project`, Target: `https://github.com/org/azcodr`).
15
+ - Auditing divergences between the current project workspace and the generic baseline repository.
16
+ - Exporting newly discovered architectural patterns, defect post-mortems, or reusable skills to the generic starter.
17
+ - **DO NOT USE** during routine project feature development or bug fixes.
18
+ - **DO NOT USE** to merge application domain entities, business logic, or project-specific data models.
19
+ - **DO NOT USE** without explicit user invocation.
20
+
21
+ ---
22
+
23
+ ## 2. Step-by-Step Execution Workflow
24
+
25
+ ### Phase 1: Target Baseline Repository Resolution (URL or Local)
26
+ When `/merge-ai` is triggered with repository URLs (e.g. `/merge-ai https://github.com/org/my-project https://github.com/org/azcodr`):
27
+ 1. **Execute Repo Resolver Script:**
28
+ ```bash
29
+ # Discovers existing local clone or automatically clones fresh
30
+ eval $(bash .agents/skills/merge-ai/scripts/resolve_repo.sh "$TARGET_REPO_URL")
31
+ ```
32
+ - **If already cloned locally:** Discovers its directory, verifies clean working tree, and exports `STATUS=ALREADY_CLONED` and `LOCAL_PATH` (e.g. `/path/to/azcodr`).
33
+ - **If not cloned locally:** Automatically executes `git clone "$TARGET_REPO_URL"` to `$HOME/projects/<name>` and exports `STATUS=CLONED_FRESH` and `LOCAL_PATH`.
34
+ 2. Set `$BASELINE_DIR="$LOCAL_PATH"`.
35
+ 3. If `STATUS=ALREADY_CLONED`, ensure the repository is on branch `main` (`git -C "$BASELINE_DIR" pull --ff-only`).
36
+
37
+ ---
38
+
39
+ ### Phase 2: Divergence Audit & Domain Purging
40
+ 1. Run the divergence audit script:
41
+ ```bash
42
+ bash .agents/skills/merge-ai/scripts/audit_divergence.sh "$BASELINE_DIR"
43
+ ```
44
+ 2. Systematically filter out all project-specific elements before proposing changes:
45
+ - **Purge Business Domain Entities:** Replace project-specific nouns with universal architectural archetypes (`Entity`, `Aggregate`, `ValueObject`, `Resource`, `Transaction`).
46
+ - **Purge Concrete Stack Specifics:** Keep core rules stack-agnostic (Hexagonal Ports, abstract repositories). Keep project-specific setups (e.g. SQLite dev / Postgres prod, React Vite client) in the project workspace.
47
+ - **Colocate DOs & DONTs into Atomic Rules:** Embed DOs and DONTs directly inside their governing atomic rule files in `docs/rules/` (`## Invariants, DO's & DONT's`). Keep `docs/knowledge/dos_and_donts.md` strictly as a clean cross-reference index directory.
48
+ - **Transform ADRs & Post-Mortems:** Port universal decisions (ADR-007 CRUD & Selectors, ADR-008 Bootstrapping Decoupling, ADR-009 Agile Domain TDD, ADR-010 M:N Skill Composability) as generic ADRs in `memory.md`. Port universal post-mortems (`ISSUE-004`, `ISSUE-005`) into `issue_log.md` and `lessons_learned.md`.
49
+
50
+ ---
51
+
52
+ ### Phase 3: Dry-Run Review & Explicit User Confirmation
53
+ 1. Present a concise, structured dry-run report to the user summarizing:
54
+ - Target baseline repo URL and resolved local directory (`$BASELINE_DIR`).
55
+ - Generic rules, skills, post-mortems, and ADRs to be merged.
56
+ - Domain-specific elements purged.
57
+ 2. **STOP AND ASK FOR EXPLICIT CONFIRMATION** before modifying `$BASELINE_DIR`.
58
+
59
+ ---
60
+
61
+ ### Phase 4: Apply Merge, Validate & Sync
62
+ Upon user confirmation:
63
+ 1. Apply the generic updates to `$BASELINE_DIR`:
64
+ - `AGENTS.md` (Unified Agent Cognitive & Agile Domain Lifecycle).
65
+ - `docs/rules/` (Updated atomic rules with colocated DOs/DONTs).
66
+ - `.agents/skills/` (Updated generic skills, e.g. decoupled `lets-build`).
67
+ - `docs/knowledge/` (Index-only `dos_and_donts.md`, generic post-mortems in `issue_log.md`, `lessons_learned.md`, `knowledge_graph.md`).
68
+ - `memory.md` (Generic ADRs).
69
+ 2. Validate agentic configuration integrity in the baseline:
70
+ ```bash
71
+ bash "$BASELINE_DIR/.agents/skills/agentic-architect/scripts/validate_agentic_configs.sh"
72
+ ```
73
+ *Requirement: 0 warnings, AGENTS.md <= 120 lines, valid symlinks.*
74
+ 3. Commit and push the baseline repository to remote:
75
+ ```bash
76
+ git -C "$BASELINE_DIR" add -A
77
+ git -C "$BASELINE_DIR" commit -m "feat(ai-sync): merge generic rules, skills, and lifecycle improvements from workspace"
78
+ git -C "$BASELINE_DIR" push origin main
79
+ ```
80
+ 4. Confirm successful synchronization with the remote generic baseline URL.
81
+
82
+ ---
83
+
84
+ ## 3. Gotchas & What NOT to Do
85
+
86
+ - **MAJOR DONT: Never touch, edit, or commit to the baseline repository (`azcodr`) during routine feature development.** The baseline must be left completely alone until `/merge-ai` is explicitly invoked.
87
+ - **DO NOT** copy application domain models, database tables, or framework-specific configs to the baseline.
88
+ - **DO NOT** create monolithic DO/DONT lists. Always colocate directives in atomic rules.
89
+ - **DO NOT** execute the merge without presenting a dry-run summary and receiving explicit approval.
90
+ - **DO NOT** push to the baseline repository if `validate_agentic_configs.sh` fails or reports warnings.
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ BASELINE_DIR="${1:-/home/prosubodh/projects/azcodr}"
5
+ CURRENT_DIR="$(pwd)"
6
+
7
+ echo "=================================================================="
8
+ echo "🔍 Auditing AI Knowledge & Rule Divergence"
9
+ echo "Current Workspace: $CURRENT_DIR"
10
+ echo "Baseline Template: $BASELINE_DIR"
11
+ echo "=================================================================="
12
+
13
+ if [ ! -d "$BASELINE_DIR" ]; then
14
+ echo "❌ Error: Baseline directory '$BASELINE_DIR' does not exist."
15
+ exit 1
16
+ fi
17
+
18
+ echo ""
19
+ echo "--- 1. Checking Core Directives (AGENTS.md) ---"
20
+ if diff -q "$CURRENT_DIR/AGENTS.md" "$BASELINE_DIR/AGENTS.md" > /dev/null 2>&1; then
21
+ echo "✅ AGENTS.md is identical."
22
+ else
23
+ echo "⚠️ AGENTS.md differs between workspaces."
24
+ fi
25
+
26
+ echo ""
27
+ echo "--- 2. Checking Atomic Rules (docs/rules/) ---"
28
+ DIFF_RULES=$(diff -qr "$CURRENT_DIR/docs/rules" "$BASELINE_DIR/docs/rules" 2>/dev/null || true)
29
+ if [ -z "$DIFF_RULES" ]; then
30
+ echo "✅ All atomic rules in docs/rules/ are identical."
31
+ else
32
+ echo "$DIFF_RULES"
33
+ fi
34
+
35
+ echo ""
36
+ echo "--- 3. Checking Specialized Skills (.agents/skills/) ---"
37
+ DIFF_SKILLS=$(diff -qr "$CURRENT_DIR/.agents/skills" "$BASELINE_DIR/.agents/skills" 2>/dev/null || true)
38
+ if [ -z "$DIFF_SKILLS" ]; then
39
+ echo "✅ All skills in .agents/skills/ are identical."
40
+ else
41
+ echo "$DIFF_SKILLS"
42
+ fi
43
+
44
+ echo ""
45
+ echo "--- 4. Checking Knowledge Hub (docs/knowledge/) ---"
46
+ DIFF_KNOW=$(diff -qr "$CURRENT_DIR/docs/knowledge" "$BASELINE_DIR/docs/knowledge" 2>/dev/null || true)
47
+ if [ -z "$DIFF_KNOW" ]; then
48
+ echo "✅ All knowledge files in docs/knowledge/ are identical."
49
+ else
50
+ echo "$DIFF_KNOW"
51
+ fi
52
+
53
+ echo ""
54
+ echo "--- 5. Checking Architecture Decision Records (memory.md) ---"
55
+ if [ -f "$CURRENT_DIR/memory.md" ] && [ -f "$BASELINE_DIR/memory.md" ]; then
56
+ mapfile -t BASELINE_ADRS < <(grep -E '^### ADR-[0-9]+:' "$BASELINE_DIR/memory.md" 2>/dev/null | sed -E 's/^### ADR-[0-9]+:[[:space:]]*//' || true)
57
+ mapfile -t CURRENT_ADRS < <(grep -E '^### ADR-[0-9]+:' "$CURRENT_DIR/memory.md" 2>/dev/null | sed -E 's/^### ADR-[0-9]+:[[:space:]]*//' || true)
58
+
59
+ MISSING_IN_CURRENT=()
60
+ for b_adr in "${BASELINE_ADRS[@]}"; do
61
+ [ -z "$b_adr" ] && continue
62
+ found=false
63
+ for c_adr in "${CURRENT_ADRS[@]}"; do
64
+ if [ "$b_adr" = "$c_adr" ]; then
65
+ found=true
66
+ break
67
+ fi
68
+ done
69
+ if [ "$found" = false ]; then
70
+ MISSING_IN_CURRENT+=("$b_adr")
71
+ fi
72
+ done
73
+
74
+ EXTRA_IN_CURRENT=()
75
+ for c_adr in "${CURRENT_ADRS[@]}"; do
76
+ [ -z "$c_adr" ] && continue
77
+ found=false
78
+ for b_adr in "${BASELINE_ADRS[@]}"; do
79
+ if [ "$c_adr" = "$b_adr" ]; then
80
+ found=true
81
+ break
82
+ fi
83
+ done
84
+ if [ "$found" = false ]; then
85
+ EXTRA_IN_CURRENT+=("$c_adr")
86
+ fi
87
+ done
88
+
89
+ if [ ${#MISSING_IN_CURRENT[@]} -gt 0 ]; then
90
+ echo "⚠️ Workspace is missing ${#MISSING_IN_CURRENT[@]} baseline ADR(s):"
91
+ for m in "${MISSING_IN_CURRENT[@]}"; do
92
+ echo " - $m"
93
+ done
94
+ elif [ ${#EXTRA_IN_CURRENT[@]} -eq 0 ]; then
95
+ echo "✅ memory.md ADRs are 100% identical."
96
+ else
97
+ echo "✅ All generic baseline ADRs are synchronized."
98
+ for e in "${EXTRA_IN_CURRENT[@]}"; do
99
+ echo " ℹ️ Project-specific ADR retained in workspace: $e"
100
+ done
101
+ fi
102
+ else
103
+ echo "⚠️ memory.md not found in one or both workspaces."
104
+ fi
105
+
106
+ echo "=================================================================="
107
+ echo "Audit complete. Run /merge-ai to filter and merge generic changes."
108
+ echo "=================================================================="
@@ -0,0 +1,177 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # ==============================================================================
5
+ # resolve_repo.sh
6
+ # Deterministically resolves whether a remote Git URL is cloned locally,
7
+ # EVEN IF CLONED UNDER A COMPLETELY DIFFERENT FOLDER NAME.
8
+ #
9
+ # Usage: ./resolve_repo.sh <REPO_URL> [--check-only] [--dest-dir <DIR>]
10
+ # ==============================================================================
11
+
12
+ REPO_URL="${1:-}"
13
+ CHECK_ONLY=false
14
+ DEST_DIR=""
15
+
16
+ if [ -z "$REPO_URL" ]; then
17
+ echo "Usage: $0 <REPO_URL> [--check-only] [--dest-dir <DIR>]" >&2
18
+ exit 1
19
+ fi
20
+
21
+ shift || true
22
+ while [[ $# -gt 0 ]]; do
23
+ case "$1" in
24
+ --check-only)
25
+ CHECK_ONLY=true
26
+ shift
27
+ ;;
28
+ --dest-dir)
29
+ DEST_DIR="$2"
30
+ shift 2
31
+ ;;
32
+ *)
33
+ echo "Unknown option: $1" >&2
34
+ exit 1
35
+ ;;
36
+ esac
37
+ done
38
+
39
+ normalize_git_url() {
40
+ local url="$1"
41
+ url="${url%.git}"
42
+ url="${url%/}"
43
+ url=$(echo "$url" | sed -E 's/^(https?:\/\/|ssh:\/\/git@|ssh:\/\/|git@)//')
44
+ url=$(echo "$url" | sed -E 's/:/\//')
45
+ echo "$url" | tr '[:upper:]' '[:lower:]'
46
+ }
47
+
48
+ TARGET_NORM=$(normalize_git_url "$REPO_URL")
49
+ REPO_NAME=$(basename "$TARGET_NORM")
50
+ CURRENT_DIR="$(pwd)"
51
+
52
+ # Check if a specific directory matches the target URL by inspecting its remotes
53
+ matches_target_url() {
54
+ local dir="$1"
55
+ if [ ! -d "$dir/.git" ]; then
56
+ return 1
57
+ fi
58
+
59
+ # Check all configured remotes (origin, upstream, etc.)
60
+ local remotes
61
+ remotes=$(git -C "$dir" config --get-regexp '^remote\..*\.url' 2>/dev/null | awk '{print $2}' || true)
62
+ for r in $remotes; do
63
+ local r_norm
64
+ r_norm=$(normalize_git_url "$r")
65
+ if [ "$r_norm" = "$TARGET_NORM" ]; then
66
+ return 0
67
+ fi
68
+ done
69
+ return 1
70
+ }
71
+
72
+ FOUND_PATH=""
73
+
74
+ # ------------------------------------------------------------------------------
75
+ # Pass 1: Fast Probe of Standard Conventions
76
+ # ------------------------------------------------------------------------------
77
+ FAST_CANDIDATES=(
78
+ "${DEST_DIR:-}"
79
+ "$HOME/projects/$REPO_NAME"
80
+ "$(dirname "$CURRENT_DIR")/$REPO_NAME"
81
+ "$CURRENT_DIR/$REPO_NAME"
82
+ "$CURRENT_DIR"
83
+ )
84
+
85
+ for cand in "${FAST_CANDIDATES[@]}"; do
86
+ [ -z "$cand" ] && continue
87
+ if matches_target_url "$cand"; then
88
+ FOUND_PATH="$(cd "$cand" && pwd)"
89
+ break
90
+ fi
91
+ done
92
+
93
+ # ------------------------------------------------------------------------------
94
+ # Pass 2: Deep Scan Across Sibling & Project Roots (Handles ANY folder name!)
95
+ # ------------------------------------------------------------------------------
96
+ if [ -z "$FOUND_PATH" ]; then
97
+ SEARCH_ROOTS=()
98
+ PARENT_DIR="$(dirname "$CURRENT_DIR")"
99
+ SEARCH_ROOTS+=("$PARENT_DIR")
100
+ [ -d "$HOME/projects" ] && [ "$HOME/projects" != "$PARENT_DIR" ] && SEARCH_ROOTS+=("$HOME/projects")
101
+ [ -d "$HOME/workspace" ] && SEARCH_ROOTS+=("$HOME/workspace")
102
+ [ -d "$HOME/dev" ] && SEARCH_ROOTS+=("$HOME/dev")
103
+ [ -d "$HOME/code" ] && SEARCH_ROOTS+=("$HOME/code")
104
+
105
+ for root in "${SEARCH_ROOTS[@]}"; do
106
+ [ ! -d "$root" ] && continue
107
+ # Search maxdepth 2 for any .git directory
108
+ while IFS= read -r gitdir; do
109
+ repo_candidate="$(dirname "$gitdir")"
110
+ if matches_target_url "$repo_candidate"; then
111
+ FOUND_PATH="$(cd "$repo_candidate" && pwd)"
112
+ break 2
113
+ fi
114
+ done < <(find "$root" -maxdepth 2 -name ".git" -type d 2>/dev/null || true)
115
+ done
116
+ fi
117
+
118
+ # ------------------------------------------------------------------------------
119
+ # Output Resolution
120
+ # ------------------------------------------------------------------------------
121
+ if [ -n "$FOUND_PATH" ]; then
122
+ BRANCH=$(git -C "$FOUND_PATH" branch --show-current 2>/dev/null || true)
123
+ if [ -z "$BRANCH" ]; then
124
+ BRANCH=$(git -C "$FOUND_PATH" rev-parse --short HEAD 2>/dev/null || echo "unknown")
125
+ fi
126
+ PORCELAIN=$(git -C "$FOUND_PATH" status --porcelain 2>/dev/null || true)
127
+ IS_CLEAN="true"
128
+ if [ -n "$PORCELAIN" ]; then
129
+ IS_CLEAN="false"
130
+ fi
131
+ FOLDER_NAME=$(basename "$FOUND_PATH")
132
+
133
+ echo "STATUS=ALREADY_CLONED"
134
+ echo "LOCAL_PATH=$FOUND_PATH"
135
+ echo "LOCAL_FOLDER_NAME=$FOLDER_NAME"
136
+ echo "CANONICAL_SLUG=$TARGET_NORM"
137
+ echo "CURRENT_BRANCH=$BRANCH"
138
+ echo "IS_CLEAN=$IS_CLEAN"
139
+ exit 0
140
+ fi
141
+
142
+ if [ "$CHECK_ONLY" = true ]; then
143
+ echo "STATUS=NOT_CLONED"
144
+ echo "LOCAL_PATH="
145
+ echo "LOCAL_FOLDER_NAME="
146
+ echo "CANONICAL_SLUG=$TARGET_NORM"
147
+ exit 1
148
+ fi
149
+
150
+ # ------------------------------------------------------------------------------
151
+ # Fallback: Fresh Clone
152
+ # ------------------------------------------------------------------------------
153
+ if [ -z "$DEST_DIR" ]; then
154
+ if [ -d "$HOME/projects" ]; then
155
+ DEST_DIR="$HOME/projects/$REPO_NAME"
156
+ else
157
+ DEST_DIR="$(dirname "$CURRENT_DIR")/$REPO_NAME"
158
+ fi
159
+ fi
160
+
161
+ echo "📥 Repository '$REPO_URL' not found locally under any folder name. Cloning into '$DEST_DIR'..." >&2
162
+ mkdir -p "$(dirname "$DEST_DIR")"
163
+ git clone "$REPO_URL" "$DEST_DIR" >&2
164
+
165
+ FINAL_PATH="$(cd "$DEST_DIR" && pwd)"
166
+ BRANCH=$(git -C "$FINAL_PATH" branch --show-current 2>/dev/null || true)
167
+ if [ -z "$BRANCH" ]; then
168
+ BRANCH=$(git -C "$FINAL_PATH" rev-parse --short HEAD 2>/dev/null || echo "unknown")
169
+ fi
170
+
171
+ echo "STATUS=CLONED_FRESH"
172
+ echo "LOCAL_PATH=$FINAL_PATH"
173
+ echo "LOCAL_FOLDER_NAME=$(basename "$FINAL_PATH")"
174
+ echo "CANONICAL_SLUG=$TARGET_NORM"
175
+ echo "CURRENT_BRANCH=$BRANCH"
176
+ echo "IS_CLEAN=true"
177
+ exit 0
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: product-analyst
3
+ description: Use when analyzing product requirements, aligning features with OKRs and Product Goals, prioritizing backlogs with Kano/MoSCoW/RICE, decomposing epics into INVEST user stories and SMART tasks, authoring Gherkin Given-When-Then acceptance criteria, or mapping domain models and failure edge cases. Do not use for writing application code, debugging implementation bugs, or running tests.
4
+ ---
5
+
6
+ # Product Analyst & Requirements Architect Skill
7
+
8
+ > **Core Purpose:** Bridge strategic business intent and engineering execution by grounding feature requirements in OKRs, maximizing product value via empirical backlog ordering (Kano, MoSCoW, RICE), and decomposing scope into vertically sliced INVEST user stories with Gherkin acceptance criteria and SMART developer tasks.
9
+
10
+ ---
11
+
12
+ ## 1. When to Use This Skill
13
+ - Decomposing a broad business request, feature idea, or PRD into actionable vertical slices.
14
+ - Evaluating alignment with strategic **Objectives & Key Results (OKRs)** and the overarching **Product Goal**.
15
+ - Ordering and prioritizing Product Backlog items using **Kano**, **MoSCoW**, **RICE**, or **Buy a Feature**.
16
+ - Distinguishing user-facing stories from non-story requirements (system invariants, NFRs, architectural spikes).
17
+ - Formulating Gherkin acceptance tests before kicking off Outside-In TDD.
18
+ - Decomposing INVEST stories into actionable, time-boxed **SMART developer tasks**.
19
+ - Establishing Ubiquitous Language definitions for new domain models.
20
+
21
+ ---
22
+
23
+ ## 2. Step-by-Step Analysis Workflow
24
+
25
+ ```
26
+ 1. OKR & Goal Alignment ──► 2. Backlog Triage & Ordering ──► 3. Story vs. NFR Classification ──► 4. INVEST Stories & Gherkin ──► 5. SMART Tasks & Edge Cases
27
+ ```
28
+
29
+ ### Step 1: Align with OKRs & the Product Goal
30
+ - **Product Goal Validation:** Verify how this feature advances the long-term Product Goal.
31
+ - **OKR Mapping:** Map the feature to a specific **Objective** (qualitative "what") and its associated **Key Results** (quantitative "how").
32
+ - **Satisfaction Gap Check:** Identify which customer pain point or satisfaction gap is addressed:
33
+ $$\text{Satisfaction Gap} = \text{Desired Customer Experience} - \text{Current Customer Experience}$$
34
+ - **Deciding What NOT to Do:** Explicitly identify and eliminate speculative, low-impact sub-features.
35
+
36
+ ### Step 2: Prioritize via Backlog Ordering Models
37
+ Consult [`references/backlog_ordering_techniques.md`](./references/backlog_ordering_techniques.md) to apply the optimal prioritization model:
38
+ - **Kano Model:** Classify as *Must-be* (table stakes), *Performance* (linear satisfaction), or *Attractive* (delighter). Reject *Indifferent* or *Reverse* items.
39
+ - **MoSCoW:** Categorize into *Must*, *Should*, *Could*, or *Won't have this time*.
40
+ - **RICE Scoring:** Compute $(Reach \times Impact \times Confidence) / Effort$ to break ranking ties objectively.
41
+
42
+ ### Step 3: Classify User Stories vs. Non-Story Requirements
43
+ Recognize that **user stories are not requirements**, but a technique to express them:
44
+ - **User Story (3 C's: Card, Conversation, Confirmation):** Fits user-facing features where customer/business perspective is translated into software behavior via a "pidgin language".
45
+ - **Non-Story Requirements:** If the requirement represents a system invariant, data integrity rule, security policy (OWASP), latency SLA, or an architectural spike, model it directly as a technical specification, architectural fitness test, or spike task rather than forcing an artificial `"As a user..."` persona.
46
+
47
+ ### Step 4: Author User Stories (INVEST Framework & Vertical Cake Slicing)
48
+ Ensure every user story conforms to Bill Wake's **INVEST** criteria:
49
+ - **Independent:** Sliced vertically through all layers (UI ➔ API ➔ Domain ➔ DB) without circular dependencies.
50
+ - **Negotiable:** Captures essence and value, leaving implementation details open for pairing co-creation.
51
+ - **Valuable:** Delivers observable benefit to the customer or business stakeholder.
52
+ - **Estimable:** Right-sized and bounded. Spikes used for major unknowns.
53
+ - **Small:** Sized to be completable in 1–2 development days.
54
+ - **Testable:** Accompanied by executable, unambiguous Gherkin acceptance criteria.
55
+
56
+ **The Multi-Layer Cake Rule:** Never slice horizontally (e.g. "Create database schema only"). Always slice vertically through the full stack so that every story delivers working software.
57
+
58
+ ### Step 5: Decompose Stories into SMART Developer Tasks
59
+ For engineering execution, translate INVEST user stories into Bill Wake's **SMART** developer tasks:
60
+ - **S - Specific:** Unambiguous scope without conceptual overlap.
61
+ - **M - Measurable:** Clear pass/fail criteria (tests pass, clean code, DoD met).
62
+ - **A - Achievable:** Realistically executable; triggers early help request if blocked.
63
+ - **R - Relevant:** Justified by direct contribution to parent story.
64
+ - **T - Time-boxed:** Limited to 2–4 hours (never exceeding 1 day).
65
+
66
+ ### Step 6: Construct the Edge Case & Failure Matrix
67
+ Map all failure paths to HTTP status codes (`400`, `401`, `403`, `404`, `409`, `422`, `429`, `500`) and RFC 7807 problem details.
68
+
69
+ ---
70
+
71
+ ## 3. Gotchas & What NOT to Do
72
+
73
+ - **DO NOT** confuse output (features shipped, story points burned) with outcome (value delivered, satisfaction gap closed).
74
+ - **DO NOT** write horizontal, technical user stories (e.g., *"As a developer, I want a database table"*).
75
+ - **DO NOT** force technical constraints, security policies, or infrastructure upgrades into user story syntax. Treat them as non-story requirements or architectural spikes.
76
+ - **DO NOT** omit the Out-of-Scope ("Won't Have this time") section. Lack of negative boundaries causes runaway scope bloat.
77
+ - **DO NOT** allow developer tasks to be open-ended without a measurable time-box. If a task exceeds 4 hours, it must be split or paired.
78
+ - **DO NOT** skip failure paths in Gherkin scenarios. Happy-path-only requirements lead to production defects.
79
+
80
+ ---
81
+
82
+ ## 4. Structured Output Template
83
+
84
+ ```markdown
85
+ # Product Specification: [Feature Name]
86
+
87
+ ## 1. Strategic Alignment & Product Goal
88
+ - **Product Goal:** [Target milestone / commitment]
89
+ - **Target OKR:**
90
+ - **Objective:** [Qualitative, inspiring What]
91
+ - **Key Result(s):** [Quantitative, measurable outcome How]
92
+ - **Target Satisfaction Gap:** [Customer pain point addressed]
93
+ - **Prioritization Category:** [Kano: Must-be / Performance / Attractive | MoSCoW: Must / Should | RICE Score: X]
94
+
95
+ ## 2. In-Scope vs. Out-of-Scope (Non-Goals)
96
+ - **In-Scope (Must/Should):** ...
97
+ - **Out-of-Scope (Won't Have This Time):** ...
98
+
99
+ ## 3. Ubiquitous Language & Entity Relationships
100
+ - **[Term 1]**: [Definition grounded in domain invariants]
101
+ - **[Term 2]**: [Definition grounded in domain invariants]
102
+
103
+ ## 4. User Stories & Gherkin Acceptance Scenarios
104
+
105
+ ### US-01: [User Story Title]
106
+ **As a** [role]
107
+ **I want to** [action]
108
+ **So that** [value]
109
+
110
+ ```gherkin
111
+ Scenario: [Happy path]
112
+ Given ...
113
+ When ...
114
+ Then ...
115
+
116
+ Scenario: [Edge case / Failure path]
117
+ Given ...
118
+ When ...
119
+ Then ...
120
+ ```
121
+
122
+ ## 5. SMART Developer Tasks (Inner-Loop Breakdown)
123
+ - [ ] **Task 1 [Specific & Time-boxed: 2h]:** [Technical description, e.g. Domain entity and value object invariants with unit test RED-GREEN]
124
+ - [ ] **Task 2 [Specific & Time-boxed: 3h]:** [Use case & secondary repository implementation with integration tests]
125
+ - [ ] **Task 3 [Specific & Time-boxed: 2h]:** [HTTP controller endpoint & RFC 7807 error handling]
126
+ - [ ] **Task 4 [Specific & Time-boxed: 3h]:** [UI view integration, TanStack query hooks, accessible Radix primitives]
127
+
128
+ ## 6. Edge Case & Error Response Matrix
129
+ | Condition | HTTP Status | Error Code | Expected Behavior |
130
+ |---|---|---|---|
131
+ | Invalid payload | 400 | `VALIDATION_ERROR` | Return field errors |
132
+ | Cross-tenant attempt | 403 / 404 | `FORBIDDEN` | Mask existence or block |
133
+ | Duplicate invariant | 409 | `CONFLICT` | Prevent double-submission |
134
+ ```
135
+
136
+ ---
137
+
138
+ ## 5. Subdirectories & Progressive Resources
139
+ - [references/invest_checklist.md](./references/invest_checklist.md): Checklist for evaluating user stories against Bill Wake's INVEST criteria and cake-slicing rules.
140
+ - [references/smart_tasks.md](./references/smart_tasks.md): Guide and patterns for breaking stories into SMART developer tasks.
141
+ - [references/backlog_ordering_techniques.md](./references/backlog_ordering_techniques.md): Matrix and decision trees for Kano, MoSCoW, RICE, and Buy a Feature.
142
+ - [references/okr_alignment_guide.md](./references/okr_alignment_guide.md): Framework for authoring Objectives, Key Results, and connecting them to Product Goals.
143
+ - [references/gherkin_patterns.md](./references/gherkin_patterns.md): Reusable Gherkin scenario patterns for REST APIs and UI interactions.