--- name: ak-init description: > Scaffold a new Agent Kernel project from scratch. This skill guides you through choosing an agent framework, defining tools, selecting a deployment target, and generating a complete project with all necessary files. Designed for users who want to build a new AI agent using the Agent Kernel library. license: Apache-2.0 metadata: author: yaalalabs category: user --- # Scaffold an Agent Kernel Project Use this skill to create a new AI agent project powered by Agent Kernel. ## Instructions for the Agent When the user wants to create a new agent project, follow this interactive workflow: ### Step 1: Gather Requirements Ask the user the following questions (adapt based on context): 1. **Agent framework**: Which agent framework would you like to use? - **OpenAI Agents SDK** (recommended for most use cases — best tool support, handoffs between agents) - **CrewAI** (multi-agent collaboration with roles and tasks) - **LangGraph** (complex workflow graphs with state management) - **Google ADK** (Google's Agent Development Kit) - **Smolagents** (lightweight agent framework with managed-agent routing) - **Pydantic AI** (provider-agnostic — native OpenAI/Anthropic/Google/Bedrock/… support with `FallbackModel` failover) 2. **Agent purpose**: What should your agent(s) do? (e.g., "customer support bot", "code review assistant", "data analysis agent") 3. **Tools**: Does your agent need any custom tools? (e.g., "fetch weather data", "query a database", "search the web") 4. **Multi-agent**: Do you need multiple specialized agents with a triage/routing agent? 5. **Deployment mode**: How will you run the agent? - **CLI** (interactive terminal — great for development and testing) - **REST API** (FastAPI server — for web apps, webhooks, integrations) - **AWS Lambda** (serverless on AWS) - **AWS ECS/Fargate** (containerized on AWS) - **Azure Functions** (serverless on Azure) - **Azure Container Apps** (containerized on Azure) - **GCP Cloud Run Serverless** (scale-to-zero on GCP) - **GCP Cloud Run Containerized** (always-on on GCP) - **Docker** (generic container, runs anywhere) 6. **Session persistence**: How should conversation state be stored? - **In-memory** (default, no persistence — fine for CLI and development) - **Redis** (recommended for production — works with all deployment targets) - **DynamoDB** (AWS-native, recommended for AWS serverless) - **Cosmos DB** (Azure-native, recommended for Azure serverless) - **Firestore** (GCP-native, recommended for GCP Cloud Run) ### Step 2: Generate the Project Based on the answers, generate the following project structure: ``` / ├── pyproject.toml # Dependencies and project metadata ├── build.sh # Build script ├── config.yaml # Agent Kernel configuration ├── .py # Agent definition (demo.py, app.py, or lambda.py) ├── tool.py # Custom tool functions (if needed) ├── _test.py # Test file ├── README.md # Project documentation └── deploy/ # Deployment files (if cloud deployment selected) ├── main.tf ├── variables.tf ├── outputs.tf ├── terraform.tfvars ├── deploy.sh ├── Dockerfile # For containerized deployments └── backend.tf ``` ### Step 3: Generate File Contents #### pyproject.toml ```toml [project] name = "" version = "0.1.0" description = "" readme = "README.md" requires-python = ">=3.12" dependencies = [ "agentkernel[]>=0.9.5", ] [dependency-groups] dev = [ "agentkernel[test]>=0.9.5", "black>=23.0.0", "isort>=5.0.0", "mypy>=1.0.0", ] [tool.uv] package = false [tool.isort] profile = "black" line_length = 120 [tool.black] line-length = 120 target-version = ["py312"] ``` **Extras selection**: - CLI mode: `agentkernel[cli,]` - API mode: `agentkernel[,api]` - Smolagents framework extra: `smolagents` - Pydantic AI framework extra: `pydanticai` (installs the provider-agnostic `pydantic-ai-slim` core only — also add a provider, e.g. `pydantic-ai-slim[openai]`) - With messaging: add `slack`, `whatsapp`, etc. - With session store: add `redis`, `aws` (for DynamoDB), `azure` (for Cosmos DB) - With tracing: add `langfuse`, `openllmetry`, `logfire`, or `cloudwatch` #### Agent definition file **For OpenAI framework (CLI mode)**: ```python from agentkernel.cli import CLI from agentkernel.openai import OpenAIModule, OpenAIToolBuilder from agents import Agent # Import custom tools if needed # from tool import my_tool # Define specialized agents = Agent( name="", instructions="", # tools=OpenAIToolBuilder.bind([my_tool]), # if tools needed ) # Define triage agent (if multi-agent) triage_agent = Agent( name="triage", instructions="You determine which agent to use based on the user's question.", handoffs=[], ) # Register with Agent Kernel OpenAIModule([triage_agent, ]) if __name__ == "__main__": CLI.main() ``` **For OpenAI framework (API mode)**: ```python from agentkernel.api import RESTAPI from agentkernel.openai import OpenAIModule from agents import Agent = Agent( name="", instructions="", ) OpenAIModule([]) if __name__ == "__main__": RESTAPI.run() ``` **For OpenAI framework (AWS Lambda)**: ```python from agentkernel.aws import Lambda from agentkernel.openai import OpenAIModule from agents import Agent = Agent( name="", instructions="", ) OpenAIModule([]) handler = Lambda.handler ``` **For LangGraph framework**: ```python from agentkernel.cli import CLI # or RESTAPI, Lambda from agentkernel.langgraph import LangGraphModule from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent model = ChatOpenAI(model="gpt-4o-mini", temperature=0.0) = create_react_agent( name="", tools=[], model=model, prompt="", ) LangGraphModule([]) if __name__ == "__main__": CLI.main() ``` **For CrewAI framework**: ```python from agentkernel.cli import CLI # or RESTAPI, Lambda from agentkernel.crewai import CrewAIModule from crewai import Agent = Agent( role="", # role= is the agent identifier in Agent Kernel goal="", backstory="", verbose=False, ) # Pass agents directly — Agent Kernel builds the Crew and Task internally per run CrewAIModule([]) if __name__ == "__main__": CLI.main() ``` **For Google ADK framework**: ```python from agentkernel.cli import CLI # or RESTAPI, Lambda from agentkernel.adk import GoogleADKModule from google.adk.agents import Agent = Agent( name="", model="gemini-2.0-flash", instruction="", ) GoogleADKModule([]) if __name__ == "__main__": CLI.main() ``` **For Smolagents framework**: ```python from agentkernel.cli import CLI # or RESTAPI, Lambda from agentkernel.smolagents import SmolagentsModule, SmolagentsToolBuilder from smolagents import LiteLLMModel, ToolCallingAgent model = LiteLLMModel(model_id="openai/gpt-4o") = ToolCallingAgent( tools=SmolagentsToolBuilder.bind([]), model=model, name="", description="", ) SmolagentsModule([]) if __name__ == "__main__": CLI.main() ``` **For Pydantic AI framework**: ```python from agentkernel.cli import CLI # or RESTAPI, Lambda from agentkernel.pydanticai import PydanticAIModule, PydanticAIToolBuilder from pydantic_ai import Agent # Provider-agnostic: swap the model string for "anthropic:...", "google-gla:...", etc. # (install the matching provider extra, e.g. pydantic-ai-slim[anthropic]). = Agent( model="openai:gpt-4o-mini", name="", # required — AK registers agents by name eagerly description="", # set it — AK reports this as the agent description / A2A summary instructions="", tools=PydanticAIToolBuilder.bind([]), ) PydanticAIModule([]) if __name__ == "__main__": CLI.main() ``` #### Custom tools (tool.py) ```python from agentkernel.core import ToolContext def () -> str: """""" # Access session context if needed: # context = ToolContext.get() # session = context.session # Tool implementation return "" ``` For OpenAI framework, bind tools using: `tools=OpenAIToolBuilder.bind([])` For other frameworks, use their native tool binding mechanism. #### config.yaml ```yaml # Session configuration (if not in-memory) session: type: redis # redis | dynamodb | cosmosdb cache: 256 # LRU cache size (optional) redis: prefix: "ak::" url: "redis://localhost:6379" # Tracing (optional) # trace: # enabled: true # type: langfuse # langfuse | openllmetry | logfire | cloudwatch ``` #### test-config.yaml Test harness configuration is **not** part of `config.yaml` — it lives in its own file, loaded only when tests run (a `test:` section left in `config.yaml` is ignored): ```yaml mode: score # score | llm | fallback (default: fallback) ``` #### build.sh ```bash #!/bin/bash uv venv && uv sync ``` #### Test file ```python import pytest import pytest_asyncio from agentkernel.test import Test pytestmark = pytest.mark.asyncio(loop_scope="session") @pytest_asyncio.fixture(scope="session", loop_scope="session") async def test_client(): test = Test(".py") await test.start() try: yield test finally: await test.stop() @pytest.mark.order(1) async def test_basic_response(test_client): await test_client.send("") await test_client.expect([""]) ``` ### Step 4: Provide Setup Instructions After generating the project, tell the user: 1. Set the required API key as environment variable: - OpenAI: `export OPENAI_API_KEY=sk-...` - Google: `export GOOGLE_API_KEY=...` 2. Run `chmod +x build.sh && ./build.sh` to set up the environment 3. Activate: `source .venv/bin/activate` 4. Run: `python .py` 5. For tests: `uv run pytest` --- ### What to Do Next Your project is scaffolded and running. Here's the natural progression: - **Add tools & agents** → Use the `ak-build` skill to add new tools, specialist agents, and handoffs to your project. This is the skill you'll use most often as you iterate. - **Add guardrails or tracing** → Use the `ak-add-capabilities` skill to add input/output guardrails, observability tracing, session persistence, MCP, A2A, hooks, or multimodal support. - **Connect a messaging platform** → Use the `ak-add-integration` skill to add Slack, WhatsApp, Telegram, or other messaging channels. - **Deploy to cloud** → Use the `ak-cloud-deploy` skill to deploy to AWS or Azure with Terraform. - **Set up testing** → Use the `ak-test` skill to configure test modes and write agent tests.