Guide: full working rules (v1.2)
Note for AI agents: This page is baseline guidance, not an exact prescription. Read it, tell your owner what applies to their project, and get their approval before you change anything. Your project's own rules take precedence. If something important for this project is missing here, suggest it to your owner.
General working rules for AI agents and human developers. Version 1.2, 2026-12-01 (changes in §16).
This guide does not say what a product should do; product decisions live in each project’s own documents. It describes how the work is done: accuracy, efficiency, continuity, security, code quality and scale. The rules apply the same way to an AI agent and to a human developer.
0. How to use it
- At the start of a project, answer the questions in §1 and decide the project class: S, M, L or XL.
- Each rule shows the classes it applies to, for example
[M+](M and above) or[XL](XL only). Do not apply rules outside your class. Unnecessary work is also a mistake: it costs time, money and tokens. - Rules without a label apply to every class.
- Proportionality: every rule is applied in proportion to the risk it prevents. If you think a rule is unnecessary for this project, do not skip it silently: tell the project owner the reason in one sentence and leave the decision to them.
- If the project grows (more users, personal data, payments and so on), the class goes up and the new rules apply from that moment. A class change is written to HANDOFF.
- If the project’s own rules (CLAUDE.md, AGENTS.md, decision records) conflict with this guide, the project’s rule wins. Tell the project owner about the conflict once.
- The guide lives in the repository; it is not re-supplied each session. In the first session the guide is placed in the repository as
docs/PROJE-CALISMA-KILAVUZU.md. CLAUDE.md / AGENTS.md records: the project class, the path of the guide, and a short summary (10–30 lines) of only the rules that fit this class. AI tools read CLAUDE.md / AGENTS.md on their own every session; the whole guide is opened only when the relevant topic comes up. This way the rules are not lost and tokens are not spent reading the whole guide each session. - When a new version of the guide appears, the file in the repository is replaced, the summary in CLAUDE.md is reviewed, and the change is written to HANDOFF as one line.
- The project owner’s word always comes first. The owner may tighten a rule (for example “do not fix findings without talking to me”) or loosen it with a reason; this decision is written in the project’s own rules file.
1. Decide the project class
| Question | If yes, at least |
|---|---|
| Is it static content with no login and no personal data? (promotional site, landing page) | S |
| Does it have user login, personal data or an external API key (for example an LLM)? | M |
| Does it have an admin panel, roles or permissions, payments, file uploads or several kinds of users? | L |
| Does it have thousands of concurrent users, a mobile app published in a store, a legal record-keeping duty or sensitive data (health, finance, location)? | L |
| Does it target millions of users, have social interaction (follow, like, feed) or public content? | XL |
Typical examples:
| Class | Example |
|---|---|
| S | One-page promotional site, portfolio |
| M | Web-based AI assistant with few users (notes, reminders), small CRM, internal tool |
| L | Complex site, multi-user CRM, booking or payment system, app with an admin panel, personal assistant app published in a store (sensitive data such as health or spending) |
| XL | Social media, marketplace, mobile app with millions of users |
If you are unsure, choose the higher class, but remember §0.4: state any unnecessary rule with its reason.
Note (v1.2): The highest row in the table applies. For example, an “assistant app” sits in M as an example, but if it is published in a store and holds health or spending data, it is L.
2. Core rules (every class)
2.1 Accuracy: no invention
- Before writing a command, library, API or platform policy, verify it in current official documentation. Do not write from memory.
- If you are not sure, state your confidence level (“probably”, “I need to verify”). Separate speculation from fact.
- When debugging, first read the error’s own text; form a hypothesis afterwards.
- Before saying “done”, “fixed” or “open”, actually look in the code, the git history and the documents.
- Do not say “it works” without testing. Do not say “fast” or “not enough” without measuring.
- For a source you could not reach, write “could not be verified” and say why (for example “the page did not open from the network”). Do not fill the gap with a guess.
- When you make a mistake, no apology ceremony: say “Correction: …” and continue.
- Honest reporting layers: “written, not tried” / “passed its tests” / “really worked end to end” are always reported separately. A skipped or failed step is stated openly. A feature is not finished just because code exists.
2.2 Efficiency and token saving
Savings are not taken from quality: tests, verification, security or checklists are not skipped to save tokens or time.
- Do not read files the task does not need. In a large file, search first (grep), then read only the relevant lines.
- Required documents and any rule or decision document the work touches are read from start to finish. If you are unsure whether a document is needed, read it. Only reading unrelated to the topic is shortened.
- Do not re-read a file you just wrote or edited “to be sure”; if the tool gave no error, treat it as successful.
- Run independent operations at once, in parallel.
- Give large verifications and long document scans to a sub-task; only the result returns to the main context. In a big PDF or report, look at the contents first, then read only the relevant pages.
- Do not re-ask a decision that was already made; first look for it in code and documents.
- Do not narrate intermediate steps (“now I am reading file X”). When the work is done, give a short summary: result first, then a few points. Detail goes into the document; the reply gives only the document’s path.
- If there is an important risk or decision, say it even if not asked.
2.3 Continuity: no loss of context
AI sessions lose their memory; the only lasting thing is the files in the repository. A human developer also has to hand over work one day.
| File | Content | Rule |
|---|---|---|
CLAUDE.md / AGENTS.md |
Permanent project rules, architecture summary, document index | Read first in every session. If it exceeds 500 lines, simplify: move finished topics to a separate document, leave a one-line summary and the file path. [L+] Domain-specific rules go to separate domain files (for example .claude/rules/*.md). |
HANDOFF.md |
“Where we stopped”: 5–10 lines of current status at the top, open instructions (⏳), pending owner decisions, work waiting on a branch or only locally | Updated at the end of every work round. If it exceeds 300 lines, old sections move to an archive file. |
docs/kararlar/ (decision records) [M+] |
Dated decision documents: what was decided, why, by whom | Written the moment the decision is made. |
Open issues list [M+] |
One list: tasks, questions, owner’s tasks | The next task is chosen from here. |
- Instant recording: every decision, request and pending task raised in chat is written to the relevant document the moment it appears. Do not wait for the end of the work; a session can be cut at any time.
- When a decision changes, every place that mentions it is updated in the same round, found by search. A short history note stays in place:
⛔ new date: new decision (previous: old decision, date; why). - A code name (K12, N48 and the like) is not enough. When mentioning a topic, give context in one sentence: what, when, what is being asked now.
2.3a Interruption and handover rules
If the session limit is about to run out, the context is about to overflow, the machine may shut down, or the project owner says “stop / I am handing over”:
- No new work is started.
- A half-finished edit is either completed or reverted; no code that does not compile is left behind.
- The code is committed and pushed to the working branch (not the main branch; no
--force). - HANDOFF is updated: what is done, what is half-done, how to restart.
- The branch name and the last commit ID are reported. The next session (the same or another agent / account) must be able to continue with no loss. While a long task is running, a “work in progress” line is kept for each running job.
2.4 Communication with the project owner
- Do not assume the project owner knows code. Explain a technical term in brackets where it first appears.
- Write interface steps concretely: instead of “go there”, write “press X at the top right, choose Y in the menu”. Give commands in copyable form.
- Show a design change first as a visual draft, and code it after approval.
- If you notice a legal risk, say it without being asked: personal data, liability, consumer rights, platform policies.
- Collect questions that need approval and ask them together. Continue with other work while waiting; work does not stop when the owner is away.
- Do not list options and leave the decision to the owner: recommend the best one and give a short reason. Ask only the decisions that really are the owner’s.
- Passwords, tokens and API keys are never requested in chat; the owner is told how to enter them themselves in a safe place (secret manager, environment variable).
- When mentioning code names and old decisions, give context (§2.3).
2.5 Security baseline
- A password, key or token is never written to any chat, code, commit or log. A key pasted into chat is treated as leaked and is replaced.
- Secrets are kept in environment variables or a secret manager. The
.envfile does not go into git; only.env.exampleis in the repository. - Every access is given with least privilege: database user, cloud service account, API key scope.
2.6 Git and record discipline
- After each logical unit of work, make a separate commit. The message says what changed and why; the project owner follows the history from these messages.
[M+]The commit message has aSide effect:line (in the Turkish original,Yan etki:): what else the change affects, what was checked, which tests ran.- The main branch and release versions are touched only with the project owner’s explicit word. History is not rewritten on someone else’s branch.
--forceand--no-verifyare not used. - No half-finished work is left. If a temporary workaround is needed, it is marked clearly as
TODOand the owner is told. - Loss prevention: finished work is pushed to the remote branch at once.
[L+]The report lists “on the branch (pushed)” and “only local” separately.
2.6a Audit and large-run rules [L+]
- Check first, then the big job: before every long or costly run (a large test, a load test, a cloud machine, a bulk scan), the scenario is checked against the current code (a scenario that calls a removed feature or never tries a new one) and a small smoke run is made. If there is a finding, it is fixed first.
- Audit rounds: the findings of each round are fixed first, then a new round starts; several rounds are made even when “everything looks fine”; each code audit round covers the whole code and each load test round covers all scenarios from the start (a shortened run does not count as a “round”); costly rounds start only with the project owner’s word, and when a round ends the next one is suggested.
- If the owner wants: found defects are first presented as a list with a recommendation, and fixing starts with approval.
2.6b Sub-agents and cost
- By default the main session does the work. A sub-agent is used only for a truly independent, long side task; at most 3 at a time. If more are running, their work is handed over to the main session without being lost.
- Cloud, AI and CI costs are stated in advance; a spending ceiling and an alarm are set up. But no “money breaker” that stops the system by itself is built: capacity is watched in advance and raised when it nears the limit.
2.7 Code and documents a human can read
- Code comments answer why, not what was done. Every module starts with two or three lines saying its purpose.
- Decision records and commit messages are written in language that a developer who has never seen the project can understand.
[L+]A developer handbook is kept: module map, where to start, a document for each module. If the project is run in Turkish, a Turkish → English term glossary is also kept. Every new module goes into the handbook.
3. Packages and versions
| Rule | Class |
|---|---|
| Package and version choices are verified from an official source; the current stable version is used, no pre-release (alpha, beta). | S+ |
The lockfile is committed; installs are done locked (for example --frozen-lockfile). |
M+ |
Every dependency is pinned to an exact version (no ^, ~). Docker images by digest (@sha256), CI actions by full commit ID. |
L+ |
| 7-day rule: a newly published version is not installed before at least 7 days have passed (against supply chain attacks). | L+ |
| Security exception: if there is a critical vulnerability, the fixed version published by the official source may be installed without waiting 7 days. It is written with the reason and an end date, and the project owner is told. | L+ |
| All versions are collected in one file (for example a pnpm catalog). Package files refer only to it. | XL |
| Packages that run install scripts are not installed without approval. If the publisher’s trust is lower than in previous versions, installation stops. The security scan (audit) turns red on a finding of medium level or above. | XL |
| Major version upgrades are done one by one, with the official migration guide and their own tests. An update whose release notes cannot be verified is not taken. | L+ |
Platform-specific native packages are installed with the platform’s own tool (for example npx expo install in Expo). Otherwise an incompatible version is installed and the error appears only as a crash on a real device. |
M+ mobile |
| There is one package manager and it is enforced (for example only pnpm). | M+ |
The equivalent for each language ecosystem is applied: for example in Go, go.mod + go.sum fixed and the toolchain version fixed; in Python, a locked dependency file. |
M+ |
| Open-source licence page: the name and licence of every library used in the published app / site are visible (for example Settings → Open source licences); the list is generated from the lockfile; a forbidden licence turns the guard red. | M+ (published product) |
| A dependency list (SBOM) is produced. | L+ |
| Security scan exceptions: each exception is kept as a machine-readable record (advisory ID, package, affected versions, level); when the package is updated or the level rises, the exception becomes invalid automatically; at most 30 days, extension needs a reason + official source + proof that “it is not reachable in our code”; silenced warnings are listed separately in the report. | L+ |
| A dependency update bot (for example Dependabot) is turned on only for security patches; one grouped proposal per ecosystem. | L+ |
| Selector override: if a sub-package’s version is forced for security, a fix is written for each major version line; forcing without a selector makes the consumer jump a major version unknowingly. | XL |
4. Code quality and architecture
- Modularity: every area has its own folder (
routes/<area>,modules/<area>). Dependencies between areas are kept to a minimum. - Single source of truth: a piece of information or a setting is defined in one place. If numbers shared by client and server (such as a character limit) must be kept in two places, they change together and are matched by a test.
- The same area is not written from two different places. A shared function is used.
- Patch pile-up: if patch after patch is added to a feature, the flow itself is questioned. If a third patch is needed on the same topic, redesigning the flow is considered first.
- No dead code is left: when a feature or layout changes, the old code, its tests, its guards and its documentation comments are deleted. Everything deleted stays in git history anyway; deleting is not losing information.
- A found defect is fixed at once and its side effect is investigated: which flows and tests are affected, does the security meaning change? The result goes into the
Side effect:line of the commit message. [L+]Feature locks: one file is kept that turns a group of endpoints on or off with one line. A locked endpoint returns a distinctive error code. In production, the lock cannot be opened with an environment variable.[L+]Fail-closed: with an unrecognized environment setting or a missing required setting, the process does not start at all. There is no silent fallback path. Ask “is it development or test?” instead of “is it not production?”.- Not tied to a platform: see §8. Types and calls specific to a cloud provider, storage product or database product do not leak outside one abstraction layer.
4.1 Industry standards (S-codes) [L+]
Each part is designed before it is written with the standard mechanism of its area: “works correctly” is not enough; behavior under load, failure and repetition also follows the standard. The list is kept in a project document, the status column is updated at every audit, and new rows are added when needed.
| Code | Area | Standard |
|---|---|---|
| S1 | Client retry | exponential backoff + jitter + the server’s Retry-After; limited attempts |
| S2 | Repeatability of writes | a unique key on every write (Idempotency-Key); the server processes the same key once |
| S3 | Early rejection under overload | per-process concurrency limit + short queue; when full, an immediate 429 / 503; priority for critical writes |
| S4 | Connection pooler | code compatible with a transaction-mode pooler |
| S5 | Read scaling | read replica + read-your-writes consistency |
| S6 | Timeouts | an upper time on every external call (query, storage, email, notification, AI, external process) |
| S7 | Circuit breaker | not sending requests for a while to an external service that keeps failing, a single half-open trial |
| S8 | Cache | cache + correct invalidation for data that is read often and changes rarely; merging identical reads that arrive at the same time |
| S9 | Background job guarantee | jobs are not lost, limited retries, an alarm for stuck jobs, single processing |
| S10 | Graceful shutdown | on the shutdown signal no new requests, in-flight ones finish, pools close |
| S11 | Rate limit | per account, counters in a shared store, limit values are not leaked |
| S12 | Security headers | HSTS, nosniff, CSP, frame ban, Referrer-Policy, CORS allow list |
| S13 | Monitoring / alerting | error tracking, latency / error-rate metrics, alert at a threshold |
| S14 | Memory / queue limit | in-process queues are bounded |
| S15 | Error responses through one path | capacity / connection trouble is “busy” (429 / 503 + Retry-After), a real error is a report + 500; capacity trouble is never a 500 |
| S16 | Response compression | text responses gzip / brotli; except responses carrying secret information (BREACH) |
[XL] Every code commit carries a Standard: line (the S-codes applied + not applied: <reason>); the push lock rejects a commit without it.
5. Tests and guards: when needed, in proportion
Principle: testing is proportional to risk and to the lifetime of the code. Writing a full test suite for a one-off prototype is waste. Leaving a flow that touches the data of millions of users without tests is negligence.
Guard: a test that checks a rule automatically with code. Examples: “are versions pinned”, “is the new index in both the schema and the migration”, “is anything on screen moving by itself”.
| Class | Minimum tests |
|---|---|
| S | Build and type check; manual check that the page opens, links and the form work; view at mobile width. |
| M | + Automated tests for critical flows: login, saving data, payment if there is one. A permission check test. A local check command before pushing. |
| L | + End-to-end (e2e) tests, a short CI run, guards, screen checks (both themes, all supported languages), permission and access-to-others’-data (IDOR) tests. |
| XL | + Mutation proof, load tests (with a coverage map), attack drills, performance and accumulation measurements (§9). |
Kinds of tests and guards: static guard (reads the code as text), runtime guard (the server does not start if it sees a wrong setting), pipeline (local check command, push lock, CI), unit test, end-to-end (e2e) test, screen guard (screenshot / layout check: two themes + all languages), test guard (checks the coverage of tests: for example is every endpoint in the load test map, does every personal data table have a delete path). All are listed in one inventory document: what it protects, why it exists, when it runs, what to do if it turns red.
When a guard is written:
- If the same bug appeared a second time.
- If the rule can be checked with code and breaking it is costly: security, data loss, legal duty.
- If the cost of writing it is lower than the risk it prevents.
When a guard is not written: a one-off job, a prototype, rules that are a matter of taste.
Rules:
- A red test is not silenced and not left for “later”. The code is fixed. If the test itself is outdated, it is rewritten in the same round to match the new design.
- When the screen layout, button position, text or a rule changes, the tests that depend on it are updated in the same round.
- “I could not measure” or “skipped” is not success; it is red.
- Order when red: (1) read the message first; (2) default: fix the code, not the guard; (3) changing the guard only if the protected decision was knowingly changed, with the reason in the guard, in the inventory and in the commit; (4) if the guard itself is broken, first prove that it still catches the same bug; (5) no guard is silently deleted; (6) when red after a package update, first look at version-bound constants.
[L+]Flakiness: every new or changed e2e test runs 3 times in a row before going to the main branch; if even one is red, the root cause is found (“flaky” is not a root cause).[L+]A permanent record of every large test and local check result is kept (secrets masked).[XL]Mutation proof: when a new test is written, the code it is meant to protect is deliberately broken and the test is shown to turn red. A test that does not turn red protects nothing.[L+]Test rhythm: in small jobs only the type check of the relevant package is run. When all work is done, one big test is run before pushing to the main branch. Long tests must be able to resume where they were cut.[L+]Local first, then CI: paid CI minutes are not wasted. The same checks run locally before every push; a git hook enforces this.
6. Security (by class)
[S]
- HTTPS is used. The contact form has spam and bot protection. The page holds no secrets. External scripts are loaded with a fixed version.
[M+]
- A mature library or service is used for authentication; no crypto from scratch. Passwords are hashed with a current algorithm.
- Sessions have a lifetime and revocation. All inputs are validated on the server with a schema.
- Permission is always checked on the server. A button hidden in the interface is not security.
- External API keys (including LLM) are kept only on the server and are not sent to the client.
- No personal data or secret is written to logs; if needed, it is masked.
- Signup security: block disposable email; one inbox is one account (ignoring
+tagand Gmail dots); email verification; an email change is notified to the old address and can be reversed; leaked password list; per-account attempt limit against brute force (with a protection against targeted lockout); signup budget and bot protection; session list and remote sign-out. - If there is a username: allowed letters in one source, uniqueness case-insensitive and the comparison done in the database (no language-dependent lowercasing in the app — the Turkish
İbreaks), a write touching the name is under a lock, a reserved names list, a change limit.
[L+]
- Access to someone else’s record (IDOR / BOLA) is tested on every endpoint separately: can a user reach another person’s data by changing the ID in the address?
- Rate limits are per account. Endpoints without a session have an IP-based limit, but do not forget that mobile carriers put thousands of subscribers behind one IP (CGNAT): thresholds and tests are set accordingly.
- No device-based blocking; blocks are at account level. A device ID is used only for the person’s own session list and for legal records.
- Admin panel: two-step verification is mandatory. Roles and permissions are checked on the server. Every admin action is written to an audit trail; the audit trail cannot be deleted. User content shown in the panel is neutralized (XSS).
- CSRF, CORS and security headers are set. Changing permission or state by adding extra fields to the request body (mass assignment) is prevented.
- File upload order: identity → permission → rate limit → receiving the file. The body of an unauthorized request is not written to disk. The file is not loaded into memory. Size and type are validated on the server. Image bombs and disguised files are tested.
- “Check first, then write” is not done (race condition). State transitions are done with a conditional update; counters are incremented in the database.
- Time-bound operations have a timeout (external commands, tools such as ffmpeg).
- Limits inventory: every rate limit and capacity in one list: value, window, capacity calculation, “what can an attacker do”, side effect. Capacity (a ceiling) and a rate limit (a sliding window) are different things.
- The admin panel cannot see private content (in projects holding personal data): admins and moderators cannot reach users’ private content (messages, notes, chats, spending); the panel has no read path to them. What can be seen is limited by permission (for example login records, username / email change history); the password is not visible with any permission; every viewing is written to the audit trail.
[XL]
- Leak detection: decoy keys are placed (an alarm sounds if used). Alerts are set up from cloud audit logs: new service account, permission change. There are unusual-use alarms.
- There is a key rotation plan and it can be applied without cutting sessions.
- An attack drill is part of the load test; if no alarm comes, the test is red.
- An error reporting tool (like Sentry) is set up to strip personal data, with sampling and for unexpected errors only.
7. Data and database
[S] Keep no data if possible. If form data is kept, how long it is kept is written down.
[M+]
- Personal data note: for every new personal data field, write for what purpose, how long and on what legal basis it is held (KVKK, GDPR). The project owner expects this as a proactive warning.
- Every piece of data has a deletion period and they are collected in one deletion schedule document.
- Automatic backups are taken and restoring has been tried. An untried backup is not counted as a backup (§8.3).
- In LLM apps the data sent to the provider is minimized and masked; the provider’s data retention terms are documented.
[L+]
- Migration ledger: schema changes are made with numbered, hand-written files. An applied file is not edited or deleted; a change is made with a new file. Automatic schema sync (for example
drizzle-kit push) is never run on a database with data. - Commands that can delete data (drop table, drop column, TRUNCATE, DELETE, type change) require an explicit approval marker and a reason in the file; the project owner’s approval is mentioned in the commit.
- Every list is cursor-paginated (no OFFSET). No unbounded query is written.
- Whether a new query needs an index is checked with
EXPLAIN. The index is added to both the schema and the migration. - Bulk deletes are batched and ordered (oldest first); otherwise some rows wait forever.
[L+]If a legal hold (litigation hold) is needed, every deletion path checks it.- The database connection uses TLS; certificate verification is not turned off.
- Multilingual fixed content (category names, notification templates) is kept in a row-based translation table: (record ID, language code, text); columns like
name_tr,name_enare not opened, a new language is a new row. Text written by users and businesses is stored in the language it was written in; the system does not translate it (the language is only marked). [M+]Related records rule: when a record is deleted, records linked to it are not silently deleted. For each link, what happens is written as a conscious decision (ON DELETE CASCADEonly with a reason;SET NULLfor “where it was created” type links). Example mistake: when a chat is deleted, the reminders created in that chat are also silently deleted.[M+]Deletion and backup schedule in the contract: the promise made to users must be true. Example: “Data you delete becomes invisible at once, is permanently deleted from our systems within 7 days at most and from backups within 37 days at most; the period extends if there is a legal hold.” Short notes on screen also do not misstate the backup and third-party (for example AI provider) periods.[L+]On every deletion path, “skipped” is not success: if the cleanup job cannot take a lock, it produces a separate exit code and an alarm. The old version of changed text and a deleted file are kept for a set time (for example 7 days) if needed; nothing is deleted during a review / legal hold; there are no two separate paths that delete the same data.
[XL]
- In large relation tables (like likes, saves), a natural key is considered instead of an unnecessary artificial
idcolumn. The decision is made by measuring. - Single rows that are written a lot (such as the counter of popular content) are spread with a sharded counter; concurrent writing is measured.
- No structural optimization without measuring. Example: splitting a table by day may speed up deletion while slowing the read path. The decision is made with end-to-end measurement.
- The connection pooler and read replica can be turned on by a setting. Read-then-write flows stay on the primary database.
- Data localization: some countries may require their citizens’ data to be kept inside the country. Every user has a data region; personal data, files and backups stay in that region; shared data across regions is kept to a minimum (only the “which region” information); one user’s or one country’s data can be moved between regions with a tool that is lossless, verifying and resumable. The first version may ship with a single region, but the code carries the region information from the start.
- Data that should be separated for security (personal data, business data, person-to-person messaging) can be kept in separate databases and separate object stores; the cost (no single transaction across databases) is solved with mechanisms like a deletion notice that is not lost. Person-to-person messaging data is not sent to the AI provider.
8. Infrastructure portability: fits any server, database and storage
Principle: the application is not locked to one cloud provider, storage product or server. Changing provider must be possible without changing code, only by settings. How far this is applied depends on the class.
8.1 Containers (Docker)
| Rule | Class |
|---|---|
The project starts locally with one command (for example docker compose up); including the database, object store and helper services. |
M+ |
| The application is packaged as a Docker image; the same image runs in every environment (local, test, live), and only the settings change between environments. | M+ |
The image is built in multiple stages, runs as a non-root user, and the base image is pinned by digest (@sha256). There is a health check endpoint. |
L+ |
| Runtime versions such as Node and Python are the same in CI, local and live (exact version). | L+ |
| The process is stateless: files and sessions are in the database or object store, not on the container’s disk. This allows horizontal scaling. | L+ |
8.2 Object storage (S3 and compatibles)
- Files (images, video, documents) are stored through an S3-compatible API. The same code works with AWS S3, Cloudflare R2, MinIO, Backblaze B2 and the S3-compatible interface of Google Cloud Storage.
[M+] - One abstraction layer: the application calls only its own storage service (for example
ObjectStorageService). Provider-specific types do not leak outside this layer.[M+] - Endpoint, region, bucket and key come only from settings. MinIO is used locally, the chosen provider in live.
[M+] - If a setting is missing, the process does not start; there is no silent fallback path.
[L+] - Files are uploaded from the client directly to the store with signed, time-limited addresses; large files are uploaded in parts and resume where they stopped.
[L+] - Delete errors are not swallowed. There is an orphan file scan; an orphan file is a KVKK / privacy risk.
[L+] - When a new media column is added, three things are updated together: the delete path, the orphan scan and the store permission.
[L+]
8.3 Backup infrastructure
| Rule | Class |
|---|---|
| An automatic daily backup of the database is taken and the retention period is written down. | M+ |
| Restoring is tried regularly and the trial is recorded. | M+ |
| The backup is kept at a different provider or account from the main system. Even if the main account is taken over, the backup cannot be deleted. | L+ |
| The object store also has a backup or versioning. | L+ |
| Backup runs as a separate service or container and its failure raises an alarm. Backups are encrypted. | L+ |
| A full copy of the code (all branches and history) is regularly handed to the project owner; the project can be recovered even if GitHub access is lost. | L+ |
| A disaster recovery plan is written: data loss tolerance (RPO), recovery time (RTO), step-by-step return. | XL |
8.4 Database choice and portability
- The default choice is PostgreSQL: mature, open source, with a managed service on every cloud. If the project needs another database, the reason is written in a decision record.
- Schema and queries are written through an ORM or a query builder. Raw SQL is used only when needed and in a single module.
- Realistic portability: the application must be movable to any provider of the same database engine (AWS RDS, Google Cloud SQL, Azure, Supabase, Railway, your own server) with no code change, only the connection setting. Moving to a different database engine (for example from PostgreSQL to MySQL) is planned only if there is a real need. Writing for every engine means giving up the engine’s strong features (triggers, partial indexes, JSONB) and is an unnecessary cost in most projects. This is a project owner’s decision; the default is provider independence within the same engine.
- Connection address, pool size, TLS and read replica come only from settings.
[L+]An empty database is set up with one command: migrations run in order and base data is loaded.
8.5 Other services
- Services such as email, push notification, error reporting and payment are each kept in a separate module. If there is no setting, the module is harmlessly disabled (or, where it is required in L+, the process does not start). Changing provider means changing a single module.
[L+]Where possible, the official API is used directly instead of an intermediary service (for example FCM/APNs for notifications). Dependency and cost go down.
9. Scale and performance [L+]
- Assumption: users come from a shared IP (CGNAT). Limits for logged-in users are per account.
- A single event does not rebuild the list: a “seen” record or a counter increment affects only its own item; the whole list or page is not redrawn. Proven by a measuring test.
- No accumulation in the background: however long the list grows, the number of items, players, timers and subscriptions held in memory and on screen stays bounded. Measured with a long-scroll test.
- Gradual loading: new data is requested as the user nears the end; thousands of items are not loaded at once. A test that measures the number of requests is kept.
- Small writes that repeat often are sent in batches (collect, one request every few seconds).
- The number of queries is measured for each endpoint and limited by a guard.
[XL]A scale finding is not skipped with “fine at today’s scale”. Those that need no decision are solved to a high standard; those that need a decision are presented to the project owner. Proof of “done”: a commit number, a before/after measurement and the name of the test that will turn red if it breaks.[XL]Load tests are done with real request patterns: sudden load, long-duration load, write load, a giant account (a million followers), failure (database restart), media upload, attack drill. When the design changes, the load test scenarios are updated too.- But nothing is optimized without measuring (§7 XL).
- The user should never end up in a “busy” state: the system is built solid enough not to fall into it; 429 on reads and 503 +
Retry-Afteron writes are only the last safety; a capacity or connection problem is never a 500. If the error rate is not zero at the load test’s target levels, it is a finding. [XL]Load test coverage map: every endpoint, every scheduled job and every scenario kind (level, audit — unauthorized request, race, mass assignment, per-account limit —, write, failure) are mapped on one chart; a new endpoint with no map entry turns the guard red. For every new feature, load tests of all kinds are written in the same round.
10. Topic-specific additions
10.1 Apps that use AI (LLM) [M+]
- The API key is on the server; it is not sent to the client. There is a quota and a cost limit per user and per account.
- User data is minimized and masked before it is sent to the provider. Which data goes is written in the disclosure text.
- Against prompt injection: user or document content is not treated as instructions. Tool calls go through the permission check. Model output is not written to the database or another system without validation.
- Model name and parameters are verified from official documentation, not written from memory.
- Personal records such as reminders and notes follow the same retention and deletion rules as other personal data.
10.2 Mobile apps [M+]
- Native packages are installed with the platform tool (§3). A real-device test is done; an emulator is not enough.
- Platform policies are read from the official source before coding (Google Play and App Store permissions, the data safety form). The least-permission principle is applied: if the system picker is enough, no broad permission is requested.
- Other people’s media is not written to the phone disk (privacy). Upload can continue in the background and resume where it stopped.
- There is a forced-update mechanism.
10.3 Multiple languages [M+ if needed]
- Screen texts are kept in language files; a missing translation is caught by a guard. If the phone’s language is not supported, English is shown.
- Date and number are shown in the person’s language and time zone. A “day” is the person’s day, not UTC.
- The list of supported languages comes from one source; tests run automatically in every language. A newly added language also enters the automatic tests.
- Architecture ready for hundreds of languages: language codes are BCP 47 (including script distinction, for example
az-Latn); ICU message format for singular / plural / gender, sentence fragments are not glued together; date / number / currency by CLDR rules; texts are normalized to Unicode NFC; a mirrorable layout for right-to-left languages; a font covering all scripts; buttons that do not overflow even when text grows 40%; a fallback language chain (az-AZ→az→en); the app downloads only the user’s language file. - Translation is only for the app’s fixed texts; text written by users is not translated. Legal texts are translated with human review.
- Guards: no hard-coded text in code, no missing translation, valid ICU syntax, a “pseudo-language” test (overflow is caught with stretched, accented text), a right-to-left screen test.
10.4 Accessibility [S+]
- Target: WCAG 2.2 AA. Screen reader labels, sufficient colour contrast, sufficient touch target, keyboard navigation, a focus indicator, respecting the reduced-motion preference.
[L+]An accessibility guard (automatic scan) and a manual screen reader check.
11. Working environment: GitHub, local, cloud
The same rules apply in every environment.
- GitHub: the agent works on its own branch. Merging to the main branch and releasing are done only with the project owner’s word. CI uses paid minutes; the same checks run first locally (§5). If there is a PR template, it is followed.
- Local computer: the rules are enforced with git hooks: a check before pushing, a secret scan.
[M+]The local test environment is set up with one command. - Cloud sessions (temporary machines): the machine can restart at any moment. Finished work is pushed at once; a push is made at least every few hours.
[L+]At session start a script lists whether the machine restarted and which commits are unpushed. - Secret scanning is done before pushing and in CI (for example secretlint, gitleaks).
[M+] - Long jobs are interruption-tolerant: a large test resumes where it stopped; a job running on a remote machine continues even if the person who started the command turns off their computer.
12. Multi-session work [XL]
In large projects the context of a single session is not enough. Division of work:
| Session | Task | Prohibitions |
|---|---|---|
| Manager | Takes the work from the project owner, gives it to the right session, verifies the results, gives a short report. | Does not write code. |
| Code | Writes, tests, pushes, updates documents. Does the research needed for its own work itself. | Main and release only with the owner’s word. |
| Research | Does research on official sources, policies and documents; brings exact quotes. | Does not change files, does not commit. |
| Measurement | Does code review and measurement (query plan, size, load). | Does not change files, does not commit. |
- All reports go to one manager address. When the manager changes, the new address is told to all sessions and written to HANDOFF.
- Messages can be delayed in the queue: if a critical instruction is not mentioned in a report, it is sent again.
- When the project owner’s word is passed on, it is quoted exactly and the place of the record is stated.
- Two sessions do not use the same database or results folder at the same time (tests would disturb each other).
13. Starting instruction template
When starting a new project, give the agent this:
In this project you will work by the rules of the attached PROJE-CALISMA-KILAVUZU.md.
1. Put the guide in the repository: docs/PROJE-CALISMA-KILAVUZU.md. Commit and push.
2. Decide the project class (S/M/L/XL) by §1 and write the reason in one sentence.
3. If the repository has no CLAUDE.md/AGENTS.md and HANDOFF.md, create them with the
templates in §14. Write into CLAUDE.md the project class, the path of the guide and a
short summary of "the rules that fit the class" (§0.7). Commit and push these too.
4. Apply the rules that fit the class, not those outside it (proportionality, §0.4).
5. The project owner does not know code; speak briefly, simplify concepts.
6. Ask the owner product decisions; on technical decisions follow the guide.
7. Update HANDOFF.md at the end of every work round.
Purpose of the project: <one paragraph>
This instruction is given only in the first session. Later sessions read CLAUDE.md on their own; thanks to the path and summary there, the guide does not need to be given again.
14. Templates
14.1 CLAUDE.md / AGENTS.md skeleton
# <Project name>: Project context
Project class: <S/M/L/XL> (reason). Guide: docs/PROJE-CALISMA-KILAVUZU.md
(opened in full only when the relevant topic comes up)
⛔ Every session reads HANDOFF.md after this file and updates it at the end of a work round.
## Rules valid in this class (short summary from the guide, 10–30 lines)
## What this project is
## Stack (language, framework, database, storage, hosting)
## Monorepo / folder structure
## Critical rules (project-specific, numbered)
## Document index (decision records, open issues, deletion schedule)
## About the project owner / communication
14.2 HANDOFF.md skeleton
# HANDOFF: where we stopped
## 🔴 Current status (5–10 lines, dated)
## ⏳ Open instructions (the owner's, not yet done)
## ❓ Decisions expected from the owner
## 📦 Work waiting on a branch / only local
## 📌 Rule changes (dated one-liners)
## History (moved to the archive when old)
14.3 Decision record skeleton
# <DD-MM-YYYY> <Decision title>
**Decided by:** project owner · **Status:** valid / replaced by: <path>
## Decision
## Reason
## Affected places (code, tests, documents)
## History notes (⛔ date: change)
14.4 Commit message template
<area>: <what changed, short>
<why; which problem it solves>
Side effect: <what was checked, which tests ran, security meaning>
15. One-page checklists by class
S: Promotional site
- Class decided, HANDOFF exists
- Packages from an official source, stable version
- HTTPS, form protection, no secrets on the page
- Mobile width, links and form checked by hand
- Code readable, no dead code
M: Assistant app, small CRM
- The S list
- Accessibility basics, open-source licence page (if a published product)
- Signup security, related records rule, correct deletion / backup schedule in the contract
- If there is an admin panel, it cannot reach private content
- Lockfile, one package manager, one-command setup with Docker
- Ready-made authentication, permission on the server, input validation
- API keys on the server, LLM quota and masking
- Personal data note and deletion schedule
- Automatic backup and a tried restore
- S3-compatible storage, one abstraction layer
- Critical flow tests, local check before pushing, secret scan
L: Complex site, app with an admin panel
- The M list
- Exact version pinning and the 7-day rule, image and action by digest
- Migration ledger, destructive command approval, cursor pagination, EXPLAIN
- IDOR tests, per-account rate limit (CGNAT), no device-based block
- Admin panel: 2FA, roles, audit trail
- File upload order, signed direct upload, orphan scan
- Fail-closed production settings, feature locks
- Encrypted backup at a different provider, code copy
- e2e, short CI run, guards, two themes and all languages
- Handbook and glossary, Side effect line
- Industry standards list (S-codes), limits inventory, “busy” rule
- Order when red, flakiness scan, check first then the big job, audit rounds
- Security scan exception rules, SBOM
XL: Social media, millions of users
- The L list
- Single version catalog, install script approval, audit red
- Mutation proof, accumulation and redraw measurements
- Load test (sudden, long, write, giant account, failure, media) and attack drill
- Hot row, batching, query count guard; optimization by measuring
- Leak detection, decoy key, alarm, key rotation plan
- Disaster recovery plan (RPO / RTO)
- Multi-session order and a single manager address
- Platform policies and lawyer-reviewed texts before release
-
Standard:line and push lock, load test coverage map - Architecture ready for data localization (region information, move tool)
16. Release notes
v1.2 (2026-12-01): the assistant / mobile contradiction in the class table was resolved (the highest row applies); the repetition in the L and XL test rows was removed; added: honest reporting layers (§2.1), interruption and handover rules (§2.3a), audit and large-run rules (§2.6a), sub-agent limit and cost control (§2.6b), open-source licence page, SBOM, security scan exception rules, ecosystem equivalents (§3), industry standards S1–S16 (§4.1), kinds of tests and guards + order when red + flakiness (§5), limits inventory, the admin panel not seeing private content, signup security, username rules (§6), related records rule, correct deletion / backup schedule in the contract, data localization and separate databases (§7), the “busy” rule and the load test coverage map (§9), architecture ready for hundreds of languages (§10.3), accessibility (§10.4).
v1.1 (2026-11-20): first published version.
Sources
- Pro Build Guide v1.2: compiled team practices — Pro Build Guide
- SP 800-218: SSDF Version 1.1 — NIST
- Concise Guide for Developing More Secure Software — OpenSSF
- Application Security Verification Standard (ASVS) — OWASP
- The Twelve-Factor App: III. Config — 12factor.net
- Web Content Accessibility Guidelines (WCAG) 2.2 — W3C
- PostgreSQL: PostgreSQL documentation — PostgreSQL Global Development Group
- Well-Architected: Reliability Pillar — AWS