Back to Prompt Library
implementation

Initialize Claude Agent with Custom Tools

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

Linked challenge: Real-time Crypto Fraud Alert Agent with Claude Agents SDK

Format
Code-aware
Lines
32
Sections
7
Linked challenge
Real-time Crypto Fraud Alert Agent with Claude Agents SDK

Prompt source

Original prompt text with formatting preserved for inspection.

32 lines
7 sections
No variables
1 code block
Start by setting up your development environment for the Claude Agents SDK. Define a `Tool` for fetching simulated crypto transaction data (`get_transaction_details(tx_id: str)`) and another for fetching relevant news articles (`search_crypto_news(query: str)`). Implement basic Python functions that return dummy data for these tools. Then, initialize a Claude agent with these tools, instructing it to monitor for large, suspicious transactions followed by news of scams. Include Python code snippets.

```python
from anthropic import Anthropic
from anthropic.agents import Tool, Agent
import json
import time

# Initialize Anthropic client
client = Anthropic(api_key="YOUR_ANTHROPIC_API_KEY")

# Define a dummy tool for fetching transaction data
def get_transaction_details(tx_id: str) -> str:
    """Fetches details for a given crypto transaction ID."""
    # Simulate fetching data
    if tx_id == "tx3":
        return json.dumps({
            "tx_id": tx_id, "from_addr": "C", "to_addr": "Monero_Mixer", 
            "amount": "1200XMR", "currency": "XMR", "timestamp": "T3"
        })
    return json.dumps({"tx_id": tx_id, "status": "not_found"})

# Define a dummy tool for searching crypto news
def search_crypto_news(query: str) -> str:
    """Searches for crypto news articles related to the query."""
    # Simulate news search
    if "scam" in query.lower() and "whale" in query.lower():
        return json.dumps([{"headline": "Whale loses millions in hardware wallet scam", "content": "A prominent crypto whale reported losing over $282M in BTC and LTC...", "timestamp": "T2.5"}])
    return json.dumps([])

# Create Tool instances
transaction_tool = Tool(name="get_transaction_details", description=get_transaction_details.__doc__, input_schema={"$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": {"tx_id": {"type": "string"}}, "required": ["tx_id"]})
news_tool = Tool(name="search_crypto_news", description=search_crypto_news.__doc__, input_schema={"$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]})

# Initialize the agent. Your task is to define the agent's prompt and make it use these tools.
# agent = Agent(client=client, tools=[transaction_tool, news_tool], ...)
# response = agent.run("Monitor for suspicious crypto activities and alert on potential scams.")
```

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.