Community생산성 & 협업github.com

firebase/developing-genkit-go

Genkit을 사용하여 Go로 AI 기반 애플리케이션을 개발합니다. 사용자가 Genkit을 이용한 Go 기반 AI 기능, 에이전트, 플로우 또는 도구 생성을 요청하거나, 생성, 프롬프트, 스트리밍, 도구 호출, 모델 제공자를 포함하는 Genkit Go 코드 작업 시 사용합니다.

developing-genkit-go란 무엇인가요?

이 스킬은 Google의 Genkit 프레임워크를 활용하여 Go 언어로 AI 기반 애플리케이션을 구축하는 방법을 제공합니다. 사용자가 AI 기능, 에이전트, 플로우 또는 도구를 Go로 개발해야 할 때, 또는 Genkit Go 코드 내에서 생성, 프롬프트, 스트리밍, 도구 호출, 모델 제공자와 관련된 작업을 수행해야 할 때 사용됩니다. Genkit은 모델 제공자(예: Google Generative AI, Vertex AI, Ollama)와의 통합을 단순화하고, 프롬프트 템플릿, 체인, 에이전트, 도구 검증을 위한 내장 기능을 제공합니다. 이 스킬은 다양한 플랫폼(Claude Code, Cursor, Codex 등)에서 호환되며, 로컬 개발 환경에서의 빠른 프로토타이핑과 프로덕션 배포를 모두 지원합니다. Genkit의 핵심 개념인 플로우(Flow)는 상태 관리와 관찰 가능성을 내장하여 복잡한 AI 워크플로우를 안정적으로 구축할 수 있게 해줍니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/firebase/agent-skills/tree/main/skills/developing-genkit-go

Installed? Explore more 생산성 & 협업 skills: steipete/gemini, steipete/gh-issues, steipete/skill-creator · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

developing-genkit-go은(는) 무엇을 하나요?

Genkit을 사용하여 Go로 AI 기반 애플리케이션을 개발합니다. 사용자가 Genkit을 이용한 Go 기반 AI 기능, 에이전트, 플로우 또는 도구 생성을 요청하거나, 생성, 프롬프트, 스트리밍, 도구 호출, 모델 제공자를 포함하는 Genkit Go 코드 작업 시 사용합니다.

개요

Genkit는 Google이 개발한 오픈소스 프레임워크로, Go 언어로 AI 기반 애플리케이션을 구축할 때 사용합니다. 이 스킬은 Genkit Go SDK 작업 시 안내를 제공합니다.

주요 개념

  • Flows (플로우): Genkit 애플리케이션의 핵심 단위로, 프롬프트, 도구 호출, 데이터 처리를 결합한 함수입니다. 플로우는 관찰 가능성(observability)과 오류 처리를 내장하고 있습니다.
  • Models (모델): Genkit은 Google Generative AI (googleAI), Vertex AI (vertexAI), Ollama (ollama) 등 여러 모델 제공자를 지원합니다.
  • Tools (도구): AI 모델이 외부 API, 데이터베이스 또는 함수를 호출할 수 있게 해주는 함수입니다.
  • Prompts (프롬프트): Genkit은 프롬프트 템플릿을 지원하며, Dotprompt 형식을 사용하여 프롬프트를 정의하고 관리할 수 있습니다.
  • Streaming (스트리밍): 부분적인 출력 청크를 실시간으로 스트리밍하여 사용자에게 점진적인 응답을 제공합니다.

설치 및 설정

전제 조건

  • Go 1.22 이상
  • Genkit CLI (선택 사항이지만 권장): go install github.com/firebase/genkit-tools/cmd/genkit-cli@latest

프로젝트 초기화

go mod init my-genkit-app

Genkit Go 패키지 설치

go get github.com/firebase/genkit/go/ai
go get github.com/firebase/genkit/go/plugins/googleai
go get github.com/firebase/genkit/go/plugins/vertexai
go get github.com/firebase/genkit/go/plugins/ollama
go get github.com/firebase/genkit/go/flow

기본 사용 예

간단한 생성 호출

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/googleai"
)

func main() {
	ctx := context.Background()

	// 환경 변수 GOOGLE_API_KEY 설정 필요
	g, err := genkit.Init(ctx, genkit.WithPlugins(&googleai.GoogleAI{}))
	if err != nil {
		log.Fatal(err)
	}

	model := googleai.Model(g, "gemini-2.0-flash")

	resp, err := ai.Generate(ctx, model, ai.WithTextPrompt("인공지능에 대한 농담을 해줘"))
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(resp.Text())
}

도구가 있는 플로우

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"net/http"
	"net/url"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/googleai"
)

// 날씨 도구 정의
type WeatherInput struct {
	Location string `json:"location"`
}

var weatherTool = ai.DefineTool(
	"getWeather",
	"지정된 위치의 현재 날씨를 가져옵니다",
	func(ctx context.Context, input WeatherInput) (string, error) {
		// 실제 구현에서는 날씨 API 호출
		return fmt.Sprintf("%s의 날씨: 맑음, 22°C", input.Location), nil
	},
)

func main() {
	ctx := context.Background()

	g, err := genkit.Init(ctx,
		genkit.WithPlugins(&googleai.GoogleAI{}),
		genkit.WithTools(weatherTool),
	)
	if err != nil {
		log.Fatal(err)
	}

	model := googleai.Model(g, "gemini-2.0-flash")

	resp, err := ai.Generate(ctx, model,
		ai.WithTextPrompt("서울의 날씨는 어떤가요?"),
	)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(resp.Text())
}

스트리밍을 포함한 플로우

package main

import (
	"context"
	"fmt"
	"log"

	"github.com/firebase/genkit/go/ai"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/googleai"
)

func main() {
	ctx := context.Background()

	g, err := genkit.Init(ctx, genkit.WithPlugins(&googleai.GoogleAI{}))
	if err != nil {
		log.Fatal(err)
	}

	model := googleai.Model(g, "gemini-2.0-flash")

	// 스트리밍 호출
	stream, resp, err := ai.GenerateStream(ctx, model,
		ai.WithTextPrompt("1부터 10까지 숫자 세기"),
	)
	if err != nil {
		log.Fatal(err)
	}

	// 부분 청크 처리
	for chunk := range stream {
		fmt.Print(chunk.Text())
	}

	// 최종 응답 처리
	fmt.Println()
	fmt.Println("최종 응답:", resp.Text())
}

모델 제공자 설정

Google Generative AI (Gemini)

환경 변수 설정:

export GOOGLE_API_KEY="your-api-key"

Vertex AI (Google Cloud)

export GCLOUD_PROJECT="your-project-id"
export GOOGLE_APPLICATION_CREDENTIALS="path/to/service-account-key.json"

Ollama (로컬 모델)

# Ollama 설치 후 실행
export OLLAMA_HOST="http://localhost:11434"
ollama pull llama3.2

Genkit CLI 사용하기

Genkit CLI는 개발자 UI와 디버깅 기능을 제공합니다:

genkit start -- go run main.go

그러면 http://localhost:4000에서 Genkit 개발자 UI에 접속할 수 있습니다.

모범 사례

  1. 플로우 분리: 각각의 AI 기능을 별도의 플로우로 캡슐화합니다.
  2. 오류 처리: 플로우 내에서 오류 처리와 폴백(fallback)을 구현합니다.
  3. 프롬프트 템플릿: .prompt 파일 또는 DefinePrompt()를 사용하여 프롬프트를 별도 파일로 관리합니다.
  4. 도구 검증: 입력 스키마를 정의하여 도구에 전달되는 데이터를 검증합니다.
  5. 스트리밍: 긴 응답의 경우 사용자 경험 향상을 위해 스트리밍을 사용합니다.
  6. 환경 변수: API 키와 설정을 코드베이스에 하드코딩하지 않고 환경 변수를 사용합니다.

추가 자료

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

firebase/developing-genkit-dart

Generates code and provides documentation for the Genkit Dart SDK. Use when the user asks to build AI agents in Dart, use Genkit flows, or integrate LLMs into Dart/Flutter applications.

firebase/developing-genkit-js

Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.

firebase/developing-genkit-python

Develop AI-powered applications using Genkit in Python. Use when the user asks about Genkit, AI agents, flows, or tools in Python, or when encountering Genkit errors, import issues, or API problems.

firebase/firebase-ai-logic

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

firebase/firebase-ai-logic-basics

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

firebase/firebase-app-hosting-basics

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

firebase/firebase-auth-basics

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

firebase/firebase-basics

Provides foundational setup, authentication, and project management workflows for Firebase using the Firebase CLI. Use when checking Firebase CLI version (must use 'npx -y firebase-tools@latest --version'), initializing a Firebase environment, authenticating, setting active projects, or setting up `google-services.json` or `GoogleService-Info.plist` files.

firebase/firebase-crashlytics

Comprehensive guide for Firebase Crashlytics, including provisioning and SDK usage. Use this skill when the user needs help setting up Crashlytics, adding crash reporting, or using the Crashlytics SDK in their application.

firebase/firebase-data-connect

Builds and deploys Firebase SQL Connect (aka Firebase Data Connect) backends with PostgreSQL securely. Use when designing schemas with tables and relations, writing authorized queries and mutations, configuring real-time data updates, or generating type-safe SDKs. Use when you need a relational database with Firebase, or when the user mentions SQL Connect or Data Connect.

firebase/firebase-firestore

Sets up, manages, and executes queries against Cloud Firestore database instances, including advanced native full-text search and relational joins using pipelines. You MUST unconditionally activate this skill if you plan to use Firestore in any way. Use when listing or creating Firestore databases, configuring security rules, designing data models, writing client SDK queries (including search/joins), or checking indexes.

firebase/firebase-firestore-basics

Comprehensive guide for Firestore basics including provisioning, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore, writing security rules, or using the Firestore SDK in their application.

firebase/firebase-firestore-enterprise-native-mode

Comprehensive guide for Firestore enterprise native including provisioning, data model, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore Enterprise with the Native mode, writing security rules, or using the Firestore SDK in their application.

firebase/firebase-firestore-standard

Comprehensive guide for Firestore Standard Edition, including provisioning, security rules, and SDK usage. Use this skill when the user needs help setting up Firestore, writing security rules, or using the Firestore SDK in their application.

firebase/firebase-hosting-basics

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

firebase/firebase-local-env-setup

Bare minimum INITIAL setup for getting started with Firebase (Node.js, CLI installation, first-time login). Use ONLY for first-time setup. For updating, troubleshooting, or refreshing an existing environment, use the firebase-basics skill instead.

firebase/firebase-remote-config-basics

Comprehensive guide for Firebase Remote Config, including template management and SDK usage. Use this skill when the user needs help setting up Remote Config, managing feature flags, or updating app behavior dynamically.

firebase/firebase-security-rules-auditor

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

firebase/firestore-security-rules-auditor

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

firebase/xcode-project-setup

Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).

관련 스킬