agentleFS
kumaran-iskumaran-is/claude-code-onboarding/.claude/skills/agentic-ai-coding-standard/SKILL.md

agentic-ai-coding-standard

Skill36 starsChanged 6 months agoMITView on GitHub

This skill provides coding standards for Python agentic AI services with LangChain/LangGraph. Use when reviewing or writing Python agentic AI code. Covers state management, tool definitions, graph structure, error handling, and observability.

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Iron Law: Always consult the agentic-ai-dev skill and its MCP sources before writing agent code.

    line 15
  2. Very specific:

    Import errors: Verify LangChain/LangGraph package versions match pyproject.toml constraints.

    line 107
  3. Very specific:

    State type mismatches: Ensure all graph state fields use TypedDict with proper Annotated types — never dict[str, Any].

    line 109
  4. Very specific:

    Graph recursion errors: Check recursion_limit in config and verify iteration_count is incremented in routing functions.

    line 111

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Iron Law: Always consult the agentic-ai-dev skill and its MCP sources before writing agent code; never generate LangGraph/LangChain patterns from memory.

Agentic AI Coding Standards

Mandatory coding standards for all Python agentic AI services using LangChain, LangGraph, and FastAPI.

Key Rules

#RuleStandard
1State typingAlways TypedDict; never dict[str, Any]
2Message listsAnnotated[list[BaseMessage], add_messages]
3Loop protectioniteration_count in state + max check in routing function
4Tool functions@tool + docstring + try/except + return strings
5LLM instantiationFactory function; never inline ChatAnthropic() in nodes
6Temperature0 for factual; 0.7 only for creative tasks
7CheckpointingPostgresSaver in production; MemorySaver only in tests
8Error handlingLog + return error state; never swallow exceptions
9Namingbuild_<name>_agent(), <verb>_node(), <Name>State
10Configpydantic-settings with fail-fast; no os.getenv() with silent defaults
11Type hintsmypy --strict; Literal for routing return types
12Asyncasync def for all I/O; ainvoke/astream in API routes
13Loggingstructlog with agent_name, thread_id, node_name context
14SecretsNever log API keys; redact PII before logging
15TestingBasic invoke + tool usage + iteration limit + error recovery
16CostTrack tokens; configure budget caps; use cheapest viable model
17ImportsGroup: stdlib → third-party → langchain/langgraph → local

Import Ordering

# 1. Standard library
from __future__ import annotations
import json
from typing import Annotated, Literal

# 2. Third-party
from fastapi import APIRouter, Depends
from pydantic import BaseModel, Field

# 3. LangChain / LangGraph
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from langchain_core.tools import tool
from langgraph.graph import END, StateGraph
from langgraph.graph.message import add_messages

# 4. Local
from ..core.config import settings
from ..core.logging import get_logger

Naming Conventions

ElementPatternExample
State<Name>StateAgentState, RAGState, MultiAgentState
Graph builderbuild_<name>_agent()build_react_agent(), build_rag_agent()
Node function<verb>_node()agent_node(), retrieve_node(), grade_node()
Tool function<verb>_<noun>()search_web(), query_database(), calculate_cost()
Provider factoryLLMProviderFactorySingleton, injected via Depends()
ConfigSettingspydantic-settings, singleton settings instance
Exception<Name>ErrorAgentError, ToolError, LLMProviderError

File Structure

src/<service>/
├── agents/
│   ├── graphs/          # build_*_agent() functions
│   ├── nodes/           # *_node() functions
│   ├── tools/           # @tool functions
│   └── state.py         # TypedDict state schemas
├── rag/                 # RAG-specific code
├── memory/              # Checkpointing + semantic memory
├── guardrails/          # Input/output validation
├── llm/providers.py     # LLM factory
├── core/
│   ├── config.py        # pydantic-settings
│   ├── logging.py       # structlog setup
│   └── exceptions.py    # Exception hierarchy
├── observability/       # Metrics + tracing
├── models/schemas.py    # Pydantic request/response
├── api/routes/          # FastAPI routes
└── main.py              # FastAPI app + lifespan

Reference

For concrete code examples and anti-patterns, Read reference/agentic-standards-examples.md.

Error Handling

Import errors: Verify LangChain/LangGraph package versions match pyproject.toml constraints.

State type mismatches: Ensure all graph state fields use TypedDict with proper Annotated types — never dict[str, Any].

Graph recursion errors: Check recursion_limit in config and verify iteration_count is incremented in routing functions.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.