Day 5 of 960 minCipher CadetHands-on lab
Day 5: Steering Files: Set the Rules for the Agent
Taught by Mr Elite Updated
By the end of today you can
- Create product, tech and structure steering files in .kiro/steering/
- Explain the difference between workspace rules and rules for all projects
- Write clear, testable rules including a no hard-coded secrets rule
- Compare agent output before and after steering to prove the rules worked
Warm-up
Answer from memory first, then tap to check. Recalling yesterday is what makes it stick.
Name two things you should look for when reviewing a diff that the agent produced.
Any two of: string-built SQL, innerHTML, hard-coded secrets, open network bindings, unexpected file changes.
Why do passing tests not prove that code is safe?
Tests only check the behaviour someone thought to test. They rarely cover malicious input or unsafe patterns.
Yesterday you reviewed every diff the agent made to your task app. You probably noticed something annoying. Ask for a feature on Monday and it uses one style. Ask again on Tuesday and it picks a different library, names files differently, or writes SQL by joining strings. You end up repeating the same corrections in every prompt.
Today I will show you how to stop repeating yourself. You will write short rule files that Kiro reads before it does any work. Done well, they save time and keep the agent away from risky habits, like pasting a password straight into source code.
What steering files are and where they live
A steering file is a plain Markdown text file that gives the agent standing instructions about your project. Kiro loads these as context, so you do not need to restate them in each chat. Think of it as a briefing note you hand to a new colleague on their first morning.
Workspace steering files live in a folder called .kiro/steering/ inside your project. Each file is just a .md file. Because they are ordinary files, you can read them, edit them, and commit them to Git so the whole team shares the same rules.
Why does this matter for security? The agent writes code quickly, and it fills any gap in your instructions with a guess. Sometimes the guess is fine. Sometimes it is a hard-coded key or a query built from user input. A steering file closes those gaps once, in one place, before the agent starts typing.
- Steering file
- A Markdown file in .kiro/steering/ that tells the agent how your project works and what rules to follow.
- Markdown
- A simple text format where # makes a heading and - makes a bullet point.
- Context
- The information the agent has in front of it when it answers you.
Quick check
Where do workspace steering files live?
Workspace steering files are Markdown files kept in .kiro/steering/ in your project, so they travel with the code.
Product, tech and structure: the three core files
Kiro can generate three foundation files for you. Each answers a different question the agent would otherwise guess at.
- product.md
- What the app is for, who uses it, and what it must never do.
- tech.md
- The languages, frameworks, libraries and versions the project uses.
- structure.md
- Where files go and how they are named.
Notice that these are about decisions, not code. If the agent knows you use Express and SQLite, it will not suddenly bring in a different framework. If it knows where routes live, it will not scatter new files at random.
Here is the kind of content a good tech.md holds for a small task app. It is short on purpose. Every line is a fact the agent can act on, and every line is something you can check against the project.
# Tech stack
- Runtime: Node.js 20
- Web framework: Express
- Database: SQLite through the better-sqlite3 library
- Tests: Jest, run with npm test
- Do not add new dependencies without asking first.Project rules versus rules for all projects
There are two scopes. Workspace steering applies to one project and sits in .kiro/steering/. Global steering applies to every project you open and sits in a steering folder in your home directory, under .kiro/steering/ there. When both exist and disagree, the workspace file wins, as it is closer to the work.
Use global rules for personal habits that never change, such as British English in comments or never committing secrets. Use workspace rules for facts about one app, such as which database it uses.
A simple test helps you decide. Ask whether the rule would still be true on a completely different project. If yes, it is global. If it mentions a library, a folder or a table name, it is workspace. Keeping them apart stops one project's details leaking into another.
Quick check
You want the agent to never hard-code secrets in any project you ever open. Where does that rule best belong?
A rule that applies everywhere belongs in global steering so you write it once.
Writing rules the agent can follow
Vague rules get vague results. Compare these two. Weak: write clean, secure code. Strong: use parameterised queries for every SQL statement, and never build SQL by joining strings. The strong rule is specific, and you can check it by reading a diff.
Keep each file short. Use bullet points. State what to do, and where it helps, say why. Include a short example when the rule could be misread.
Before you write a rule, ask yourself how you would spot a breach of it. If you cannot answer, the rule is too fuzzy. Rewrite it until a reviewer could point at one line in a diff and say it broke the rule.
# Security rules
- Never hard-code secrets, API keys, tokens or passwords in source files.
- Read secrets from environment variables, for example process.env.API_KEY.
- Keep a .env file out of Git by listing it in .gitignore.
- Add a .env.example file with placeholder values only.
- Use parameterised queries for all SQL. Never join strings into SQL.
- Bind the dev server to 127.0.0.1, not 0.0.0.0.Watch me do it: three steering files and a before and after test
I will do this on the task app from Day 4. Everything runs on your own machine, and nothing touches anyone else's system. First we capture a baseline so we can compare later. Without a before picture you cannot prove the rules changed anything.
ls .kiro/steeringNow a quick mechanical check. This command searches your source for SQL lines that join strings with a plus sign. Change src to your own source folder if it has a different name. Silence means no match, which is what we want.
grep -rn "SELECT.*+" srcIn the after diff, look for signs the rules were used. Files should sit where structure.md says. SQL should use placeholders such as ? rather than joined strings. No keys should appear in source. If something still breaks a rule, tell the agent which rule it missed and ask it to fix the diff. That feedback is how you tighten your wording.
Your turn: the lab on agent permissions
Steering shapes what the agent should do. Permissions limit what it can do. The lab below shows why you need both, because instructions can be hijacked. A hidden line in an issue or a file can read like an order, and the agent may treat it as one.
In the lab you play the security engineer. Read the task, decide the least access the agent needs to finish it, and cut everything else. Work through the hints on the lab page, and write down your reasoning as you go. You are not hunting for a secret value here. You are practising the habit of giving a tool only what the job needs.
When you finish, come back and think about steering. Which of your permission decisions could also be written as a plain rule in security.md? Rules and permissions work as two layers, and the second layer still holds when the first one is fooled.
Your turn
Coding Agent Blast Radius
Steering files tell the agent how to behave, but a hidden instruction in an issue can try to redirect it. In this lab you act as the security engineer and narrow what a coding agent is allowed to do, so a hijacked agent cannot cause serious damage. It is a hands-on look at blast radius, meaning how much harm one mistake can do.
What to try
What to notice
- How much the agent could reach when permissions allow everything.
- That the hidden instruction looks like ordinary text, so a rule alone may not stop it.
- How narrower permissions limit damage even if the agent is tricked.
If it did not work
Writing vague rules like be secure or write good code
Rewrite each as a specific action you could verify in a diff, such as use parameterised queries.
Putting a real API key or password in a steering file
Steering files are plain text and often committed. Use placeholders and keep real values in environment variables.
Assuming the agent always obeys steering
Treat rules as strong guidance. Read every diff and tell the agent when it breaks one.
Writing very long steering files
Keep each file short and focused. Split by topic instead of writing one huge file.
Recap
- Steering files are Markdown rules in .kiro/steering/ that the agent reads as standing context
- product.md, tech.md and structure.md fix what, with which tools, and where
- Workspace rules apply to one project and global rules to all of them, with workspace winning on conflict
- Specific, checkable rules work better than vague advice
- A no hard-coded secrets rule belongs in every project
- Steering guides the agent but does not replace diff review or tight permissions
Cheat sheet
.kiro/steering/- Folder for workspace steering files
product.md- Purpose, users and limits of the app
tech.md- Stack, libraries and versions
structure.md- Folder layout and naming
security.md- Your own security rules, such as no secrets in code
ls .kiro/steering- Lists the steering files from the terminal
Blast radius- How much harm one mistake or hijack can cause
Before the next day
Mission: Steer the task app
Write three steering files for your task app, ask the agent for a new feature, and show that it followed your rules. A before and after comparison is the evidence, so capture the before first. Work only on your own task app on your own machine.
About 35 min
You are done when: The three steering files plus a short before and after comparison note naming at least two rules the agent followed.
Want more? Add a global steering file with one personal rule, then confirm it applies when you open a different project.
Quiz
4 questions. Your score is saved with your progress.
1. Why is the rule use parameterised queries for all SQL better than write secure code?
A specific rule gives the agent a clear action and gives you something concrete to verify.
2. A workspace steering file and a global steering file disagree. Which does Kiro follow?
Workspace steering is closer to the project, so it takes priority over global rules.
3. Which is the safest place for a real database password?
Environment variables keep secrets out of files that get committed and shared.
4. What does the lab teach that steering files alone cannot?
Permissions cap the damage even if hidden instructions fool the agent, which rules in text cannot guarantee.
Finish the day
Mark the day complete to save your progress.
Next: Tomorrow we move from rules the agent reads to actions it triggers. You will build an agent hook that runs when a file changes, and the steering and permission thinking from today will help you keep it safe.
Your notes
Private to this device. Write what you want to remember from today.