Understand how Claude really works - and learn to build reliable applications and agents on it.
Secrets of Claude AI is a complete, hands-on textbook on the Claude family of large language models by Anthropic. It takes you from the mathematics of the transformer to production-grade agentic systems, explaining not only what to do but why it works. Every concept is grounded in working Python code and in one running example: Kobza, a corporate assistant for a building-materials company that grows chapter by chapter from a single API call into a secure, evaluated, production-ready agent.
What you will learn
- How the model thinks: tokens and tokenization, attention, the context window, and how pretraining, fine-tuning, RLHF and Constitutional AI shape Claude's behaviour.
- The Claude API in depth: the Messages API, streaming, system prompts, adaptive thinking and effort levels, tool use, vision and PDFs, citations and structured outputs.
- Prompt engineering that holds up: few-shot examples, delimiters, prompt chains and measurable, iterative improvement.
- Cutting cost and latency: prompt caching, batch processing, token counting, compaction and context editing, with worked cost calculations.
- Agents: the agent loop, workflows versus agents, the tool runner and the Claude Agent SDK, Claude Code with MCP, hooks, subagents and skills, Cowork, and Managed Agents.
- Dependability: prompt-injection defence, the OWASP Top 10 for LLMs, threat modelling, evaluation with LLM judges and statistical tests, retrieval-augmented generation (RAG), computer use, rate limits, observability and safe model migration.
- Responsible AI: bias testing, formal fairness criteria, regulation (EU AI Act, GDPR) and the role of the developer.
Inside the book
- 23 chapters in four parts, with 158 diagrams and illustrations
- Learning outcomes, summaries, key terms, review questions and exercises in every chapter
- 14 lab assignments with 15 domain variants, plus hints and answer guides
- 130 ready-to-use code recipes in Python, TypeScript, Go, Java, C#, Ruby, PHP and the command line
- A reference of current models, prices, parameters and error codes, a glossary and 138 test items
- A companion code repository with offline tests, so you can run the examples without an API key
Who this book is for
University students in computer science, software engineering, data science and cybersecurity; software developers and machine-learning engineers who integrate large language models into products; and anyone who wants to move beyond chat and build real applications and agents with Claude. Basic Python is enough to follow the code.
The book reflects the Claude 5.x model family and the Claude API as of October 2026, and teaches the principles that stay valid as models and prices change.
This book is an independent publication and is not affiliated with, endorsed or sponsored by Anthropic, PBC. Claude is a trademark of Anthropic, PBC.