소스 정보
- 저장소
- tomevault-io/skills-registry
- 최근 소스 활동
- 2026년 7월 3일 19:45
- 감지된 SKILL.md 언어
- 영어
- 스타
- 0
- 포크
- 0
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/tomevault-io/skills-registry --skill lambda-go-lazy-init-segregated명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | lambda-go-lazy-init-segregated |
| description | >- Use when this capability is needed. |
AWS Lambda's
best practices say verbatim:
"Initialize SDK clients and database connections outside of the function handler … Subsequent
invocations processed by the same instance of your function can reuse these resources." True — but
the language-neutral doc stops short of the Go-specific refinement: in Go, anything you initialize
during INIT (an init() block or an eager package-level global) runs unconditionally on every cold
start, on every code path. init() cascades across all imported packages. So a Mongo connection
opened in init() taxes 100% of cold starts even if 70% of invocations never touch Mongo.
The fix: defer each expensive client behind its own sync.Once, grouped by temporal locality of
use — not one initAll().
init() (or an eager global) opening a database/Mongo connection or constructing a client
the common path doesn't use.init().Announce on invoke: "Using lambda-go-lazy-init-segregated to split sync.Once by usage path so the happy path doesn't pay cold-start for unused clients."
aws.Config itself is cheap — load it once (globally or behind one sync.Once).serviceX.NewFromConfig(cfg) is cheap-ish; a Mongo dial or a TLS handshake to a slow
upstream is the expensive part.sync.Once by which branch needs the client together, not "all infra clients in one Once."sync.Once.Do guarantees exactly-once, goroutine-safe, lazy execution — the idiomatic deferral
primitive.Example shape: an inbound-federation handler with 3 clients (an identity provider, EventBridge,
Mongo) across 2 segregated Once values. The most common branch — a brand-new federated
sign-up with no candidate to reconcile — initializes only the identity-provider client, never
Mongo or EventBridge.
Java/Python/.NET have SnapStart, which snapshots a pre-initialized environment so eager init is effectively free. Go has no SnapStart. Every cold start re-runs INIT from scratch, so segregated lazy init is the primary lever for Go cold-start cost. (If you do use Provisioned Concurrency, INIT runs during pre-warm and the value diminishes — this pattern matters most for on-demand Lambdas with bursty traffic and seldom-used branches.)
package main
import (
"context"
"sync"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
"github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
"go.mongodb.org/mongo-driver/v2/mongo"
)
// aws.Config: loaded once, cheap. Shared by all service clients.
var (
cfgOnce sync.Once
awsCfg aws.Config
)
func loadAWSConfig(ctx context.Context) aws.Config {
cfgOnce.Do(func() {
c, err := config.LoadDefaultConfig(ctx)
if err != nil {
panic(err) // init failure: fail fast, structured error to Lambda
}
awsCfg = c
})
return awsCfg
}
// Once #1 — identity path. Every invocation needs the IdP client (cheap).
var (
idpOnce sync.Once
idpClient *cognitoidentityprovider.Client
)
func initIdentity(ctx context.Context) {
idpOnce.Do(func() { idpClient = cognitoidentityprovider.NewFromConfig(loadAWSConfig(ctx)) })
}
// Once #2 — data-plane path. Mongo dial is EXPENSIVE; only the reconcile branch pays it.
var (
dataOnce sync.Once
ebClient *eventbridge.Client
mongoClient *mongo.Client
)
func initDataPlane(ctx context.Context) {
dataOnce.Do(func() {
ebClient = eventbridge.NewFromConfig(loadAWSConfig(ctx))
mongoClient = connectMongo(ctx)
})
}
(MyResp, ) {
initIdentity(ctx)
needsReconcile(e) {
initDataPlane(ctx)
}
doWork(ctx, e)
}
{ lambda.Start(handler) }
func initAll() or one sync.Once that constructs every client.init() calling connectMongo(...), sql.Open(...), or any dial unconditionally.var mongoClient = mustConnect() outside any Once/branch.sync.Once shared across two branches that never co-occur.Once.sync.Once, called inside that branch only.global-skills/aws-go/lambda-go-refactor-purge-audit/SKILL.md — when a branch (and its client) is
removed, go mod tidy purges the module; audit the now-dead IAM actions.global-skills/aws-go/aws-sdk-go-v2-version-policy/SKILL.md — share one aws.Config; construct
each chosen service client with NewFromConfig.Last verified: 2026-06-03 against the AWS Lambda best-practices guide (live — "Initialize SDK
clients and database connections outside of the function handler"), sync.Once semantics, and
aws-lambda-go/lambda v1.54.0 (lambda.Start). Go has no SnapStart, confirmed against the
SnapStart docs (Java/Python/.NET only).
Re-check after: AWS SDK Go v2 major / CDK CLI major, or by 2026-09-03. Decay risk: low (the
INIT-phase cost model and sync.Once are stable primitives).
Found a drift? Run /skill-pattern-freshness-audit aws-go.
Source: esaldgut/ai-native-engineering-workspace — distributed by TomeVault.