Imported from andreame-code/netrisk (
AGENTS.md). Install upstream withnpx skills add andreame-code/netrisk. Copyright stays with the author.
NetRisk - Agent Instructions
Mission
Build and evolve NetRisk as a maintainable turn-based strategy game inspired by Risk/Risiko.
The project must remain safe to extend over time, especially as more work is done with AI agents. Prefer small, reviewable, reversible changes over broad rewrites.
Operating mode
For every task:
- Inspect the relevant files before editing.
- State a concise implementation plan unless the task is trivial.
- Change only what is needed for the requested scope.
- Run the most relevant validation available.
- Summarize changed files and why they changed.
- Clearly list remaining risks, skipped checks, or follow-up work.
Do not expand the task beyond what the user asked for unless required to complete it correctly.
If the request is ambiguous, destructive, security-sensitive, or requires a broad architectural change, stop and ask for clarification or explain the trade-off before editing.
Core principles
- Do not rewrite entire files unless explicitly requested or clearly safer than patching.
- Do not rebuild working systems just because a cleaner design exists.
- Preserve existing behavior unless the requested change requires otherwise.
- Keep one concern per change whenever possible.
- Prefer adding small modules over heavily mutating large files.
- Do not mix cosmetic refactors with feature work.
- Do not touch unrelated files.
- Avoid new dependencies unless they materially reduce risk or complexity.
- If adding a dependency, explain why it is needed and where it is used.
- Delete code only when it is obsolete, duplicated, unsafe, or directly replaced by the change; explain the deletion.
- Do not rename files, folders, exported functions, or public interfaces unless the requested change requires it.
- Keep changes easy to review, revert, and test.
Architecture rules
- The backend is the source of truth for game state and rule validation.
- The frontend handles rendering, user input, local UI state, and presentation only.
- Game rules must not be duplicated between frontend and backend.
- Shared models, DTOs, enums, and schemas must live in the shared area when consumed by both sides.
- Game logic must live in dedicated engine modules, not inside React components or route handlers.
- Keep transport, persistence, and game rules separated.
- Backend APIs must validate inbound payloads and critical outbound responses.
- Frontend code must validate remote payloads at the boundary before UI consumption.
- Validation schemas describe transport shape only; they must not duplicate game-rule logic.
- Backward compatibility must be preserved unless the user explicitly asks for a breaking change.
Language policy
- NetRisk should evolve toward pure TypeScript.
- New application code must be TypeScript.
- Legacy JavaScript may remain when needed for compatibility or when converting it would create unnecessary risk.
- Do not introduce new non-TypeScript application code unless there is a clear compatibility reason.
- Config files, scripts, and tooling files may follow the conventions already used in the repository.
Preferred structure
Use the existing repository structure as the source of truth. In general:
frontend: UI, map rendering, panels, local presentation state.backend: API, game orchestration, persistence, multiplayer support.backend/engine: pure game rules, turn logic, combat, reinforcement, movement, victory checks.shared: shared types, DTOs, enums, schemas, runtime validation.
Do not move files or rename exports unless the requested change requires it.
Versioning and compatibility
Use the central Version and Compatibility Registry as the source of truth for compatibility-related versions.
- Do not add version constants in random files.
- Keep app, engine, API, datastore, save-game, and module API versions centralized.
- Use
shared/version-manifest.ctsandshared/compatibility.ctsfor existing compatibility decisions. - Create or extend
shared/save-game-migrations.ctsonly when a save-game compatibility change actually requires it. - Saved game state changes must consider save-game schema compatibility.
- Module manifest changes must consider module API compatibility.
- API response shape changes must consider API versioning and runtime validation.
- If a change may break existing saved games, APIs, or modules, call it out explicitly in the PR summary.
- Do not create a broad migration framework unless explicitly requested.
Game-specific guardrails
- Preserve the current map behavior unless the user explicitly asks to change it.
- For game-screen UI work, keep the experience map-centric.
- Menus, panels, dialogs, cards, and action states should visually match the current game direction.
- Do not hide critical game state behind decorative UI.
- Reinforcement, attack, fortification, cards, objectives, and victory logic must be testable outside the UI.
- AI behavior must use the same rules engine as human players.
- Multiplayer and persistence must not bypass backend validation.
- Admin-configurable rules must not create invalid game states.
- Do not move business logic into React components.
- Do not mix transport, persistence, and game rules in one file.
UI and design rules
- Preserve existing layout intent unless the task is specifically a redesign.
- When given screenshots or mockups, treat them as visual constraints.
- Match spacing, density, hierarchy, and interaction style from the provided references.
- Do not change the map when the task only asks for menus, panels, modals, or action states.
- Keep labels accurate: if a tab or section represents cards, do not call it map.
- Prefer incremental UI polish over complete component replacement.
- Avoid introducing a new visual language in only one part of the app.
AI-assisted change safety
AI-generated or AI-assisted code must meet the same standards as handwritten code.
- Prefer small patches with clear intent over large generated rewrites.
- Inspect generated code for duplicated rules, hidden state, broad abstractions, and untested branches.
- Do not accept generated code that bypasses engine boundaries, validation, or compatibility rules.
- Add or update tests when generated code changes behavior.
- Keep domain terminology aligned with
CONTEXT.mdand ADRs when they exist. - If generated code changes architecture, document the reason in the PR summary or an ADR when appropriate.
Testing and validation
Before editing, inspect package.json, workflow files, and existing tests to identify the correct commands.
Use targeted checks during development, then run broader validation before completion when available. Prefer one extra relevant test over an under-validated change.
Typical validation priorities:
- Type checks and builds required by the repo scripts.
- Unit tests for changed game logic.
- React tests for changed UI behavior.
- Integration tests for API, validation, persistence, or module changes.
- E2E tests for game flow, routing, or important UI interactions.
- Lint and formatting checks.
Common local commands include:
npm run typechecknpm run typecheck:frontendnpm run typecheck:react-shellnpm run build:tsnpm run lintnpm run format:checknpm run testnpm run test:gameplaynpm run test:reactnpm run test:e2e:smokenpm run test:allnpm run test:all:e2e
Choose the smallest validation set that proves the change during development, then broaden before push or PR. For risky changes, prefer npm run test:all or npm run test:all:e2e when the environment can support it.
If a command is unavailable, failing for unrelated reasons, or too expensive for the environment, say so clearly and run the next best validation.
Never claim tests passed unless they were actually run and passed.
Git workflow
If working in a writable git repository:
- Check the current branch before editing.
- For implementation tasks that modify files, create or use a dedicated branch for the chat.
- If the worktree is in detached HEAD and the task modifies files, create and switch to
codex/<short-description>before editing. - Do not create unnecessary branches for pure review, planning, explanation, or documentation-only analysis.
- Commit only coherent, validated changes.
- Do not commit secrets, generated junk, local environment files, or unrelated formatting changes.
- Before large or risky changes, create a checkpoint commit or ask the user to confirm the approach.
If GitHub remote access is available and the user asked for implementation:
- Push the branch after local validation passes, unless the user explicitly says not to.
- Create or update a PR when appropriate for the workflow.
- Include a clear PR summary, validation performed, and known risks.
- Do not mark work complete while required local validation is failing.
If GitHub access is not available:
- Provide the patch summary.
- List exact commands the user should run.
- State that push or PR creation was not performed.
CI, Vercel, and PR review
When a PR exists and remote checks are available:
- Check GitHub CI and Vercel preview status if possible.
- If checks fail, inspect the failure and fix actionable issues.
- Re-run relevant local validation before pushing fixes.
- Do not pretend remote checks are green if they are pending, unavailable, or not checked.
Requesting Codex review on a PR is useful only when the environment supports it. Do not block forever waiting for a self-review loop. If Codex review comments are available, fix actionable comments, rerun validation, and update the PR.
Definition of done
A task is complete only when:
- The requested scope has been implemented or clearly explained.
- Relevant files were inspected.
- Relevant validation was run, or unavailable validation was explicitly disclosed.
- Changed files are summarized.
- Risks and follow-ups are listed separately.
- No unrelated changes were introduced.
Development order for NetRisk
Prefer incremental development in this order unless the user asks otherwise:
- Architecture and shared models.
- Map and territories.
- Turn flow.
- Reinforcement rules.
- Combat rules.
- Movement and fortification rules.
- Cards and objectives.
- Victory conditions.
- AI.
- Multiplayer.
- Map editor.
- Custom rules and admin configuration.
Stop conditions
Stop and ask or report before proceeding if:
- The task requires deleting or rewriting large parts of the app.
- The change affects persistence, migrations, saved games, or module compatibility.
- The change introduces authentication, authorization, or security impact.
- The change requires new production dependencies.
- The tests reveal unrelated failures that cannot be safely fixed in scope.
- The requested implementation conflicts with existing architecture.
Communication style
- Be direct and concise.
- Prefer practical progress over speculative redesign.
- Explain trade-offs when there is more than one reasonable path.
- Do not overengineer.
- Do not produce giant rewrites unless explicitly requested.
- Do not hide uncertainty.
Agent skills
These skill settings only configure how Matt Pocock's skills find issue-tracker, triage-label, and domain-doc information. They do not override the NetRisk guardrails, current user request, or repository-specific instructions above.
Issue tracker
Issues and PRDs are tracked in GitHub Issues for andreame-code/netrisk, inferred from the configured origin remote. See docs/agents/issue-tracker.md.
Triage labels
Use the default GitHub Issue label vocabulary: needs-triage, needs-info, ready-for-agent, ready-for-human, and wontfix. See docs/agents/triage-labels.md.
Domain docs
This repo uses a single-context domain docs layout with root CONTEXT.md and ADRs in docs/adr/. See docs/agents/domain.md.
Skill invocation gate
When the user explicitly asks to use Matt Pocock skills, the agent must invoke the requested slash skills explicitly before editing files.
For architecture work that explicitly requests the skill-driven workflow, the minimum required sequence is:
/zoom-out/improve-codebase-architecture/grill-with-docs/tddbefore implementation/diagnoseif validation fails for unclear reasons
The agent must provide visible evidence sections for every requested skill:
- Skill evidence:
/zoom-out - Skill evidence:
/improve-codebase-architecture - Skill evidence:
/grill-with-docs - Skill evidence:
/tdd - Skill evidence:
/diagnose, if used
If a requested slash skill is unavailable, stop and say:
“Requested skill unavailable: /”
Do not silently simulate a skill. Do not continue with ordinary implementation when the user asked for a skill-driven workflow.