BrunoP.Blog

How to work with an AI agent: the guide (skills, memory, cost and security)

An AI agent only truly delivers when you get four things right: giving it skills (what it can do), memory (that doesn't vanish), cost control, and protection against attacks. I put it all in one guide, with a deep-dive on each piece and the free tools for each.

An AI agent (like Claude Code, Cursor, or ChatGPT with tools) doesn't just chat: it acts. It reads files, runs commands, calls APIs. But the difference between "I played with AI" and "AI works for me" is mastering four levers: what the agent can do (skills), what it remembers (memory), what it costs (tokens), and how it doesn't burn you (loops + security). This guide ties the four together, with a deep-dive on each and, where possible, a free tool to put it into practice.

What are "skills" and how does the agent do things your way?

A skill is a recipe you hand the agent: a SKILL.md file (optionally with scripts) that teaches it to do a task your way, the same every time, from your commit style to how you review security. Instead of re-explaining each conversation, you store the knowledge once, and the agent triggers the skill on its own when the task matches its description. It's the open Agent Skills standard, and it's just text.

Go deeper: what AI skills are and how to build your own →

Free tool: SkillForge generates a valid SKILL.md from a form, in your browser.

How do you give the agent memory so it doesn't forget everything each session?

First, separate two concepts: the context window is the short-term memory of one conversation. It vanishes when the session ends. Persistent memory lives in files outside the conversation, which the agent reads at the start of each session and updates as it works. The pattern that works has three layers (global rules · per-project memory · a lean index), versioned with git using a whitelist so a secret never leaks.

Go deeper: I gave my agent a memory that survives every session (with template) →

What does running an agent cost, and how do you avoid overpaying?

Cost is measured in tokens: chunks of text going in (your prompt + context) and out (the answer), priced per model. The bill grows with large context and with an expensive model used out of habit. Real savings come from picking the right model for each task and measuring the spend before scaling, not from guessing.

Go deeper: how much a prompt costs (I compared 8 models) + PromptTools →

First: understand how AI "reads" your words (the tokenizer), it's what sets the cost.

How do you stop the agent from looping and torching the budget?

An autonomous agent can get stuck in a loop (repeating an expensive call endlessly) and become a "financial DoS" against yourself. The protection is a circuit breaker: a limit on how many actions per period it can fire (the classic "token bucket" / rate limit). Every serious system that gives an agent autonomy puts that brake in before letting go of the reins.

Go deeper: my AI agent looped and nearly torched the budget →

What are the security risks, and the main one?

The biggest is prompt injection: instructions hidden inside content the agent reads (an email, a page, a file) and obeys by accident, as if they were your orders. It's a structural risk. The model can't safely tell "data" from "command". The defense is to limit what the agent can do, distrust external content, and never give it irreversible power without confirmation.

Go deeper: "ignore all previous instructions" — the attack AI can't fix →

In short

No single piece is the magic. It's the set. A skill without memory re-explains everything; memory without cost control gets expensive; both without security become a risk. Getting the four levers right together is what turns a clever chat into an agent that works for you.

I want AI working in my business

That's what I do in applied AI for business: put AI and automation to solve real business problems, with an obsession for cost and security. If that fits your case, let's talk.

Get what I build.

New tools, Lab experiments and articles, when they ship. No spam, unsubscribe anytime.