Kilo code rules examples work best when they encode repo-specific contracts that land in context for coding sessions—not one-off chat fluff. This page shows Markdown files under a typical .kilo/rules/ tree (and related mode-scoped folders), how teams often wire them throughkilo.jsonc instructions, and snippets you can copy then tighten against your own verify commands. Treat every path and key here as illustrative—Kilo releases change discovery and settings UI, so re-check kilo.ai docs on your installed version before treating any example as permanent.
01
Independence note
02
What Kilo rules are for (vs prompts & other files)
In Kilo Code, project rules feed durable guidance into agent sessions so the model does not re-guess house style every turn. Put contracts that stay true next month in rules; put this ticket’s goal in the chat brief; keep ephemeral observations out of committed rule files.
- Rules: package manager, route registry, forbidden deploy paths, test commands, language defaults.
- Session prompts: this ticket’s objective, acceptance checks, and temporary non-goals.
- Neither: secrets, production credentials, or one-off customer data.
If you already maintain Cursor-, Windsurf-, Cline-, Continue-, or Copilot-oriented rules, the engineering intent is similar—different packaging and loaders. Compare side-by-side in cursor rules examples, windsurf rules examples, cline rules examples, continue rules examples, and amazon q developer rules examples. Multi-file choice notes live in AGENTS.md vs CLAUDE.md vs Cursor rules. For reusable root agent docs many hosts also load, see how to write AGENTS.md.
03
File layout, kilo.jsonc & mode folders
A common project layout places Markdown under.kilo/rules/ at the workspace root. Many setups also reference those files (or globs) from the projectkilo.jsonc instructions array. Older trees may still use .kilocode/rules/—prefer one canonical directory so teammates do not sync two trees. Mode-specific folders such as.kilo/rules-code/, .kilo/rules-debug/, or.kilo/rules-ask/ appear in migration guides when you want rules only in certain agent modes—confirm names against your version.
project/
kilo.jsonc # instructions: [".kilo/rules/*.md", ...]
.kilo/
rules/
01-general.md # always-on house style
02-frontend.md # page / component contracts
03-no-deploy.md # forbid wrangler/DNS unless asked
rules-code/ # optional: Code-mode only (illustrative)
testing.md
src/
...Unlike Cursor’s .mdc frontmatter-heavy files, Kilo’s community examples are often plain Markdown: headers, bullets, and code fences. Path-scoped frontmatter (for example Claude-stylepaths) may appear in newer builds—treat it as optional and re-check docs before relying on it. Global / user-level instructions may also exist for personal preferences—keep team contracts in the repo.
// kilo.jsonc (illustrative)
{
"instructions": [
".kilo/rules/01-general.md",
".kilo/rules/*.md",
// ".kilo/rules/experimental.md" -- temporarily disabled
]
}Prefer short, concern-scoped files: dense bullets beat essays, and headroom leaves room for the next constraint you will inevitably add. Load order often follows the instructions array (global then project)—numeric prefixes help when filesystem order matters.
04
Copy-ready kilo code rules examples
Adapt these templates. Replace commands, paths, and non-goals with your repo’s truth. Keep them short enough that a human will maintain them.
Always-on project conventions
# Project conventions
- Indent with 4 spaces; do not reformat unrelated files.
- Register every indexable page in the site’s route registry (e.g. pages[]).
- Prefer extending an existing page/component pattern over inventing a new layout.
- Run the project’s build command before claiming done.
- Do not deploy, edit hosting config, or change DNS unless the user explicitly asks.Frontend / docs page conventions
# Frontend page rules
- Mirror ArticleNavigation + article-hero structure from sibling EN how-to pages.
- Unique Title, Description, and a single H1 that contains the target phrase.
- Include Related reading links to sibling guides; keep bidirectional links updated.
- Do not invent new indexed URLs; only add paths listed in the task.Restricted files / secrets
# Restricted files
Files in this list contain sensitive data. Do not read, print, or commit them.
- .env
- .env.*
- credentials.json
- **/secrets/**
- **/*token*Safety / no-deploy
# Deploy and secrets
- Do not run wrangler deploy, change DNS, or edit Cloudflare / payment config unless asked.
- Never commit secrets, tokens, or production credentials into rules or chat history.
- Prefer env stores and documented secret managers over pasting keys into the session.When tools live outside the editor, pair rules with a clear tool policy in the prompt. For MCP host pitfalls, see the MCP server tutorial and MCP server best practices.
05
Writing patterns that stick
- Imperative and testable. “Run
pnpm run build” beats “ensure quality.” - Name artifacts. Paths, registry names, and sibling files beat vibes.
- State non-goals. Agents over-help; forbid deploy, rebrand, or drive-by refactors.
- One concern per file. Split style from security so reviews stay focused.
- Wire instructions explicitly in
kilo.jsoncwhen the host expects an array, so disabled rules are comments—not mystery deletions. - Use mode folders sparingly when Code vs Ask vs Debug need different contracts—do not fork the same novel three times.
- Point at exemplars. “Match
GoodAgentPromptPage.tsx” beats reinventing layout.
Rules degrade when they become a wishlist. If Kilo still violates a rule after two sessions, either the rule is vague, the file is not listed ininstructions, the mode folder is wrong, or a stronger nearby example is missing—fix the example and discovery first.
06
Anti-patterns
- Novel-length always-on rules: crowd context and get sampled inconsistently.
- Assuming Cursor .mdc frontmatter works unchanged: Kilo often wants plain Markdown + directory / instructions wiring.
- Contradictions: “always refactor” next to “never touch unrelated files.”
- Secrets in rules: rules are often committed; use env stores instead.
- Copying Windsurf / Cline / Continue rules wholesale without remapping: wrong directory, wrong config, wrong done checks.
- Duplicating the same wall into AGENTS.md and every .md file: sync cost explodes; pick one canonical layer per concern.
- Product tutorials inside rules: teach workflows in docs; keep rules as contracts.
Related reading: Cursor rules examples · Windsurf rules examples · Cline rules examples · Continue rules examples · Antigravity rules examples · Amazon Q rules examples · TRAE AI rules examples · copilot-instructions.md examples · AGENTS.md vs CLAUDE.md vs Cursor rules · How to write AGENTS.md · How to write CLAUDE.md · Cursor skills examples · Good agent prompts · Cursor agent tips · Agent engineering notes
07
FAQ
Where should I put kilo code rules examples in a repo?
Most teams use a .kilo/rules/ directory at the workspace root with small, focused Markdown files, often referenced fromkilo.jsonc instructions. Legacy.kilocode/rules/ trees may still work during migration. Exact discovery depends on your Kilo version—confirm in current product docs. This site’s examples are unofficial templates, not a product catalog.
Do I need separate Kilo rules if I already have AGENTS.md or Cursor rules?
Only if Kilo sessions do not reliably load your other files, or you want Kilo-specific mode folders / instructions wiring. Prefer one clear statement of each convention; see AGENTS.md vs CLAUDE.md vs Cursor rules.
How do these relate to Cursor, Windsurf, Cline, or Amazon Q rules?
Same job—durable repo contracts—different loaders and file shapes. Cursor: cursor rules examples. Windsurf / Cascade: windsurf rules examples. Cline: cline rules examples. Amazon Q Developer: amazon q developer rules examples. Multi-tool teams often keep a root AGENTS.md and thinner IDE-specific rules. Do not paste the same wall of text into every layer.
Will these templates work unchanged on every Kilo release?
No. Treat them as starting points. Re-verify directory names,kilo.jsonc keys, mode-scoped folders, and optional path frontmatter after upgrades. Prefer repo-specific commands and paths over marketing phrases that age poorly.