|
| 1 | +## Communication & Documentation |
| 2 | + |
| 3 | +- Precise, concise chat replies/updates: Short as possible, detailed enough. |
| 4 | +- Reduce redundancy/duplication unless critical. |
| 5 | +- New docs: High-level TOC at top; checklist + phased format; actionable items visible. Suggest Phase 0 technical spike (1-2h max) to validate assumptions/critical paths first. |
| 6 | +- Do not create new MD/text files unless instructed. Append to existing project docs. |
| 7 | +- Add things to remember to MEMORY.md |
| 8 | +- General workflow: 1-2 step ad-hoc requests to direct implementation. If 4-5 steps with multiple phases, write project MD file first. |
| 9 | +- Slight pushback OK if security/maintainability/destructive risk ahead. |
| 10 | + |
| 11 | +## UI Design |
| 12 | + |
| 13 | +- Layout follows the user's decision sequence, not the system's data structure. |
| 14 | +- Label roles at the point of action — if the user must scroll or remember context to understand what a control does, the label is missing. |
| 15 | +- Every repeated component (card, row, panel) must be self-describing without surrounding context. |
| 16 | +- Design for how the user reads, not how the data is stored or fetched. |
| 17 | +- Default to the most common action. If 80% of users will pick the same option, pre-select it — don't make the majority click what the system already knows. |
| 18 | + |
| 19 | +## Code & Architecture |
| 20 | + |
| 21 | +- Code: DRY, SOLID; balance maintainability, performance, secure. Comply with framework security best practices. |
| 22 | +- **State Management**: Introduce FSM (Finite State Machine) if state transitions exceed 4 distinct states or more than one conditional branch per state. Document state diagram in code comments or `/docs/state-machine.md`. |
| 23 | +- **Contracts**: Designate single writer per contract/schema (API response shape, DB record structure, queue message format). Changes require review from contract owner; broadcast breaking changes immediately. |
| 24 | +- **Pipelines**: One logical pipeline per data flow whenever possible. Avoid forking/rejoining; use filters, transforms, and side effects in sequence. If pipeline needs multiple paths, use conditional routing within single pipeline, not separate pipelines. |
| 25 | + |
| 26 | +## Anti-Patterns to Avoid |
| 27 | + |
| 28 | +- N+1 queries (e.g., loop API/DB calls; batch/paginate instead). |
| 29 | +- Unpaginated API/DB calls (always use `per_page=100`, `page` iteration). |
| 30 | +- Unbound DB queries (add `LIMIT 1000`, timeouts). |
| 31 | +- Infinite loops/recursion without bounds. |
| 32 | +- High-rate API bursts (respect GitHub 5000/hr PAT limits; sleep/retry). |
| 33 | +- Hardcoding credentials or secrets in code or config files. |
| 34 | +- Destructive operations without explicit confirmation or dry-run support. |
| 35 | + |
| 36 | +## Security & Credentials |
| 37 | + |
| 38 | +- Do not store credentials, personal/project/client names, most emails in repo unless in confirmed gitignored `/temp/` or config folder. Double-check for leaks. |
| 39 | +- Use environment variables or `.env` files (always gitignore `.env`). Never hardcode credentials. |
| 40 | +- For production integrations, reference Vault, AWS Secrets Manager, or equivalent secret storage. |
| 41 | +- Log credential usage (masked) to audit trail; log actual credential values only to secure, non-repository logs. |
| 42 | +- Mask sensitive data in logs (credentials, tokens, email addresses). |
| 43 | + |
| 44 | +## Destructive Operations |
| 45 | + |
| 46 | +- Log all DELETE/DROP/TRUNCATE operations with timestamp, user, and target to `/logs/agent-audit.json`. |
| 47 | +- Require explicit confirmation flag (e.g., `--confirm` or env var `CONFIRM_DESTRUCTIVE=true`) before executing. |
| 48 | +- Support `--dry-run` mode when applicable; output what _would_ be deleted without executing. |
| 49 | +- If operation affects >1000 rows/records, require additional confirmation or escalation. |
| 50 | +- Pause and escalate if operation is blocked or validation fails; do not retry silently. |
| 51 | + |
| 52 | +## Observability & Tests From Day One |
| 53 | + |
| 54 | +- Every new service, plugin, or pipeline ships with structured logging, health checks, and at least one integration test before merging to main. |
| 55 | +- Instrument first, optimize later. Add timing/counters to critical paths (DB queries, API calls, queue processing) at build time — retrofitting observability is 5x harder. |
| 56 | +- Log with context: every log line should include enough to trace a request end-to-end (request ID, tenant/user ID, operation name). Avoid generic messages like "error occurred." |
| 57 | +- Health check endpoints (`/healthz`, `wp-admin` heartbeat, cron verification) are not optional — they are part of the definition of done. |
| 58 | +- Write the smoke test that proves the happy path works before writing any feature code. If you can't test it, you can't ship it. |
| 59 | +- Alerts should be actionable. If a threshold fires, the runbook or next step should be obvious. No alert without a documented response. |
| 60 | +- For WordPress/WooCommerce: hook into `query_monitor` data, log slow queries (>500ms), and monitor Action Scheduler queue depth from the start. |
| 61 | +- Dashboards and log queries are deliverables, not afterthoughts. Include them in the PR or project doc alongside the code. |
| 62 | + |
| 63 | +## Testing & Mock Harnesses |
| 64 | + |
| 65 | +- Write tests _before_ integrating with external APIs. Use mock harnesses to simulate responses. |
| 66 | +- Mock harnesses should cover: happy path, rate limits (429), timeouts (504), malformed responses, and auth failures (401/403). |
| 67 | +- Store mock response fixtures in `/fixtures/` (JSON, YAML, or plaintext). Keep them realistic and versioned. |
| 68 | +- Use conditional logic or env vars (`MOCK_MODE=true`) to toggle between real and mock backends without code changes. |
| 69 | +- For external integrations (Shopify, WooCommerce, Meta Ads, GA4), create a mock server or HTTP interceptor (e.g., `nock` in Node, `responses` in Python, `http-mock` in Go). |
| 70 | +- Test both sync and async paths separately; async errors (timeouts, retries) are common blindspots. |
| 71 | +- Assert on side effects (logs, DB writes, queue messages) not just return values. Mock should verify agent behavior, not just response parsing. |
| 72 | + |
| 73 | +## Versioning & Changelog |
| 74 | + |
| 75 | +- There is no concept of "Unreleased." Every fix or feature gets a version bump at time of commit/merge. |
| 76 | +- Use semver: MAJOR for breaking changes, MINOR for features, PATCH for fixes. |
| 77 | +- Documentation-only changes do not increment version unless explicitly instructed. |
| 78 | +- Changelog entries describe _what changed and why_ in plain language. Do not include project names, filenames, or folder paths in changelog entries — those belong in `4X4.md` or project docs, not the changelog. |
| 79 | +- Format: `## [x.y.z] - YYYY-MM-DD` followed by `### Added`, `### Changed`, `### Fixed`, `### Removed` as applicable. |
| 80 | + |
| 81 | +## Monitoring & Safety |
| 82 | + |
| 83 | +- Audit deps weekly (`safety check`, Dependabot). |
| 84 | +- Rate limit APIs; exponential backoff on 429s. |
| 85 | + |
| 86 | +## Phase 0 Technical Spikes |
| 87 | + |
| 88 | +- When proposing phased work, include Phase 0 spike (1–2h max) to validate critical assumptions. |
| 89 | +- Phase 0 should test: API availability, DB connectivity, performance baseline, and blocking dependencies. |
| 90 | +- If Phase 0 surfaces blockers or contradicts assumptions, pause and escalate; do not proceed to Phase 1. |
| 91 | +- Document Phase 0 findings in spike report before committing to later phases. |
| 92 | + |
| 93 | +--- |
| 94 | + |
| 95 | +## 4X4 Template |
| 96 | + |
| 97 | +**Extract into separate `4X4.md` file.** If one exists already, rename existing to `4X4-deprecated.md`. |
| 98 | + |
| 99 | +**Why it's called 4X4:** 4 Domains (Strategic Goals, Current Goals, Past Goals, Lessons Learned) × 4 Tasks |
| 100 | + |
| 101 | +Keep this file short and sweet. Enough details but barely enough to point in the right direction. Start with only 4 weekly goals. Cross those off first before adding more. |
| 102 | + |
| 103 | +``` |
| 104 | +PROJECT OVERVIEW |
| 105 | +[insert here] |
| 106 | +
|
| 107 | +PROJECT ANTI-GOALS (OPTIONAL) |
| 108 | +
|
| 109 | +A. STRATEGIC GOALS |
| 110 | +1. [insert here] |
| 111 | +2. [insert here] |
| 112 | +3. [insert here] |
| 113 | +4. [insert here] |
| 114 | +
|
| 115 | +B. CURRENT WEEK GOALS |
| 116 | +1. [insert here] |
| 117 | +2. [insert here] |
| 118 | +3. [insert here] |
| 119 | +4. [insert here] |
| 120 | +
|
| 121 | +C. LAST WEEKS ACCOMPLISHMENTS |
| 122 | +1. [insert here] |
| 123 | +2. [insert here] |
| 124 | +3. [insert here] |
| 125 | +4. [insert here] |
| 126 | +
|
| 127 | +D. RECENT LESSONS LEARNED |
| 128 | +1. [insert here] |
| 129 | +2. [insert here] |
| 130 | +3. [insert here] |
| 131 | +4. [insert here] |
| 132 | +``` |
| 133 | + |
| 134 | +--- |
| 135 | + |
| 136 | +Attn: LLM Remove 4X4 section after extraction. |
0 commit comments