Amazon q developer rules examples work best when they encode repo-specific contracts that Amazon Q can load as chat context—not one-off prompt fluff. This page shows Markdown files under a typical.amazonq/rules/ tree, copy-ready snippets, and a practical division of labor with root AGENTS.md. Treat every path here as illustrative—AWS product docs and IDE/CLI builds change discovery—so re-check official Amazon Q Developer documentation on your installed surface before treating any example as permanent. We deliberately skip AWS console signup, IAM, and IDE marketplace install steps; those belong in AWS docs.

01

Independence note

02

What Amazon Q rules are for (vs AGENTS.md & prompts)

Project rules describe coding standards and team contracts that should stay true across developers. Amazon Q can incorporate Markdown under.amazonq/rules/ as chat context so answers respect those guidelines. Put durable house style in rules; put this ticket’s goal in the chat brief; keep secrets out of both.

  • .amazonq/rules: IDE/CLI-oriented project standards Amazon Q is expected to load as context (language defaults, infra guardrails, test commands).
  • AGENTS.md: portable root agent brief many tools (and some Amazon Q CLI builds) also read—good for cross-tool contracts. See how to write AGENTS.md.
  • Session prompts: this ticket’s objective, acceptance checks, and temporary non-goals.
  • Neither: AWS access keys, production credentials, or one-off customer data.

Prefer one clear statement of each convention. Thin Amazon Q–specific deltas in .amazonq/rules/; shared multi-tool facts inAGENTS.md. Compare packaging with cursor rules examples, windsurf rules examples, cline rules examples, kilo code rules examples, and copilot-instructions.md examples. Multi-file choice notes live in AGENTS.md vs CLAUDE.md vs Cursor rules.

03

File layout & relationship to AGENTS.md

A widely documented layout places Markdown underproject-root/.amazonq/rules/. Files are usually plain.md (for example python-standards.md orcdk-rules.md). Prefer one concern per file so reviews stay focused. Exact auto-load behavior can differ between Amazon Q chat in the IDE and the Amazon Q Developer CLI—confirm on your surface.

project/
  AGENTS.md                  # portable cross-tool brief (optional but useful)
  .amazonq/
    rules/
      01-general.md          # always-on house style
      02-python.md           # language standards
      03-infra-guardrails.md # S3/Dynamo/SNS-style contracts (illustrative)
      04-no-deploy.md        # forbid prod changes unless asked
  src/
  ...

AGENTS.md division of labor: keep facts that every coding agent should know (package manager, test command, forbidden paths) in a short root AGENTS.md. Keep Amazon Q–flavored or AWS-stack specifics in .amazonq/rules/. Some CLI releases includeAGENTS.md among default agent resources; IDE chat may rely more heavily on .amazonq/rules/ or agent resource config— do not assume identical loading. When in doubt, put the canonical sentence in one place and link or summarize elsewhere rather than maintaining three novels. Deeper comparison: AGENTS.md vs rules.

This page does not walk through Rules panel clicks, AWS Builder ID signup, or marketplace install—those change often and are covered by AWS documentation.

04

Copy-ready amazon q developer rules examples

Adapt these templates. Replace stack names, commands, 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.
- Prefer extending an existing module pattern over inventing a parallel layout.
- Run the project’s test / build command before claiming done.
- Do not change IAM, billing, DNS, or production deploy pipelines unless the user explicitly asks.
- Never print or commit secrets, access keys, or session tokens.

Language / API standards (Python example)

# Python standards

- Use type hints on public functions; prefer TypedDict / dataclasses for structured payloads.
- Raise specific exceptions; avoid bare except.
- Prefer pytest for new tests; mirror existing fixture style under tests/.
- Do not add a second HTTP client library when the repo already standardized on one.

Infra / cloud resource guardrails (illustrative)

# Infrastructure guardrails

- New S3 buckets: encryption on, block public access, enforce TLS in transit.
- New DynamoDB tables that need streams: document encryption and retention expectations.
- New SNS topics / SQS queues: enforce TLS; do not leave public subscribe/publish open.
- Prefer least-privilege IAM roles scoped to the service; do not attach AdministratorAccess in examples.

Safety / no-prod-change

# Deploy and secrets

- Do not run production deploys, mutate live AWS accounts, or edit payment / DNS config unless asked.
- Never commit .env, credentials.json, or long-lived access keys into rules or chat history.
- Prefer short-lived roles 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

  1. Imperative and testable. “Run pytest” beats “ensure quality.”
  2. Name artifacts. Paths, module names, and IaC stacks beat vibes.
  3. State non-goals. Forbid prod deploys, IAM sprawl, and drive-by refactors.
  4. One concern per file. Split language style from infra guardrails.
  5. Separate AGENTS.md from Q rules. Shared facts once; Q-specific deltas thin.
  6. Prefer portable wording when the same contract should also help Cursor / Cline teammates.
  7. Point at exemplars. “Match the existing repository layer” beats reinventing access patterns.

Rules degrade when they become a wishlist. If Amazon Q still violates a rule after two sessions, either the rule is vague, the file is outside.amazonq/rules/, AGENTS.md was assumed loaded when it was not, or a stronger nearby example is missing—fix discovery on your IDE/CLI surface first.

06

Anti-patterns

  • Novel-length always-on rules: crowd context and get sampled inconsistently.
  • Mirroring AWS console install steps inside rules: install paths belong in docs, not committed contracts.
  • Contradictions: “always open security groups” next to “least privilege.”
  • Secrets in rules: rules are often committed; use secret managers instead.
  • Copying Cursor / Kilo / Cline rules wholesale without remapping: wrong directory, wrong host assumptions.
  • Duplicating the same wall into AGENTS.md and every .amazonq file: sync cost explodes; pick one canonical layer per concern.
  • Assuming IDE and CLI load identical context: verify AGENTS.md / rules behavior on each surface you ship.

Related reading: How to write AGENTS.md · AGENTS.md vs CLAUDE.md vs Cursor rules · Kilo code rules examples · JetBrains AI Assistant rules examples · Junie guidelines examples · Kiro steering examples · Augment rules examples · Cursor rules examples · TRAE AI rules examples · Windsurf rules examples · Cline rules examples · Continue rules examples · Antigravity rules examples · copilot-instructions.md examples · How to write CLAUDE.md · Good agent prompts · Cursor agent tips · Agent engineering notes

07

FAQ

Where should I put amazon q developer rules examples in a repo?

Most teams use .amazonq/rules/ at the project root with small, focused Markdown files. Exact auto-load behavior depends on your Amazon Q IDE or CLI version—confirm in current AWS docs. This site’s examples are unofficial templates, not a product catalog.

How should .amazonq/rules relate to AGENTS.md?

Put portable, cross-tool contracts in AGENTS.md and keep Amazon Q–specific or AWS-stack deltas in.amazonq/rules/. Some CLI builds load AGENTS.md by default; IDE chat may emphasize .amazonq/rules/—do not assume they are interchangeable. See AGENTS.md vs CLAUDE.md vs Cursor rules.

Is this an Amazon Q or AWS console install guide?

No. This page only covers copy-ready rule writing and AGENTS.md division of labor. Install paths, IAM, Builder ID, marketplace, and console steps belong in official AWS documentation—re-check those after upgrades.

Will these templates work unchanged on every Amazon Q release?

No. Treat them as starting points. Re-verify directory names, chat vs CLI context loading, and any agent resource config after upgrades. Prefer repo-specific commands and paths over marketing phrases that age poorly.