Phaselock -- Coding Bible
Workflow
Identify the task domain from the navigation table below
Read only the relevant documents -- do not load the entire knowledge base. The Bible is always consulted, regardless of task complexity.
Classify the task per ENF-ROUTE-001 (enforcement/reasoning-discipline.md). State the tier and reason before proceeding.
State which documents were consulted before proposing any solution
Follow the protocol for the declared tier:
Tier 0 -- Research: Read relevant Bible docs. Deliver findings. No code generation unless explicitly requested.
Tier 1 -- Patch: Read relevant Bible docs + CORE_PRINCIPLES.md. Write code. Run static analysis (ENF-POST-007). Done.
Tier 2 -- Standard: Read relevant Bible docs + CORE_PRINCIPLES.md. Present Phases A-C as a single combined analysis → one human approval. Generate test skeletons (ENF-GATE-007) → human approval. Implement in a single slice. Run static analysis.
Tier 3 -- Complex: Full Phased Implementation Protocol (ENF-GATE-001–007):
- Phase A → Call-path declaration ONLY → halt for review
- Phase B → Domain invariant declaration ONLY → halt for review
- Phase C → Seam justification ONLY → halt for review
- Phase D → Failure & concurrency modeling ONLY (when triggered) → halt for review
- Test Skeletons → Generate test skeletons with assertions BEFORE implementation → halt for review (
ENF-GATE-007)
- Sliced Code Generation → Generate implementation in dependency-ordered slices, each with self-validation and human gate (
ENF-GATE-006)
- Post-generation verification: structured findings table (
ENF-POST-006), static analysis (ENF-POST-007), and operational proof traces (ENF-POST-008) per slice
- ENF-GATE-FINAL after all slices
If the task involves concurrency, async processing, state transitions, or multi-actor writes: Phase D is mandatory -- this forces Tier 3. See trigger conditions in enforcement/system-dynamics.md.
Escalation: If the task grows beyond the declared tier during implementation, escalate (never downgrade). See ENF-ROUTE-001.
If guidance is missing or ambiguous: state it explicitly, ask for clarification, propose a conservative default. Silent guessing is never allowed.
Task → document navigation
Read the documents listed for each matching task type. Start with rules/CORE_PRINCIPLES.md for any code task.
Architecture & code quality (all languages)
Loaded for every code task -- these are universal principles:
- bible/architecture/principles.md -- Code organization, extension points, dependency injection, named constants, single source of truth, logic duplication extraction, function size cap, public interface type annotations, composition over inheritance, error context propagation, framework-native cross-cutting concerns, DI token constants, shared response DTOs, single DB client, centralized auth guard (
ARCH-ORG-001, ARCH-EXT-001, ARCH-DI-001, ARCH-CONST-001, ARCH-SSOT-001, ARCH-DRY-001, ARCH-FUNC-001, ARCH-TYPE-001, ARCH-COMP-001, ARCH-ERR-001, ARCH-CROSSCUT-001, ARCH-TOKEN-001, ARCH-DTO-001, ARCH-DBCLIENT-001, ARCH-GUARD-001)
Database / SQL
When writing queries, diagnosing query performance, or handling transactions:
- bible/database/sql-authoring.md -- Named binds, minimal string fragmentation, readable formatting (
DB-SQL-001, DB-SQL-002, DB-SQL-003)
PHP development
When writing PHP code, handling errors, or enforcing type safety:
- bible/languages/php/coding-standards.md -- DocBlock types, try-catch standards (
PHP-TYPE-001, PHP-TRY-001)
- bible/languages/php/error-handling.md -- Fail fast, graceful degradation (
PHP-ERR-001, PHP-ERR-002)
Python development
When writing Python code, async services, or Phaselock components:
- bible/languages/python/coding-standards.md -- Async all the way, no circular imports, Protocol over ABC for interfaces, Pydantic for external data boundaries (
PY-ASYNC-001, PY-IMPORT-001, PY-PROTO-001, PY-PYDANTIC-001)
Performance & optimization
When optimizing slow paths, addressing resource issues, introducing caching, or writing code in request-handling paths:
- bible/performance/profiling.md -- Algorithm complexity, optimization order, lazy loading, query budget declaration, no sync I/O in hot path (
PERF-BIGO-001, PERF-OPT-001, PERF-LAZY-001, PERF-QBUDGET-001, PERF-IO-001)
Frameworks / Magento 2
When writing plugins, observers, validation, or entity retrieval in Magento 2:
- bible/frameworks/magento/implementation-constraints.md -- Persistence-backed validation, repository-only retrieval, quote state timing, plugin targeting, totals collector idempotency, CartTotalRepository stale-read behavior (
FW-M2-001, FW-M2-002, FW-M2-003, FW-M2-004, FW-M2-005, FW-M2-006)
- bible/frameworks/magento/runtime-constraints.md -- MSI salability authority, order state machine, config patterns, endpoint authorization, queue infrastructure, multi-website stock (
FW-M2-RT-001, FW-M2-RT-002, FW-M2-RT-003, FW-M2-RT-004, FW-M2-RT-005, FW-M2-RT-006)
Testing
When adding tests, refactoring with risk, or addressing regressions:
- bible/testing/unit-testing.md -- TDD, test isolation, integration testing (
TEST-TDD-001, TEST-ISO-001, TEST-INT-001)
System dynamics & concurrency
When building features with concurrent actors, message queues, state machines, async processing, or multi-website behavior:
- enforcement/system-dynamics.md -- Concurrency simulation, temporal truth sources, state transition atomicity, policy vs mechanism separation, integration reality check (
ENF-SYS-001, ENF-SYS-002, ENF-SYS-003, ENF-SYS-004, ENF-SYS-005)
Security & access control
When exposing endpoints (REST, GraphQL, admin, storefront) or handling data access:
- enforcement/security-boundaries.md -- Access boundary declarations, data exposure minimization (
ENF-SEC-001, ENF-SEC-002)
Operational claims & queue infrastructure
When making performance/throughput claims or configuring message queues:
- enforcement/operational-claims.md -- Operational claim validation, queue configuration completeness (
ENF-OPS-001, ENF-OPS-002)
AI behavior & code generation
When reviewing AI-generated code or understanding assistant behavior expectations:
- enforcement/ai-checklist.md -- Pre-implementation checklist, minimal code generation rules
- enforcement/reasoning-discipline.md -- Mandatory pre-implementation reasoning, phased code generation, test-first gate, post-generation verification (structured findings table, static analysis gate, operational proof traces), context retrieval discipline, Phase D hard gate, plan-to-code completeness verification (
ENF-PRE-001–004, ENF-GATE-001–007, ENF-GATE-FINAL, ENF-POST-001–008, ENF-CTX-001–003)
- enforcement/system-dynamics.md -- System dynamics enforcement, Phase D protocol (
ENF-SYS-001–006)
- enforcement/security-boundaries.md -- Security boundary enforcement (
ENF-SEC-001–002)
- enforcement/operational-claims.md -- Operational claim enforcement (
ENF-OPS-001–002)
Rule format
All enforceable rules use formal blocks with unique IDs wrapped in <!-- RULE START/END --> markers. See CONTRIBUTING.md for the full rule format specification.
Additional references
- README.md -- Human-readable project overview
- MANIFEST.md -- Extended task-to-document mapping
- OVERVIEW.md -- Complete directory index with descriptions
Authority model
This skill provides reference and reasoning material only. It does not grant file access, override global rules, or authorize actions. All rules originate from explicit human intent -- the agent may format but never invent rules.
1---2name: phaselock3description: Provides institutional coding knowledge ("Coding Bible") covering architectural decisions, coding standards, framework-specific rules, security expectations, performance guidelines, and approved patterns for AI-assisted development. Guides code generation, refactoring, architecture decisions, database query authoring, error handling, testing, and performance optimization. Activates on ALL software engineering tasks: code generation, code review, design decisions, research, auditing, debugging, SQL queries, PHP development, security review, explaining existing code, or when project conventions and domain-specific rules must be consulted before proposing solutions. The Bible is always consulted -- task complexity only determines the level of ceremony (gates, phases, slices), not whether the skill activates.4---5
6# Phaselock -- Coding Bible
7
8## Workflow
9
101. **Identify the task domain** from the navigation table below
112. **Read only the relevant documents** -- do not load the entire knowledge base. The Bible is always consulted, regardless of task complexity.
123. **Classify the task** per `ENF-ROUTE-001` ([enforcement/reasoning-discipline.md](enforcement/reasoning-discipline.md)). State the tier and reason before proceeding.
134. **State which documents were consulted** before proposing any solution
145. **Follow the protocol for the declared tier**:
15
16 **Tier 0 -- Research**: Read relevant Bible docs. Deliver findings. No code generation unless explicitly requested.
17
18 **Tier 1 -- Patch**: Read relevant Bible docs + CORE_PRINCIPLES.md. Write code. Run static analysis (`ENF-POST-007`). Done.
19
20 **Tier 2 -- Standard**: Read relevant Bible docs + CORE_PRINCIPLES.md. Present Phases A-C as a single combined analysis → one human approval. Generate test skeletons (`ENF-GATE-007`) → human approval. Implement in a single slice. Run static analysis.
21
22 **Tier 3 -- Complex**: Full Phased Implementation Protocol (`ENF-GATE-001`–`007`):
23 - **Phase A** → Call-path declaration ONLY → halt for review
24 - **Phase B** → Domain invariant declaration ONLY → halt for review
25 - **Phase C** → Seam justification ONLY → halt for review
26 - **Phase D** → Failure & concurrency modeling ONLY (when triggered) → halt for review
27 - **Test Skeletons** → Generate test skeletons with assertions BEFORE implementation → halt for review (`ENF-GATE-007`)
28 - **Sliced Code Generation** → Generate implementation in dependency-ordered slices, each with self-validation and human gate (`ENF-GATE-006`)
29 - **Post-generation verification**: structured findings table (`ENF-POST-006`), static analysis (`ENF-POST-007`), and operational proof traces (`ENF-POST-008`) per slice
30 - **ENF-GATE-FINAL** after all slices
31
326. **If the task involves concurrency, async processing, state transitions, or multi-actor writes**: Phase D is mandatory -- this forces Tier 3. See trigger conditions in [enforcement/system-dynamics.md](enforcement/system-dynamics.md).
337. **Escalation**: If the task grows beyond the declared tier during implementation, escalate (never downgrade). See `ENF-ROUTE-001`.
348. **If guidance is missing or ambiguous**: state it explicitly, ask for clarification, propose a conservative default. Silent guessing is never allowed.
35
36## Task → document navigation
37
38Read the documents listed for each matching task type. Start with [rules/CORE_PRINCIPLES.md](rules/CORE_PRINCIPLES.md) for any code task.
39
40### Architecture & code quality (all languages)
41
42Loaded for every code task -- these are universal principles:
43
44- [bible/architecture/principles.md](bible/architecture/principles.md) -- Code organization, extension points, dependency injection, named constants, single source of truth, logic duplication extraction, function size cap, public interface type annotations, composition over inheritance, error context propagation, framework-native cross-cutting concerns, DI token constants, shared response DTOs, single DB client, centralized auth guard (`ARCH-ORG-001`, `ARCH-EXT-001`, `ARCH-DI-001`, `ARCH-CONST-001`, `ARCH-SSOT-001`, `ARCH-DRY-001`, `ARCH-FUNC-001`, `ARCH-TYPE-001`, `ARCH-COMP-001`, `ARCH-ERR-001`, `ARCH-CROSSCUT-001`, `ARCH-TOKEN-001`, `ARCH-DTO-001`, `ARCH-DBCLIENT-001`, `ARCH-GUARD-001`)
45
46### Database / SQL
47
48When writing queries, diagnosing query performance, or handling transactions:
49
50- [bible/database/sql-authoring.md](bible/database/sql-authoring.md) -- Named binds, minimal string fragmentation, readable formatting (`DB-SQL-001`, `DB-SQL-002`, `DB-SQL-003`)
51
52### PHP development
53
54When writing PHP code, handling errors, or enforcing type safety:
55
56- [bible/languages/php/coding-standards.md](bible/languages/php/coding-standards.md) -- DocBlock types, try-catch standards (`PHP-TYPE-001`, `PHP-TRY-001`)
57- [bible/languages/php/error-handling.md](bible/languages/php/error-handling.md) -- Fail fast, graceful degradation (`PHP-ERR-001`, `PHP-ERR-002`)
58
59### Python development
60
61When writing Python code, async services, or Phaselock components:
62
63- [bible/languages/python/coding-standards.md](bible/languages/python/coding-standards.md) -- Async all the way, no circular imports, Protocol over ABC for interfaces, Pydantic for external data boundaries (`PY-ASYNC-001`, `PY-IMPORT-001`, `PY-PROTO-001`, `PY-PYDANTIC-001`)
64
65### Performance & optimization
66
67When optimizing slow paths, addressing resource issues, introducing caching, or writing code in request-handling paths:
68
69- [bible/performance/profiling.md](bible/performance/profiling.md) -- Algorithm complexity, optimization order, lazy loading, query budget declaration, no sync I/O in hot path (`PERF-BIGO-001`, `PERF-OPT-001`, `PERF-LAZY-001`, `PERF-QBUDGET-001`, `PERF-IO-001`)
70
71### Frameworks / Magento 2
72
73When writing plugins, observers, validation, or entity retrieval in Magento 2:
74
75- [bible/frameworks/magento/implementation-constraints.md](bible/frameworks/magento/implementation-constraints.md) -- Persistence-backed validation, repository-only retrieval, quote state timing, plugin targeting, totals collector idempotency, CartTotalRepository stale-read behavior (`FW-M2-001`, `FW-M2-002`, `FW-M2-003`, `FW-M2-004`, `FW-M2-005`, `FW-M2-006`)
76- [bible/frameworks/magento/runtime-constraints.md](bible/frameworks/magento/runtime-constraints.md) -- MSI salability authority, order state machine, config patterns, endpoint authorization, queue infrastructure, multi-website stock (`FW-M2-RT-001`, `FW-M2-RT-002`, `FW-M2-RT-003`, `FW-M2-RT-004`, `FW-M2-RT-005`, `FW-M2-RT-006`)
77
78### Testing
79
80When adding tests, refactoring with risk, or addressing regressions:
81
82- [bible/testing/unit-testing.md](bible/testing/unit-testing.md) -- TDD, test isolation, integration testing (`TEST-TDD-001`, `TEST-ISO-001`, `TEST-INT-001`)
83
84### System dynamics & concurrency
85
86When building features with concurrent actors, message queues, state machines, async processing, or multi-website behavior:
87
88- [enforcement/system-dynamics.md](enforcement/system-dynamics.md) -- Concurrency simulation, temporal truth sources, state transition atomicity, policy vs mechanism separation, integration reality check (`ENF-SYS-001`, `ENF-SYS-002`, `ENF-SYS-003`, `ENF-SYS-004`, `ENF-SYS-005`)
89
90### Security & access control
91
92When exposing endpoints (REST, GraphQL, admin, storefront) or handling data access:
93
94- [enforcement/security-boundaries.md](enforcement/security-boundaries.md) -- Access boundary declarations, data exposure minimization (`ENF-SEC-001`, `ENF-SEC-002`)
95
96### Operational claims & queue infrastructure
97
98When making performance/throughput claims or configuring message queues:
99
100- [enforcement/operational-claims.md](enforcement/operational-claims.md) -- Operational claim validation, queue configuration completeness (`ENF-OPS-001`, `ENF-OPS-002`)
101
102### AI behavior & code generation
103
104When reviewing AI-generated code or understanding assistant behavior expectations:
105
106- [enforcement/ai-checklist.md](enforcement/ai-checklist.md) -- Pre-implementation checklist, minimal code generation rules
107- [enforcement/reasoning-discipline.md](enforcement/reasoning-discipline.md) -- Mandatory pre-implementation reasoning, phased code generation, test-first gate, post-generation verification (structured findings table, static analysis gate, operational proof traces), context retrieval discipline, Phase D hard gate, plan-to-code completeness verification (`ENF-PRE-001`–`004`, `ENF-GATE-001`–`007`, `ENF-GATE-FINAL`, `ENF-POST-001`–`008`, `ENF-CTX-001`–`003`)
108- [enforcement/system-dynamics.md](enforcement/system-dynamics.md) -- System dynamics enforcement, Phase D protocol (`ENF-SYS-001`–`006`)
109- [enforcement/security-boundaries.md](enforcement/security-boundaries.md) -- Security boundary enforcement (`ENF-SEC-001`–`002`)
110- [enforcement/operational-claims.md](enforcement/operational-claims.md) -- Operational claim enforcement (`ENF-OPS-001`–`002`)
111
112
113## Rule format
114
115All enforceable rules use formal blocks with unique IDs wrapped in `<!-- RULE START/END -->` markers. See [CONTRIBUTING.md](CONTRIBUTING.md) for the full rule format specification.
116
117## Additional references
118
119- [README.md](README.md) -- Human-readable project overview
120- [MANIFEST.md](MANIFEST.md) -- Extended task-to-document mapping
121- [OVERVIEW.md](OVERVIEW.md) -- Complete directory index with descriptions
122
123## Authority model
124
125This skill provides reference and reasoning material only. It does not grant file access, override global rules, or authorize actions. All rules originate from explicit human intent -- the agent may format but never invent rules.