Skip to content

feat: add project-scoped variable support#18

Merged
fank merged 3 commits intomainfrom
claude/project-scoped-variables
Apr 16, 2026
Merged

feat: add project-scoped variable support#18
fank merged 3 commits intomainfrom
claude/project-scoped-variables

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Apr 16, 2026

Summary

  • Adds --project flag to all variable subcommands (list, get, create, update, delete) to support n8n's project-scoped variables (GA since n8n v1.118.0)
  • Adds ProjectID field to Variable struct and threads projectId through ListVariables and CreateVariable API methods
  • variable list dynamically shows a PROJECT column when any returned variable is project-scoped

Usage

# Global variables (unchanged)
n8nctl variable list
n8nctl variable create api_url https://api.example.com

# Project-scoped variables
n8nctl variable list --project pJK8xB2nFqWdR0yT
n8nctl variable create env production --project pJK8xB2nFqWdR0yT
n8nctl variable get env --project pJK8xB2nFqWdR0yT
n8nctl variable update env staging --project pJK8xB2nFqWdR0yT
n8nctl variable delete env --project pJK8xB2nFqWdR0yT

Test plan

  • go build ./... compiles cleanly
  • go vet ./... passes
  • n8nctl variable list --help shows --project flag
  • n8nctl variable create --help shows --project flag
  • n8nctl variable list still works without --project (backward compatible)
  • n8nctl variable create key val --project <id> creates a project-scoped variable
  • n8nctl variable list --project <id> filters to that project's variables

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces project-scoping for variables by updating the API client and adding a "--project" flag to all variable CLI subcommands. The "list" command now conditionally displays a project column when project-scoped variables are present. Review feedback suggests improving the API client's consistency by returning a "*ListResult" with pagination support, refactoring the CLI table rendering to reduce duplication, and defining the "--project" flag as a persistent flag on the parent command to minimize boilerplate.

Comment thread internal/api/client.go
Comment thread internal/cmd/variable/variable.go
Comment thread internal/cmd/variable/variable.go Outdated
Address PR review feedback:
- Move --project flag to parent command as persistent flag
- Deduplicate table rendering into single loop with conditional format
@fank fank merged commit a49559b into main Apr 16, 2026
5 checks passed
@fank fank deleted the claude/project-scoped-variables branch April 16, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant