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: phaselock
3description: >
4 Provides institutional coding knowledge ("Coding Bible") covering architectural
5 decisions, coding standards, framework-specific rules, security expectations,
6 performance guidelines, and approved patterns for AI-assisted development.
7 Guides code generation, refactoring, architecture decisions, database query
8 authoring, error handling, testing, and performance optimization. Activates on
9 ALL software engineering tasks: code generation, code review, design decisions,
10 research, auditing, debugging, SQL queries, PHP development, security review,
11 explaining existing code, or when project conventions and domain-specific rules
12 must be consulted before proposing solutions. The Bible is always consulted --
13 task complexity only determines the level of ceremony (gates, phases, slices),
14 not whether the skill activates.
15metadata:
16 source: https://skillmd.com/skills/aibot88/phaselock
17 author: lucio-saldivar
18 version: "1.0"
19---
20
21# Phaselock -- Coding Bible
22
23## Workflow
24
251. **Identify the task domain** from the navigation table below
262. **Read only the relevant documents** -- do not load the entire knowledge base. The Bible is always consulted, regardless of task complexity.
273. **Classify the task** per `ENF-ROUTE-001` ([enforcement/reasoning-discipline.md](enforcement/reasoning-discipline.md)). State the tier and reason before proceeding.
284. **State which documents were consulted** before proposing any solution
295. **Follow the protocol for the declared tier**:
30
31 **Tier 0 -- Research**: Read relevant Bible docs. Deliver findings. No code generation unless explicitly requested.
32
33 **Tier 1 -- Patch**: Read relevant Bible docs + CORE_PRINCIPLES.md. Write code. Run static analysis (`ENF-POST-007`). Done.
34
35 **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.
36
37 **Tier 3 -- Complex**: Full Phased Implementation Protocol (`ENF-GATE-001`–`007`):
38 - **Phase A** → Call-path declaration ONLY → halt for review
39 - **Phase B** → Domain invariant declaration ONLY → halt for review
40 - **Phase C** → Seam justification ONLY → halt for review
41 - **Phase D** → Failure & concurrency modeling ONLY (when triggered) → halt for review
42 - **Test Skeletons** → Generate test skeletons with assertions BEFORE implementation → halt for review (`ENF-GATE-007`)
43 - **Sliced Code Generation** → Generate implementation in dependency-ordered slices, each with self-validation and human gate (`ENF-GATE-006`)
44 - **Post-generation verification**: structured findings table (`ENF-POST-006`), static analysis (`ENF-POST-007`), and operational proof traces (`ENF-POST-008`) per slice
45 - **ENF-GATE-FINAL** after all slices
46
476. **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).
487. **Escalation**: If the task grows beyond the declared tier during implementation, escalate (never downgrade). See `ENF-ROUTE-001`.
498. **If guidance is missing or ambiguous**: state it explicitly, ask for clarification, propose a conservative default. Silent guessing is never allowed.
50
51## Task → document navigation
52
53Read the documents listed for each matching task type. Start with [rules/CORE_PRINCIPLES.md](rules/CORE_PRINCIPLES.md) for any code task.
54
55### Architecture & code quality (all languages)
56
57Loaded for every code task -- these are universal principles:
58
59- [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`)
60
61### Database / SQL
62
63When writing queries, diagnosing query performance, or handling transactions:
64
65- [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`)
66
67### PHP development
68
69When writing PHP code, handling errors, or enforcing type safety:
70
71- [bible/languages/php/coding-standards.md](bible/languages/php/coding-standards.md) -- DocBlock types, try-catch standards (`PHP-TYPE-001`, `PHP-TRY-001`)
72- [bible/languages/php/error-handling.md](bible/languages/php/error-handling.md) -- Fail fast, graceful degradation (`PHP-ERR-001`, `PHP-ERR-002`)
73
74### Python development
75
76When writing Python code, async services, or Phaselock components:
77
78- [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`)
79
80### Performance & optimization
81
82When optimizing slow paths, addressing resource issues, introducing caching, or writing code in request-handling paths:
83
84- [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`)
85
86### Frameworks / Magento 2
87
88When writing plugins, observers, validation, or entity retrieval in Magento 2:
89
90- [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`)
91- [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`)
92
93### Testing
94
95When adding tests, refactoring with risk, or addressing regressions:
96
97- [bible/testing/unit-testing.md](bible/testing/unit-testing.md) -- TDD, test isolation, integration testing (`TEST-TDD-001`, `TEST-ISO-001`, `TEST-INT-001`)
98
99### System dynamics & concurrency
100
101When building features with concurrent actors, message queues, state machines, async processing, or multi-website behavior:
102
103- [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`)
104
105### Security & access control
106
107When exposing endpoints (REST, GraphQL, admin, storefront) or handling data access:
108
109- [enforcement/security-boundaries.md](enforcement/security-boundaries.md) -- Access boundary declarations, data exposure minimization (`ENF-SEC-001`, `ENF-SEC-002`)
110
111### Operational claims & queue infrastructure
112
113When making performance/throughput claims or configuring message queues:
114
115- [enforcement/operational-claims.md](enforcement/operational-claims.md) -- Operational claim validation, queue configuration completeness (`ENF-OPS-001`, `ENF-OPS-002`)
116
117### AI behavior & code generation
118
119When reviewing AI-generated code or understanding assistant behavior expectations:
120
121- [enforcement/ai-checklist.md](enforcement/ai-checklist.md) -- Pre-implementation checklist, minimal code generation rules
122- [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`)
123- [enforcement/system-dynamics.md](enforcement/system-dynamics.md) -- System dynamics enforcement, Phase D protocol (`ENF-SYS-001`–`006`)
124- [enforcement/security-boundaries.md](enforcement/security-boundaries.md) -- Security boundary enforcement (`ENF-SEC-001`–`002`)
125- [enforcement/operational-claims.md](enforcement/operational-claims.md) -- Operational claim enforcement (`ENF-OPS-001`–`002`)
126
127
128## Rule format
129
130All 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.
131
132## Additional references
133
134- [README.md](README.md) -- Human-readable project overview
135- [MANIFEST.md](MANIFEST.md) -- Extended task-to-document mapping
136- [OVERVIEW.md](OVERVIEW.md) -- Complete directory index with descriptions
137
138## Authority model
139
140This 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.