/mapping-service-resources
Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects
$ npx -y skills add LerianStudio/ring --skill mapping-service-resources --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/mapping-service-resources
Context preview
The summary Claude sees to decide when to auto-load this skill.
Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects
SKILL.md
mapping-service-resources.SKILL.mdname: ring:mapping-service-resources
description: "Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects existing Postgres migrations, emits an HTML report, and offers opt-in S3 upload. Use before ring:adding-multi-tenancy on a new service. Skip for non-Go projects."
Service Discovery
When to use
- User wants to know what to provision in dispatch layer for a service
- User asks "what services/modules/resources does this project have?"
- Before running ring:adding-multi-tenancy on a new service
- User asks about MongoDB indexes in a project
Skip when
- Not a Go project
- Task does not involve service discovery, dispatch layer, or resource mapping
- Project has no external dependencies
Related
**Complementary:** ring:adding-multi-tenancy, ring:implementing-tasks
Prerequisites
- Go project with go.mod in the current working directory
Scans Go project to produce dispatch layer registration data. Orchestrator executes all detection phases directly.
Phase 1: Service Detection
# Service name
grep "ApplicationName\|ServiceName" internal/bootstrap/config.go 2>/dev/null | head -5
cat .env.example 2>/dev/null | grep -i "APPLICATION_NAME\|SERVICE_NAME" | head -3
# Service type
test -f go.mod && cat go.mod | head -3 # module path hints service purpose
ls internal/adapters/ 2>/dev/null # adapters reveal type
# Unified service check
ls components/ 2>/dev/null # multiple components = unified service
Output:
service_name: "my-service"
is_unified: true | false
components: [{name, path, applicationName}] # if unifiedPhase 2: Module Detection
# Strategy A: Explicit WithModule calls (preferred)
grep -rn "WithModule(" internal/ components/ 2>/dev/null
# Extract string arg: WithModule("onboarding") → module "onboarding"
# Strategy B: Component-based (if no WithModule found)
ls components/ # each component = one module
# module_name = component's ApplicationName
# Strategy C: Single-component fallback
# module_name = service ApplicationNameMerge: Strategy A → B fills gaps → C fallback.
Phase 3: Resource Detection per Module
For each module, scan `{component_path}/internal/adapters/`:
# PostgreSQL: subdirectory existence
ls {base_path}postgres/ 2>/dev/null
# MongoDB
ls {base_path}mongodb/ 2>/dev/null || ls {base_path}mongo/ 2>/dev/null
# RabbitMQ
ls {base_path}rabbitmq/ 2>/dev/null
grep -l "producer\|Producer" {base_path}rabbitmq/ 2>/dev/null
grep -l "consumer\|Consumer" {base_path}rabbitmq/ 2>/dev/null
# Redis (informational only — NOT a dispatch layer resource)
ls {base_path}redis/ 2>/dev/nullPhase 3.5: Database Name Detection per Module
# From bootstrap config
grep -E 'env:"POSTGRES_NAME|env:"DB_.*_NAME|env:"MONGO_NAME|env:"MONGO_.*_NAME' \
{component_path}/internal/bootstrap/config.go
# From .env.example (actual values)
grep -E "POSTGRES_NAME=|DB_.*_NAME=|MONGO_NAME=|MONGO_.*_NAME=" {component_path}/.env.example
# External datasources
grep -E "DATASOURCE_.*_DATABASE=" {component_path}/.env.exampleCross-reference across modules: same database name in 2+ modules = shared (provision once).
Phase 4: MongoDB Index Detection & Migration File Generation
**Only execute if MongoDB was detected in any module during Phase 3.**
Execute the procedure in `references/mongodb-index-detection.md` — Steps 1, 2, 3, 4 only. (Detection and local generation only; S3 upload is handled in Phase 6.)
1. **Step 1** — Detect in-code index definitions (`EnsureIndexes`, `IndexModel`, `CreateIndex`) per module. 2. **Step 2** — Detect existing local migration files in `{component_path}/scripts/mongodb/*.up.json` + `*.down.json` (fallback legacy `*.js`). LOCAL ONLY — no S3 lookup. 3. **Step 3** — Cross-reference code vs. local migration files, classify each as `covered` / `missing_migration` / `migration_only`. 4. **Step 4** — Generate one `.up.json` + `.down.json` file pair per missing index (atomic per index, NOT grouped by collection):
- Path: `{component_path}/scripts/mongodb/{NNNNNN}_{index_name}.up.json` / `.down.json` — per-module directory preserves ownership for Phase 6 upload (single-component services resolve `{component_path}` to repo root)
- Naming: `idx_{collection}_{fields}` (or `uniq_*` for uniqueness business rules)
- HARD GATE: every `.up.json` MUST have explicit `"options.name"` matching the file name
- **Track per module:** populate `module.generated_migration_files = [{up_file, down_file, index_name}, ...]` so Phase 6 knows exactly which files belong to which module
**Format reminder:** the dispatch layer reads `.up.json` / `.down.json` from S3 and applies indexes on tenant provisioning. The service does NOT execute these files. Legacy `.js` scripts are NOT uploaded — only JSON migrations.
Phase 4.5: PostgreSQL Migration Detection
**Only execute if PostgreSQL was detected in any module during Phase 3.**
Detection only — Postgres migrations are written by developers; this skill does NOT generate `.sql` files.
# Common golang-migrate locations (per module path resolved in Phase 3)
ls {component_path}/scripts/postgres/*.up.sql 2>/dev/null
ls {component_path}/scripts/postgresql/*.up.sql 2>/dev/null
ls {component_path}/db/migrations/*.up.sql 2>/dev/null
ls {component_path}/migrations/*.up.sql 2>/dev/nullFor each `.up.sql` file found:
- Verify the matching `.down.sql` exists (golang-migrate convention).
- Map it to its module (by directory path).
- Track for the Phase 6 upload.
Store: `module.postgres_migrations = [{up_file, down_file, sequence, description}]`
If a `.up.sql` exists without `.down.sql` → flag in Phase 5 HTML report (golang-migrate requires pairs).
Phase 5: Generate HTML Report
Dispatch `ring:visualizing
Read more
name: ring:mapping-service-resources description: "Mapping a Go service's Service -> Module -> Resource hierarchy for dispatch-layer registration: detects modules and per-module PostgreSQL/MongoDB/RabbitMQ resources, database names, and shared databases, generates MongoDB index migration pairs (.up.json/.down.json), detects existing Postgres migrations, emits an HTML report, and offers opt-in S3 upload. Use before ring:adding-multi-tenancy on a new service. Skip for non-Go projects."
Service Discovery
When to use
- User wants to know what to provision in dispatch layer for a service
- User asks "what services/modules/resources does this project have?"
- Before running ring:adding-multi-tenancy on a new service
- User asks about MongoDB indexes in a project
Skip when
- Not a Go project
- Task does not involve service discovery, dispatch layer, or resource mapping
- Project has no external dependencies
Related
**Complementary:** ring:adding-multi-tenancy, ring:implementing-tasks
Prerequisites
- Go project with go.mod in the current working directory
Scans Go project to produce dispatch layer registration data. Orchestrator executes all detection phases directly.
Phase 1: Service Detection
# Service name grep "ApplicationName\|ServiceName" internal/bootstrap/config.go 2>/dev/null | head -5 cat .env.example 2>/dev/null | grep -i "APPLICATION_NAME\|SERVICE_NAME" | head -3 # Service type test -f go.mod && cat go.mod | head -3 # module path hints service purpose ls internal/adapters/ 2>/dev/null # adapters reveal type # Unified service check ls components/ 2>/dev/null # multiple components = unified service
Output:
service_name: "my-service"
is_unified: true | false
components: [{name, path, applicationName}] # if unifiedPhase 2: Module Detection
# Strategy A: Explicit WithModule calls (preferred)
grep -rn "WithModule(" internal/ components/ 2>/dev/null
# Extract string arg: WithModule("onboarding") → module "onboarding"
# Strategy B: Component-based (if no WithModule found)
ls components/ # each component = one module
# module_name = component's ApplicationName
# Strategy C: Single-component fallback
# module_name = service ApplicationNameMerge: Strategy A → B fills gaps → C fallback.
Phase 3: Resource Detection per Module
For each module, scan `{component_path}/internal/adapters/`:
# PostgreSQL: subdirectory existence
ls {base_path}postgres/ 2>/dev/null
# MongoDB
ls {base_path}mongodb/ 2>/dev/null || ls {base_path}mongo/ 2>/dev/null
# RabbitMQ
ls {base_path}rabbitmq/ 2>/dev/null
grep -l "producer\|Producer" {base_path}rabbitmq/ 2>/dev/null
grep -l "consumer\|Consumer" {base_path}rabbitmq/ 2>/dev/null
# Redis (informational only — NOT a dispatch layer resource)
ls {base_path}redis/ 2>/dev/nullPhase 3.5: Database Name Detection per Module
# From bootstrap config
grep -E 'env:"POSTGRES_NAME|env:"DB_.*_NAME|env:"MONGO_NAME|env:"MONGO_.*_NAME' \
{component_path}/internal/bootstrap/config.go
# From .env.example (actual values)
grep -E "POSTGRES_NAME=|DB_.*_NAME=|MONGO_NAME=|MONGO_.*_NAME=" {component_path}/.env.example
# External datasources
grep -E "DATASOURCE_.*_DATABASE=" {component_path}/.env.exampleCross-reference across modules: same database name in 2+ modules = shared (provision once).
Phase 4: MongoDB Index Detection & Migration File Generation
**Only execute if MongoDB was detected in any module during Phase 3.**
Execute the procedure in `references/mongodb-index-detection.md` — Steps 1, 2, 3, 4 only. (Detection and local generation only; S3 upload is handled in Phase 6.)
1. **Step 1** — Detect in-code index definitions (`EnsureIndexes`, `IndexModel`, `CreateIndex`) per module. 2. **Step 2** — Detect existing local migration files in `{component_path}/scripts/mongodb/*.up.json` + `*.down.json` (fallback legacy `*.js`). LOCAL ONLY — no S3 lookup. 3. **Step 3** — Cross-reference code vs. local migration files, classify each as `covered` / `missing_migration` / `migration_only`. 4. **Step 4** — Generate one `.up.json` + `.down.json` file pair per missing index (atomic per index, NOT grouped by collection):
- Path: `{component_path}/scripts/mongodb/{NNNNNN}_{index_name}.up.json` / `.down.json` — per-module directory preserves ownership for Phase 6 upload (single-component services resolve `{component_path}` to repo root)
- Naming: `idx_{collection}_{fields}` (or `uniq_*` for uniqueness business rules)
- HARD GATE: every `.up.json` MUST have explicit `"options.name"` matching the file name
- **Track per module:** populate `module.generated_migration_files = [{up_file, down_file, index_name}, ...]` so Phase 6 knows exactly which files belong to which module
**Format reminder:** the dispatch layer reads `.up.json` / `.down.json` from S3 and applies indexes on tenant provisioning. The service does NOT execute these files. Legacy `.js` scripts are NOT uploaded — only JSON migrations.
Phase 4.5: PostgreSQL Migration Detection
**Only execute if PostgreSQL was detected in any module during Phase 3.**
Detection only — Postgres migrations are written by developers; this skill does NOT generate `.sql` files.
# Common golang-migrate locations (per module path resolved in Phase 3)
ls {component_path}/scripts/postgres/*.up.sql 2>/dev/null
ls {component_path}/scripts/postgresql/*.up.sql 2>/dev/null
ls {component_path}/db/migrations/*.up.sql 2>/dev/null
ls {component_path}/migrations/*.up.sql 2>/dev/nullFor each `.up.sql` file found:
- Verify the matching `.down.sql` exists (golang-migrate convention).
- Map it to its module (by directory path).
- Track for the Phase 6 upload.
Store: `module.postgres_migrations = [{up_file, down_file, sequence, description}]`
If a `.up.sql` exists without `.down.sql` → flag in Phase 5 HTML report (golang-migrate requires pairs).
Phase 5: Generate HTML Report
Dispatch `ring:visualizing
Proven engineering practices, enforced through skills. Ring is a comprehensive skills library and workflow system for AI agents that transforms how AI assistants approach software development.
Repo: LerianStudio/ring
Other skills on ring.
- /analyzing-options
Analyzing different approaches for a task or problem with structured comparisons, effort estimates, and recommendations. Use when facing strategic decisions, architecture choices, or multiple viable approaches. Skip when there's an obvious single approach or the decision is
Open skill - /auditing-production-readiness
Auditing a service's production readiness against Ring engineering standards across base dimensions plus a conditional multi-tenant dimension, then emitting a scored report and an HTML dashboard. Use before production deploy, periodic review, onboarding, or a major release. Skip
Open skill - /cleaning-comments
Cleaning redundant and obvious comments following clean code principles while preserving meaningful documentation. Supports git scope filtering (staged, unstaged, branch, commit-range). Use when code has excessive comments, during code review, or post-refactor cleanup. Skip when
Open skill - /committing-changes
Commit changes with scope allowlist enforcement, atomic grouping, GPG-signed conventional commits, and trailer management. Detects the repo's PR-validation scope policy before proposing any message. Use when the user asks to commit or has changes ready to record. Skip when the
Open skill - /creating-handoffs
Creating a handoff document that captures session state (completed work, decisions, open items, next steps) and delivering it via Plan Mode so the user gets the native 'clear context and continue implementing' resume option. Use when ending a session, when context grows large,
Open skill - /creating-worktrees
Creating an isolated git worktree for parallel branch work: selects the directory by priority order, verifies/adds .gitignore safety, auto-installs the detected toolchain's dependencies, runs a baseline test, and reports readiness. Use before a feature that needs isolation from
Open skill

