Back to Prompt Library
implementation

Initial Claude Agent Setup and Tool Definition

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Autonomous Cloud Security Triage Agent

Format
Code-aware
Lines
32
Sections
8
Linked challenge
Autonomous Cloud Security Triage Agent

Prompt source

Original prompt text with formatting preserved for inspection.

32 lines
8 sections
No variables
1 code block
Set up a basic Claude agent using the Claude Agents SDK. Define two simple tools: `get_instance_metadata(instance_id: str)` returning instance tags and `threat_intel_lookup(hash: str)` returning known threats. Configure the agent to use Claude Opus 4.1. Write a test case where the agent receives a high CPU alert and needs to use these tools to gather context.

```python
# agent_main.py
from anthropic import Anthropic
from anthropic_agents import Agent, tool

anthropic_client = Anthropic()

@tool
def get_instance_metadata(instance_id: str) -> str:
    """Gets metadata like tags for a given cloud instance ID."""
    # Simulate API call
    if instance_id == "i-abcdefg123":
        return "tags: prod, web-server"
    return "No metadata found."

@tool
def threat_intel_lookup(hash: str) -> str:
    """Looks up a file hash in threat intelligence databases."""
    # Simulate API call
    if hash == "malicious_process.sh_hash":
        return "Known cryptocurrency miner identified."
    return "No threat found for this hash."

agent = Agent(
    client=anthropic_client,
    model="claude-3-opus-20240229", # Or newer model if available
    tools=[get_instance_metadata, threat_intel_lookup],
    system_prompt="You are a cloud security analyst. Analyze alerts, use tools, and provide classification and remediation."
)

async def run_triage(alert: str):
    response = await agent.run(alert)
    print(response.content)

# Example usage:
# asyncio.run(run_triage("High CPU alert on instance i-abcdefg123. Suspicious process 'malicious_process.sh' detected."))
```

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.