| name | magic-capabilities |
| description | Use when a cast needs to verify whether a package, type, or middleware exists in github.com/tink3rlabs/magic — the in-bounds surface for spellcasting templates |
magic-capabilities
The authoritative answer to "is X available in github.com/tink3rlabs/magic?". Pinned to v0.17.3. If your magic is newer, prefer upstream and note the drift in your cast output.
NOTE — reconciled against real magic v0.17.3 source on 2026-05-29. Three major corrections vs. previous content:
storage.NewStorageAdapter() does not exist → use storage.StorageAdapterFactory{}.GetInstance(type, configMap).
mql.Parse(string) does not exist → use mql.NewParser(input).Parse(); but service layers should pass raw Lucene to storage.Search, not call the parser directly.
- Migration YAML has no
id: field — the numeric ID is encoded in the filename prefix (0001__create_RESOURCETABLE.yaml). YAML fields are description: + migrations: [{migrate: ..., rollback: ...}].
Why this skill exists
Every cast template references only what's in this surface. If a generated file imports a package not listed here — or imports anything from a project-specific common library that wraps magic — the cast has failed. Revert and use an in-bounds equivalent.
Package surface (v0.17.3)
github.com/tink3rlabs/magic/storage
Adapter type constants (pass to StorageAdapterFactory.GetInstance):
| Constant | Value |
|---|
storage.MEMORY | in-process map; no persistence |
storage.SQL | PostgreSQL / MySQL via database/sql |
storage.COSMOSDB | Azure Cosmos DB |
storage.DYNAMODB | AWS DynamoDB |
Config shape (config/default.yaml):
storage:
type: memory
config:
schema: myservice
host: localhost
port: "5432"
Symbols:
| Symbol | Kind | Signature / Use | Doc |
|---|
StorageAdapterFactory | struct | Factory; use {}.GetInstance(...) | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapterFactory |
StorageAdapterFactory.GetInstance | method | GetInstance(t StorageAdapterType, config map[string]string) (StorageAdapter, error) — constructs adapter from type constant + flat config map | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapterFactory.GetInstance |
StorageAdapterType | type | string alias; cast with storage.StorageAdapterType(viper.GetString("storage.type")) | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapterType |
StorageAdapter | interface | Common adapter contract implemented by every backend | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.List | method | List(dest any, sortKey string, filter map[string]any, limit int, cursor string, params ...map[string]any) (string, error) — returns next cursor | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.Search | method | Search(dest any, sortKey string, query string, limit int, cursor string, params ...map[string]any) (string, error) — accepts raw Lucene string; adapter parses and evaluates | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.Get | method | Get(dest any, filter map[string]any, params ...map[string]any) error | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.Create | method | Create(value any, params ...map[string]any) error | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.Update | method | Update(value any, filter map[string]any, params ...map[string]any) error | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
StorageAdapter.Delete | method | Delete(value any, filter map[string]any, params ...map[string]any) error | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#StorageAdapter |
NewDatabaseMigration | func | NewDatabaseMigration(adapter StorageAdapter) *DatabaseMigration — build a migration runner | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage#NewDatabaseMigration |
ConfigFs | var (embed.FS) | Set by main.go to expose embedded config/ to migrations | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/storage |
NewStorageAdapter does not exist — this is a common error in older docs. Always use StorageAdapterFactory{}.GetInstance.
github.com/tink3rlabs/magic/middlewares
| Symbol | Kind | Use | Doc |
|---|
EnsureValidToken | func | chi middleware: JWT validation via OIDC JWKS | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#EnsureValidToken |
EnsureValidTokenConfig | struct | {Enabled, IssuerURL, Audience, AllowedClockSkew} | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#EnsureValidTokenConfig |
SetDefaultClaimsConfig | func | Configure custom JWT claim keys (tenant, email, roles, groups) | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#SetDefaultClaimsConfig |
ClaimsConfig | struct | {TenantIdKey, EmailKey, RolesKey, GroupsKey} | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#ClaimsConfig |
RequireRole | func | chi middleware factory: 403 unless JWT roles[] contains one of roles... | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#RequireRole |
TenantRequestContext | middleware | Extracts tenant_id from JWT, puts on context.Context | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#TenantRequestContext |
UserRequestContext | middleware | Extracts email/groups from JWT, puts on context | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#UserRequestContext |
ErrorHandler | struct | Wrap(func(w,r) error) adapter that maps magic/errors types to HTTP status codes | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#ErrorHandler |
ObservabilityWithOptions | middleware | Per-request HTTP metrics + trace spans, with SkipPaths/SkipPathPrefixes | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#ObservabilityWithOptions |
ObservabilityOptions | struct | {SkipPaths, SkipPathPrefixes} | https://pkg.go.dev/github.com/tink3rlabs/magic@v0.17.3/middlewares#ObservabilityOptions |
github.com/tink3rlabs/magic/observability
github.com/tink3rlabs/magic/health
github.com/tink3rlabs/magic/leadership
github.com/tink3rlabs/magic/mql
mql.Parse(string) does not exist — use mql.NewParser(input).Parse().
Preferred pattern: service layers pass the raw Lucene string directly to storage.Search(...) and let the adapter parse and evaluate it. Only call mql.NewParser when you need in-process AST evaluation (e.g. to validate, transform, or inspect the query before sending it to storage).
github.com/tink3rlabs/magic/errors
github.com/tink3rlabs/magic/logger
github.com/tink3rlabs/magic/pubsub
todo-service shape (reference layout for casting-a-new-service)
Hard boundary — out-of-bounds for every cast
If a generated file imports or names any of the following categories, the cast has failed:
- Any project-specific "common" library (request loggers, rate limiters, audit middleware, cache middleware, default-tenant overrides, admin overrides) that lives outside
github.com/tink3rlabs/magic
- Any custom storage bootstrap wrapper that hides
storage.StorageAdapterFactory{}.GetInstance(...) / storage.NewDatabaseMigration(...).Migrate()
- Any per-resource ACL authorizer beyond
middlewares.RequireRole
- Any encryption-at-rest wrapper not provided by magic
In-bounds equivalents for common needs:
| You might want | In-bounds option |
|---|
| Structured request logging | chi's middleware.Logger, or magic's slog handler |
| Rate limiting | not in v0.1; user adds after the cast |
| Audit logging | not in v0.1; user adds after the cast |
| Response caching | not in v0.1; user adds after the cast |
| Tenant context on every request | middlewares.TenantRequestContext |
| Storage bootstrap + migrations | storage.StorageAdapterFactory{}.GetInstance(type, configMap) + storage.NewDatabaseMigration(adapter).Migrate() |
| Role-based authorization | middlewares.RequireRole |
| Per-resource ACL | not in v0.1; user adds after the cast |
Drift protocol
When magic cuts a new tag:
- Bump the
Pinned to **v0.17.3** line at the top of this skill body.
- Re-fetch each
pkg.go.dev URL; any 404 → that symbol was renamed or removed; reconcile with upstream.
- Add any new exported types/funcs that templates would reference.
- If a magic constructor name changed (e.g.
storage.StorageAdapterFactory{}.GetInstance → something else), update templates/service/cmd/server.go to match.
v0.1 is manually maintained. v0.2+ may auto-generate from go doc -all.