Golem fix missing ns

From ThinkR-open/golem · View interactive version

Golem fix missing ns is an AI agent skill from the GitHub repository ThinkR-open/golem. Validate that all module input/output IDs are properly namespaced. Triggers on: - "check my modules for missing ns" - "find missing ns in modules" - "validate module namespaces" Do not trigger on: - when the user is not working inside a golem app

How to use this skill

Skill file

Check for Missing `ns()` in Modules

Validate that all module input/output IDs are properly namespaced.

Why Namespacing Matters

In Shiny modules, all input and output IDs must be namespaced using the ns() function. This prevents ID conflicts when the same module is used multiple times in an app.

Correct vs Incorrect

✅ Correct

mod_analytics_ui <- function(id) {
  ns <- NS(id)
  tagList(
    selectInput(
      ns("type_filter"),
      label = NULL,
      choices = c("All", "None")
    )
  )
}

❌ Incorrect

mod_analytics_ui <- function(id) {
  ns <- NS(id)
  tagList(
    selectInput(
      "type_filter",  # Missing ns()!
      label = NULL,
      choices = c("All", "None")
    )
  )
}

What to Check

In Module UI Functions

In Module Server Functions

Places to Look

How Claude Checks

  1. Locate all IDs in module files (files starting with mod_)
  1. Verify namespacing by checking each ID is wrapped in ns()
  1. Report findings
  1. Fix if approved

Common Mistakes

| Mistake | Fix |

|---------|-----|

| selectInput("myid", ...) | selectInput(ns("myid"), ...) |

| plotOutput("plot") | plotOutput(ns("plot")) |

| observeEvent(input$button) | observeEvent(input$submit, ...) with ID properly namespaced |

| uiOutput("dynamic") | uiOutput(ns("dynamic")) |

When to Run

Example Workflow

User: Check my modules for missing ns()

Claude:
1. Scans all mod_*.R files
2. Identifies 3 missing ns() wrappings
3. Shows the issues with line numbers
4. Asks: "Should I fix these?"

User: Yes, fix them

Claude:
- Updates the files
- Runs the check again to verify
- Confirms: "All fixed! ✅"

Notes

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.