lutherwaves/spellcasting/tweaking-a-cast
Claude Code and agent skill by lutherwaves/spellcasting
- community
Checking that the SKILL.md file is still in the repository.
Use when modifying an existing resource on a magic-based service — add a column, add a filter, add a role guard, add soft-delete, swap a storage adapter — enforces DTO-completeness on every field change
Install
npx vskill@latest install lutherwaves/spellcasting/tweaking-a-castSKILL.md
The same SKILL.md was published earlier as lutherwaves/spellcasting/tweaking-a-cast.
tweaking-a-cast
Targeted modifications to a resource that already exists in a magic-based service. Routes by the user's intent. Every field-touching change goes through the DTO-completeness rule.
Prerequisites
- Existing magic service at cwd.
- The file being modified imports
github.com/tink3rlabs/magic/*. If not, abort with: "Target file doesn't look like a magic-based service — out of scope."
The DTO-completeness rule (mandatory)
When you add a column to a database struct, you MUST complete ALL of these in the same change:
- Add the field to the DB struct (in
pkg/types/<resource>.go). - Add to the Create DTO (
CreateResource) if user-settable on creation. - Add to the Update DTO (
UpdateResource) if user-modifiable. - Add to the validation schema in
pkg/routes/<resource>/validation.go. - Wire into the service layer (
CreateandUpdatefunctions inpkg/features/<resource>/service.go). - Add a migration:
config/migrations/postgresql/NNNN__add_COLUMN_to_RESOURCETABLE.yamlwithALTER TABLE ... ADD COLUMN IF NOT EXISTS ....
For date-only fields (OpenAPI format: date), use a DateOnly-equivalent type — NOT time.Time, which marshals to RFC3339 with a time component.
If any step is skipped, the field exists in the DB but is unreachable from the API. That's the failure mode this rule prevents.
Sub-procedures
Add a column
Run the six DTO-completeness steps above. Smoke:
Commit:
Add a Lucene filter clause
Edit pkg/features/${RESOURCE}/service.go — the List method. Pass the user-supplied Lucene string directly to storage.Search(...) — the adapter parses and evaluates it. Do not call mql.NewParser in the service layer; only use it if you need in-process AST evaluation (validation, transformation, etc.). Add a test case to service_test.go exercising the new clause. Commit:
Add a role guard to a subroute
Edit pkg/routes/${RESOURCE}/routes.go. Wrap the protected subset:
Add a test asserting 403 Forbidden for a request whose JWT lacks ${ROLE}. Commit:
Add soft-delete
- Apply DTO-completeness for
deleted_at *time.Time(DB struct only — not in Create/Update DTOs, not user-settable). - In
pkg/features/${RESOURCE}/service.go:
ListandGet: addWHERE deleted_at IS NULLto the storage query.Delete: replace the hard delete withUPDATE ... SET deleted_at = now() WHERE id = $1.
- Migration:
ALTER TABLE ... ADD COLUMN IF NOT EXISTS deleted_at timestamptz. - Add a test asserting
Listexcludes soft-deleted rows.
Commit: feat: add soft-delete to ${RESOURCE}.
Swap storage adapter
- Read current adapter from
viper.GetString("storage.type")inconfig/default.yaml. - Copy the new adapter snippet from
templates/adapter/${NEW}.snippet.go(if helper code is needed) intocmd/orpkg/features/<resource>/. - Update the viper config keys — use the real config shape:
storage.type: ${NEW}(one ofmemory,sql,cosmosdb,dynamodb) plus connection details as a flat map understorage.config.*(e.g.storage.config.host,storage.config.port,storage.config.schema). Do not use the oldstorage.<type>.hostnested style —GetInstancetakesviper.GetStringMapString("storage.config"). go mod tidy && go vet ./... && go build ./....- If the new adapter is
dynamodborcosmos, double-check that the storage queries don't use SQL-specific syntax —magic/storageadapter contracts abstract this, but custom predicates may need adaptation.
Commit: feat: swap storage adapter to ${NEW}.
Bail conditions
- The target file imports nothing from
magic/*→ abort, tell the user. - Multiple resources need the same change → run this cast per resource (don't batch).
- The user asks for a change outside these five sub-procedures → tell them: "That's outside
tweaking-a-cast's sub-procedure set; either describe it as one of {add column, add filter, add guard, add soft-delete, swap adapter} or implement it directly."
Capability boundary
Tweaks stay inside the in-bounds surface. If a tweak would require importing a project-specific common library or middleware, that's a sign the modification is out of scope for spellcasting — point the user at magic-capabilities to find an in-bounds equivalent or punt the change for them to make by hand.
Doc references
storage.StorageAdapter.Search(Lucene passthrough, canonical): https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdaptermql.NewParser(in-process AST parsing only): https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/mql#NewParserstorage.StorageAdapterFactory.GetInstance(adapter construction): https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapterFactory.GetInstancemiddlewares.RequireRole: https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#RequireRole- Migration shape (reference): https://github.com/tink3rlabs/todo-service/tree/main/config/migrations/postgresql
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/tweaking-a-cast/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/lutherwaves/spellcasting/tweaking-a-cast)