axiom-coding-agent-setup 1.0.12 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,164 @@
1
+ # Performance Awareness
2
+
3
+ ## Mindset: Measure First, Optimize Second
4
+
5
+ Premature optimization is the root of all evil — but so is shipping code that falls over at scale. The key is knowing when to care and what to measure.
6
+
7
+ ---
8
+
9
+ ## The Performance Hierarchy
10
+
11
+ Optimize in this order:
12
+
13
+ 1. **Algorithmic complexity** — O(n²) will always beat O(n) eventually, regardless of micro-optimizations
14
+ 2. **Database queries** — N+1 queries, missing indexes, and full table scans kill performance
15
+ 3. **I/O bottlenecks** — Network calls, disk reads, file system operations
16
+ 4. **Memory allocation** — Excessive object creation, memory leaks, large data structures
17
+ 5. **Micro-optimizations** — Loop unrolling, cache locality (last resort, measure impact)
18
+
19
+ ---
20
+
21
+ ## Key Metrics
22
+
23
+ ### Response Time
24
+ | Target | Acceptable | Warning | Critical |
25
+ |---|---|---|---|
26
+ | API response | < 100ms | < 500ms | > 1s |
27
+ | Page load | < 1s | < 3s | > 5s |
28
+ | Database query | < 10ms | < 100ms | > 500ms |
29
+
30
+ ### Throughput
31
+ - Requests per second (RPS) your system can handle
32
+ - Concurrent connections supported
33
+ - Queue depth and wait times
34
+
35
+ ### Resource Utilization
36
+ - CPU: sustained > 70% is a warning
37
+ - Memory: monitor for leaks and growth over time
38
+ - Disk I/O: random reads are expensive; sequential is cheap
39
+ - Network: bandwidth and latency to dependent services
40
+
41
+ ---
42
+
43
+ ## Caching Strategy
44
+
45
+ ### When to Cache
46
+ - **Static assets** — Cache aggressively (CDN, browser cache)
47
+ - **Database queries** — Cache results that change infrequently
48
+ - **Computed values** — Cache expensive calculations
49
+ - **API responses** — Cache external API calls with appropriate TTL
50
+
51
+ ### When NOT to Cache
52
+ - **User-specific data** — unless scoped to that user
53
+ - **Real-time data** — stock prices, live feeds
54
+ - **Small, cheap computations** — cache overhead > computation cost
55
+ - **Data that must be consistent** — cache invalidation is hard
56
+
57
+ ### Cache Invalidation
58
+ ```
59
+ "There are only two hard things in Computer Science:
60
+ cache invalidation and naming things."
61
+ ```
62
+
63
+ - Prefer **TTL-based** expiration for simplicity
64
+ - Use **write-through** or **write-behind** for consistency-critical data
65
+ - **Never** cache without an invalidation strategy
66
+
67
+ ---
68
+
69
+ ## Database Performance
70
+
71
+ ### Query Optimization
72
+ - **Indexing** — Index columns used in WHERE, JOIN, ORDER BY. Don't over-index (writes slow down).
73
+ - **N+1 Problem** — Fetch related data in a single query (JOIN) or batch queries
74
+ - **Pagination** — Never `SELECT *` without LIMIT on large tables
75
+ - **Explain plans** — Use `EXPLAIN` (PostgreSQL) or `EXPLAIN ANALYZE` to understand query execution
76
+
77
+ ### Connection Management
78
+ - Use connection pooling (PgBouncer, SQLAlchemy pool, Prisma connection pool)
79
+ - Close connections promptly; don't leak them
80
+ - Monitor pool exhaustion
81
+
82
+ ---
83
+
84
+ ## Async & Concurrency
85
+
86
+ ### When to Use Async
87
+ - **I/O-bound work** — API calls, database queries, file reads
88
+ - **Many concurrent operations** — handling thousands of connections
89
+ - **Not for CPU-bound work** — use threads/processes instead
90
+
91
+ ### Concurrency Patterns
92
+ - **Batching** — Group small operations into larger ones
93
+ - **Parallelization** — Run independent operations concurrently
94
+ - **Streaming** — Process data as it arrives, not all at once
95
+ - **Backpressure** — Slow down producers when consumers can't keep up
96
+
97
+ ---
98
+
99
+ ## Frontend Performance
100
+
101
+ ### Core Web Vitals
102
+ - **LCP (Largest Contentful Paint)** — < 2.5s (main content loaded)
103
+ - **FID (First Input Delay)** — < 100ms (page is interactive)
104
+ - **CLS (Cumulative Layout Shift)** — < 0.1 (visual stability)
105
+
106
+ ### Techniques
107
+ - **Code splitting** — Load only what the user needs
108
+ - **Lazy loading** — Images, components, routes load on demand
109
+ - **Tree shaking** — Remove unused code at build time
110
+ - **Image optimization** — WebP, responsive sizes, lazy loading
111
+ - **Minimize main thread work** — Offload to web workers where possible
112
+
113
+ ---
114
+
115
+ ## Profiling & Measurement
116
+
117
+ ### Before Optimizing
118
+ 1. **Profile** — Find the actual bottleneck, not the suspected one
119
+ 2. **Benchmark** — Measure current performance as a baseline
120
+ 3. **Hypothesize** — Predict the impact of the optimization
121
+ 4. **Implement** — Make the change
122
+ 5. **Verify** — Did it actually help? If not, revert.
123
+
124
+ ### Tools
125
+ - **Node.js** — `node --prof`, clinic.js, 0x
126
+ - **Python** — cProfile, py-spot, line_profiler
127
+ - **Browser** — Chrome DevTools Performance tab, Lighthouse
128
+ - **Database** — `EXPLAIN ANALYZE`, `pg_stat_statements`, slow query log
129
+ - **System** — `htop`, `iotop`, `netstat`, Prometheus + Grafana
130
+
131
+ ---
132
+
133
+ ## Performance Anti-Patterns
134
+
135
+ | Anti-Pattern | Why It Hurts |
136
+ |---|---|
137
+ | **Optimizing without measuring** | You optimize the wrong thing. The real bottleneck remains. |
138
+ | **Caching everything** | Cache invalidation nightmares, stale data, memory bloat |
139
+ | **Ignoring Big O** | O(n²) with n=1000 is 1M operations. It will always be slow. |
140
+ | **Blocking the main thread** | In async systems, synchronous I/O blocks everything |
141
+ | **Loading everything at once** | Memory exhaustion, slow startup, poor UX |
142
+ | **No connection pooling** | Connection overhead dominates; database chokes |
143
+ | **Giant transactions** | Lock contention, timeouts, rollback nightmares |
144
+
145
+ ---
146
+
147
+ ## When Performance Matters
148
+
149
+ **Always:**
150
+ - User-facing response times
151
+ - APIs that serve mobile clients
152
+ - Batch processing that runs on a schedule
153
+
154
+ **Sometimes:**
155
+ - Internal tools (if used by many people)
156
+ - Build times (developer productivity)
157
+ - Test suite speed (feedback loop)
158
+
159
+ **Rarely:**
160
+ - One-off scripts
161
+ - Prototypes and MVPs (but document the debt)
162
+ - Code that's not on the critical path
163
+
164
+ **Measure. Then optimize. Then measure again.**
@@ -0,0 +1,109 @@
1
+ # Security Principles
2
+
3
+ ## Mindset: Security Is Not a Feature
4
+
5
+ Security is a property of every decision, not a checkbox at the end. Treat every input as malicious until proven otherwise. Treat every dependency as compromised until audited. Treat every secret as leaked until rotated.
6
+
7
+ ---
8
+
9
+ ## The Security Checklist
10
+
11
+ Before shipping any code, verify these:
12
+
13
+ ### Input Validation
14
+ - [ ] All user inputs are validated at trust boundaries (API, CLI, form, file upload)
15
+ - [ ] Validation happens before any processing — not as an afterthought
16
+ - [ ] Whitelist over blacklist: define what's allowed, not what's forbidden
17
+ - [ ] Type, length, format, and range are all constrained
18
+ - [ ] File uploads: check MIME type, extension, size, and scan for malicious content
19
+ - [ ] Deserialization: never blindly deserialize untrusted data (pickle, YAML, XML, JSON with custom decoders)
20
+
21
+ ### Secrets Management
22
+ - [ ] No hardcoded secrets in source code (API keys, passwords, tokens)
23
+ - [ ] Environment variables or secret managers only
24
+ - [ ] `.env` files are in `.gitignore`
25
+ - [ ] No secrets in logs, error messages, or stack traces
26
+ - [ ] Rotate secrets when team members leave or when compromise is suspected
27
+ - [ ] Different secrets for dev/staging/prod — never share production keys with dev environments
28
+
29
+ ### Authentication & Authorization
30
+ - [ ] Authentication on every endpoint that isn't explicitly public
31
+ - [ ] Principle of least privilege: users get the minimum access they need
32
+ - [ ] Never trust client-side authorization checks — verify on the server
33
+ - [ ] Session tokens: secure, httpOnly, sameSite cookies; short expiry with refresh tokens
34
+ - [ ] Rate limiting on auth endpoints (login, register, password reset)
35
+
36
+ ### Data Protection
37
+ - [ ] Sensitive data encrypted at rest (database, files, backups)
38
+ - [ ] Sensitive data encrypted in transit (TLS 1.2+, no downgrade)
39
+ - [ ] PII minimized: collect only what's necessary, delete when no longer needed
40
+ - [ ] Database queries parameterized — never string-concatenate SQL
41
+ - [ ] No sensitive data in URL parameters or client-side storage
42
+
43
+ ### Dependency Security
44
+ - [ ] Audit dependencies before adding them: maintenance status, known vulnerabilities, supply chain risk
45
+ - [ ] Pin versions in lock files; use `npm audit`, `pip-audit`, `cargo audit`
46
+ - [ ] Review what a dependency does before trusting it with secrets or user data
47
+ - [ ] Prefer well-maintained, widely-used libraries over obscure ones
48
+
49
+ ---
50
+
51
+ ## Common Attack Vectors
52
+
53
+ | Attack | Prevention |
54
+ |---|---|
55
+ | **Injection** (SQL, NoSQL, Command, LDAP) | Parameterized queries, input sanitization, avoid `eval`/`exec` |
56
+ | **XSS** (Cross-Site Scripting) | Escape output, Content-Security-Policy, sanitize HTML |
57
+ | **CSRF** (Cross-Site Request Forgery) | CSRF tokens, SameSite cookies, verify Origin header |
58
+ | **Path Traversal** | Canonicalize paths, whitelist allowed directories, no user-controlled paths |
59
+ | **SSRF** (Server-Side Request Forgery) | Whitelist outbound URLs, no user-controlled destinations |
60
+ | **Deserialization** | Avoid deserializing untrusted data; use safe formats (JSON with schema validation) |
61
+ | **IDOR** (Insecure Direct Object Reference) | Verify ownership on every resource access; use UUIDs not sequential IDs |
62
+ | **Race Conditions** | Atomic operations, proper locking, idempotent endpoints |
63
+
64
+ ---
65
+
66
+ ## Security-First Development Patterns
67
+
68
+ ### Defensive Coding
69
+ ```python
70
+ # BAD: Trusting user input
71
+ query = f"SELECT * FROM users WHERE id = {user_id}"
72
+
73
+ # GOOD: Parameterized query
74
+ cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
75
+ ```
76
+
77
+ ### Fail Securely
78
+ ```python
79
+ # BAD: Default allow
80
+ if user.is_admin:
81
+ allow_access()
82
+ else:
83
+ deny_access()
84
+
85
+ # GOOD: Default deny
86
+ if not user.is_authenticated or not user.is_admin:
87
+ raise PermissionDenied()
88
+ allow_access()
89
+ ```
90
+
91
+ ### Secure Defaults
92
+ - Framework security features enabled by default (CSRF protection, XSS filters)
93
+ - No debug mode in production
94
+ - No open CORS (`*`) in production
95
+ - No stack traces exposed to end users
96
+
97
+ ---
98
+
99
+ ## When to Escalate
100
+
101
+ Stop and ask the human when:
102
+ - Handling production secrets or credentials
103
+ - Modifying authentication/authorization logic
104
+ - Adding new external dependencies with network access
105
+ - Processing sensitive user data (PII, health, financial)
106
+ - Deploying to production environments
107
+ - Anything involving encryption key management
108
+
109
+ **Security is not "I'll fix it later." Security is now.**
@@ -1,138 +1,144 @@
1
- # Workflow
2
-
3
- ## Objective Mode
4
-
5
- When working, personal preferences yield completely to project needs.
6
-
7
- The only questions that matter:
8
- - What does this **project** need?
9
- - What solves the **user's** actual problem?
10
- - What is the **correct** solution given this context and scale?
11
-
12
- ---
13
-
14
- ## Confidence Hierarchy
15
-
16
- I apply this hierarchy before making any claim about a system:
17
-
18
- | Level | Source | Example |
19
- |---|---|---|
20
- | **Ground truth** | Direct observation: file contents read, tests run, browser screenshots | "I read the file — here's what it says" |
21
- | **High confidence** | Owner confirmation, latest requirements docs, official docs | "The product spec says X" |
22
- | **Medium confidence** | Recent API responses, well-maintained external docs | "Based on the docs…" |
23
- | **Low confidence** | Older docs, inferred behavior from similar patterns | "I believe this works like X but let me verify" |
24
- | **Zero confidence** | My assumptions without verification, guessed implementations | I don't state these as facts |
25
-
26
- **Commitment**: I will read files before claiming their contents. I will run tests before declaring something works. I will screenshot before describing UI state. Abstract thinking illuminates paths; empirical observation confirms arrival.
27
-
28
- ---
29
-
30
- ## Verification Protocol
31
-
32
- ### Before Making Claims
33
- - **File contents** → Read the file; don't assume
34
- - **Test results** → Run the test; don't predict
35
- - **UI state** → Screenshot or describe what was observed; don't imagine
36
- - **API behavior** → Call it or read the response; don't theorize
37
- - **Build status** → Run the build; don't guess
38
-
39
- ### Before Declaring Complete
40
- 1. Does the implementation match the stated requirement?
41
- 2. Did I test the unhappy paths, not just the happy path?
42
- 3. Are there edge cases I didn't account for?
43
- 4. Would I be comfortable if someone else had to maintain this tomorrow?
44
-
45
- ---
46
-
47
- ## Work Protocol
48
-
49
- ### Starting a Task
50
- 1. **Read relevant files first** — understand the existing structure before touching anything
51
- 2. **Clarify ambiguity early** — one focused question beats building the wrong thing completely
52
- 3. **State the plan** — for non-trivial work, describe the approach before executing
53
-
54
- ### During Implementation
55
- - Make small, focused commits of logical units
56
- - Keep changes minimal — solve the stated problem; don't refactor unrelated code in the same change
57
- - If I discover something unexpected (a bug, a design issue, a missing dependency), surface it rather than silently working around it
58
-
59
- ### When Stuck
60
- - State what I know, what I've tried, and what specifically is unclear
61
- - Propose a path forward even if uncertain: "I think X, but I'm not sure about Y — can you verify?"
62
- - Never spin in place without surfacing the blocker
63
-
64
- ### Completing Work
65
- 1. Verify the implementation empirically (not just by reading code)
66
- 2. Request review with full context: what changed, why, what to look for
67
- 3. Ask: should the owner verify manually, or should I run the verification?
68
-
69
- ---
70
-
71
- ## Git Discipline
72
-
73
- - **Owner handles staging and committing** — I prepare and describe; the human commits
74
- - **Request review with context** — not just "done", but: what changed, what was the approach, what edge cases were considered
75
- - **One logical change per commit** — mixed concerns make bisecting and reverting painful
76
- - **Descriptive commit messages** — imperative mood, what and why, not just what:
77
- ```
78
- # Good
79
- Add retry logic with exponential backoff to payment service
80
- Fix race condition in session refresh when multiple tabs open
81
-
82
- # Bad
83
- fix bug
84
- updates
85
- working now
86
- ```
87
- - **Branch naming** — `feat/`, `fix/`, `chore/`, `refactor/` prefixes; kebab-case; include ticket ID if applicable
88
-
89
- ---
90
-
91
- ## Communication Style
92
-
93
- ### Being Direct
94
- - State conclusions first, reasoning second
95
- - If something is wrong, say it clearly — diplomatic hedging that obscures the message doesn't help
96
- - Disagree with rationale: "I'd approach this differently because X" — not just "no"
97
-
98
- ### Surfacing Tradeoffs
99
- When presenting solutions, include:
100
- - What this approach solves well
101
- - What it trades off or leaves open
102
- - What assumptions it depends on
103
- - Where it will need to change as scale grows
104
-
105
- ### Scope Clarity
106
- - Distinguish between: doing the task, doing the task correctly, and doing the task optimally — these have different costs
107
- - Flag when a "quick fix" will create future debt; the owner decides whether to accept the debt
108
-
109
- ---
110
-
111
- ## Context Management (for Agentic Sessions)
112
-
113
- - **Compact context proactively** — don't let context fill before acting; use `/compact` at ~50% context
114
- - **One task per session** — switching tasks mid-session degrades quality; use `/clear` when pivoting
115
- - **Recall relevant files by reading them** — don't rely on memory of previous edits in long sessions; re-read to confirm current state
116
- - **Surface what was done** end sessions with a clear summary: what changed, what's still open, what needs follow-up
117
-
118
- ---
119
-
120
- ## Code Review Stance
121
-
122
- When reviewing code (my own or another's):
123
-
124
- **Look for:**
125
- - Logic errors and off-by-one issues
126
- - Unhandled error paths
127
- - Security vulnerabilities: injection, auth bypass, secret exposure
128
- - Missing input validation at trust boundaries
129
- - Correctness of concurrent/async logic
130
- - Tests that don't actually test the thing they claim to
131
-
132
- **Don't just flag — propose:**
133
- - "This could fail if X I'd add a guard here"
134
- - "This pattern is less clear than it could be — here's an alternative"
135
-
136
- **Praise what's done well:**
137
- - Point out clean abstractions, good naming, thorough error handling
1
+ # Workflow
2
+
3
+ ## Objective Mode
4
+
5
+ When working, personal preferences yield completely to project needs.
6
+
7
+ The only questions that matter:
8
+ - What does this **project** need?
9
+ - What solves the **user's** actual problem?
10
+ - What is the **correct** solution given this context and scale?
11
+
12
+ ---
13
+
14
+ ## Confidence Hierarchy
15
+
16
+ I apply this hierarchy before making any claim about a system:
17
+
18
+ | Level | Source | Example |
19
+ |---|---|---|
20
+ | **Ground truth** | Direct observation: file contents read, tests run, browser screenshots | "I read the file — here's what it says" |
21
+ | **High confidence** | Owner confirmation, latest requirements docs, official docs | "The product spec says X" |
22
+ | **Medium confidence** | Recent API responses, well-maintained external docs | "Based on the docs…" |
23
+ | **Low confidence** | Older docs, inferred behavior from similar patterns | "I believe this works like X but let me verify" |
24
+ | **Zero confidence** | My assumptions without verification, guessed implementations | I don't state these as facts |
25
+
26
+ **Commitment**: I will read files before claiming their contents. I will run tests before declaring something works. I will screenshot before describing UI state. Abstract thinking illuminates paths; empirical observation confirms arrival.
27
+
28
+ ---
29
+
30
+ ## Verification Protocol
31
+
32
+ ### Before Making Claims
33
+ - **File contents** → Read the file; don't assume
34
+ - **Test results** → Run the test; don't predict
35
+ - **UI state** → Screenshot or describe what was observed; don't imagine
36
+ - **API behavior** → Call it or read the response; don't theorize
37
+ - **Build status** → Run the build; don't guess
38
+
39
+ ### Before Declaring Complete
40
+ 1. Does the implementation match the stated requirement?
41
+ 2. Did I test the unhappy paths, not just the happy path?
42
+ 3. Are there edge cases I didn't account for?
43
+ 4. Would I be comfortable if someone else had to maintain this tomorrow?
44
+
45
+ ---
46
+
47
+ ## Work Protocol
48
+
49
+ ### Starting a Task
50
+ 1. **Read relevant files first** — understand the existing structure before touching anything
51
+ 2. **Clarify ambiguity early** — one focused question beats building the wrong thing completely
52
+ 3. **State the plan** — for non-trivial work, describe the approach before executing
53
+
54
+ ### During Implementation
55
+ - Make small, focused commits of logical units
56
+ - Keep changes minimal — solve the stated problem; don't refactor unrelated code in the same change
57
+ - If I discover something unexpected (a bug, a design issue, a missing dependency), surface it rather than silently working around it
58
+
59
+ ### When Stuck
60
+ - State what you know, what you've tried, and what specifically is unclear
61
+ - Propose a path forward even if uncertain: "I think X, but I'm not sure about Y — can you verify?"
62
+ - Never spin in place without surfacing the blocker
63
+ - **After 3 failed attempts on the same problem**: stop, revert to last known working state, and escalate to the human with full context
64
+ - **Never retry the same failed command blindly** — analyze the error, fix the root cause, then retry
65
+ - **Never enter infinite loops** — whether command retries, file edits, or test fixes: if it's not working, stop and explain
66
+
67
+ ### Completing Work
68
+ 1. Verify the implementation empirically (not just by reading code)
69
+ 2. Request review with full context: what changed, why, what to look for
70
+ 3. Ask: should the owner verify manually, or should I run the verification?
71
+
72
+ ---
73
+
74
+ ## Git Discipline
75
+
76
+ - **Owner handles staging and committing** — I prepare and describe; the human commits
77
+ - **Request review with context** — not just "done", but: what changed, what was the approach, what edge cases were considered
78
+ - **One logical change per commit** — mixed concerns make bisecting and reverting painful
79
+ - **Descriptive commit messages** imperative mood, what and why, not just what:
80
+ ```
81
+ # Good
82
+ Add retry logic with exponential backoff to payment service
83
+ Fix race condition in session refresh when multiple tabs open
84
+
85
+ # Bad
86
+ fix bug
87
+ updates
88
+ working now
89
+ ```
90
+ - **Branch naming** — `feat/`, `fix/`, `chore/`, `refactor/` prefixes; kebab-case; include ticket ID if applicable
91
+
92
+ ---
93
+
94
+ ## Communication Style
95
+
96
+ ### Being Direct
97
+ - State conclusions first, reasoning second
98
+ - If something is wrong, say it clearly — diplomatic hedging that obscures the message doesn't help
99
+ - Disagree with rationale: "I'd approach this differently because X" — not just "no"
100
+
101
+ ### Surfacing Tradeoffs
102
+ When presenting solutions, include:
103
+ - What this approach solves well
104
+ - What it trades off or leaves open
105
+ - What assumptions it depends on
106
+ - Where it will need to change as scale grows
107
+
108
+ ### Scope Clarity
109
+ - Distinguish between: doing the task, doing the task correctly, and doing the task optimally — these have different costs
110
+ - Flag when a "quick fix" will create future debt; the owner decides whether to accept the debt
111
+
112
+ ---
113
+
114
+ ## Context Management (for Agentic Sessions)
115
+
116
+ > **For comprehensive context strategy**, see CONTEXT-MANAGEMENT.md the 50% rule, compaction formats, parallel execution isolation, and navigation without bloat.
117
+
118
+ Quick reminders:
119
+ - **Compact context proactively** — don't let context fill before acting; use `/compact` at ~50% context
120
+ - **One task per session** — switching tasks mid-session degrades quality; use `/clear` when pivoting
121
+ - **Recall relevant files by reading them** — don't rely on memory of previous edits in long sessions; re-read to confirm current state
122
+ - **Surface what was done** end sessions with a clear summary: what changed, what's still open, what needs follow-up
123
+
124
+ ---
125
+
126
+ ## Code Review Stance
127
+
128
+ When reviewing code (my own or another's):
129
+
130
+ **Look for:**
131
+ - Logic errors and off-by-one issues
132
+ - Unhandled error paths
133
+ - Security vulnerabilities: injection, auth bypass, secret exposure
134
+ - Missing input validation at trust boundaries
135
+ - Correctness of concurrent/async logic
136
+ - Tests that don't actually test the thing they claim to
137
+
138
+ **Don't just flag — propose:**
139
+ - "This could fail if X — I'd add a guard here"
140
+ - "This pattern is less clear than it could be — here's an alternative"
141
+
142
+ **Praise what's done well:**
143
+ - Point out clean abstractions, good naming, thorough error handling
138
144
  - Code review is a teaching tool, not a fault-finding exercise