mdc-openai

A guide to building applications with the OpenAI API, including prompts, reliable client code, agents, and tests. The OpenAI API lets software send requests to OpenAI models and use their responses.

In plain words
What is it for?
Use it when designing prompts, function-calling agents, API clients, or tests for OpenAI-based software.
Why use it?
It provides practical rules for making model requests clearer, safer, and more dependable.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/graycodeai/starling/mdc-openai
Any agent
npx skills add GrayCodeAI/starling --skill mdc-openai
Clone the repo
git clone --depth 1 https://github.com/GrayCodeAI/starling

Made for: Claude Code, Codex.

Per session 35 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,277 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00035 $0.02277
Opus 5 $0.00017 $0.01138
Sonnet 5 $0.00007 $0.00455
Haiku 4.5 $0.00003 $0.00228

Measured 2d ago against content hash 5d21ceccbbff, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

mdc-openai scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks the agent to reveal its instructionsmediumSystem prompt leakage

Directions to print, repeat or translate the system prompt extract configuration the operator did not intend to expose.

# This assumes get_response_good is adapted for keyword extraction with JSON output prompt = f"""Extract 3-5 keywords from the following text as a JSON array.
categories/ai-ml/mdc-openai/SKILL.md · 286 lines

How it starts

The opening of the file, as written. The whole thing — 286 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Text 3: {user_text} Keywords 3:"""

response = client.chat.completions.create( model="gpt-4o", messages=[{"role": "user", "content": few_shot_prompt}] )


#### 2.1.6 Role/Persona and Constraints

Define the AI's role and explicitly state what it should *not* do.

❌ **BAD**: Only negative constraints
```python
system_message = "DO NOT MENTION PRICES. DO NOT BE OVERLY FORMAL."

GOOD: Clear role, positive instructions, and specific constraints

system_message = """You are a friendly, helpful customer support agent for a SaaS product.
Your goal is to diagnose user issues and suggest solutions.
NEVER ask for Personally Identifiable Information (PII) like passwords or credit card numbers.
Instead, refer users to our secure help portal at `https://support.example.com/security`.
"""

2.2 Agent Design

For building autonomous agents, follow OpenAI's "Practical Guide to Building Agents" framework.

2.2.1 Core Components

Agents require:

  1. Model: The LLM for reasoning and decision-making.
  2. Tools: External functions/APIs the agent can use.
  3. Instructions: Explicit guidelines and guardrails.
2.2.2 Function Calling

Use function calling for agents to reliably interact with external tools and APIs. Define tools with clear schemas.

from openai import OpenAI
import json

client = OpenAI()

def get_current_weather(location: str, unit: str = "fahrenheit") -> str:
    """Get the current weather in a given location"""
    # In a real app, this would call an external weather API
    if "san francisco" in location.lower():
        return json.dumps({"location": location, "temperature": "72", "unit": unit})
    return json.dumps({"location": location, "temperature": "unknown"})

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_current_weather",
            "description": "Get the current weather in a given location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "The city and state, e.g. San Francisco, CA",
                    },
                    "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
                },
                "required": ["location"],
            },
        },
    }
]

def run_agent_with_tool(user_message: str):
    messages = [{"role": "user", "content": user_message}]
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=messages,
        tools=tools,
        tool_choice="auto", # Let the model decide if it needs to call a tool
    )
    response_message = response.choices[0].message

    if response_message.tool_calls:
        tool_call = response_message.tool_calls[0]
        function_name = tool_call.function.name
        function_args = json.loads(tool_call.function.arguments)
        
        if function_name == "get_current_weather":
            function_response = get_current_weather(**function_args)
            messages.append(response_message) # Extend conversation with assistant's reply
            messages.append(
                {
                    "tool_call_id": tool_call.id,
                    "role": "tool",
                    "name": function_name,
                    "content": function_response,
                }
            )
            second_response = client.chat.completions.create(
                model="gpt-4o",
                messages=messages,
            )
            return second_response.choices[0].message.content
    return response_message.content

# Example usage:

Read the full file on GitHub · 286 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 286 lines · 35 tokens per session scan B 5d21ceccbbff

Subscribe to this mod's changes

mdc-openai is a skill published in the GitHub repository GrayCodeAI/starling (2 stars, last pushed 3d ago), licensed MIT. It adds 35 tokens to every session and 2,277 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (asks the agent to reveal its instructions). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories