pyramid-sa 0.1.0__tar.gz

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.
Files changed (41) hide show
  1. pyramid_sa-0.1.0/.cursor/rules/dev-workflow-activation.mdc +46 -0
  2. pyramid_sa-0.1.0/.cursor/rules/knowledge-base.mdc +28 -0
  3. pyramid_sa-0.1.0/.cursor/rules/knowledge.mdc +38 -0
  4. pyramid_sa-0.1.0/.cursor/rules/python-conventions.mdc +47 -0
  5. pyramid_sa-0.1.0/.cursor/rules/quality.mdc +21 -0
  6. pyramid_sa-0.1.0/.cursor/rules/test-patterns.mdc +68 -0
  7. pyramid_sa-0.1.0/.cursor/skills/dev-workflow/SKILL.md +272 -0
  8. pyramid_sa-0.1.0/.cursor/skills/knowledge-management/SKILL.md +107 -0
  9. pyramid_sa-0.1.0/.cursor/skills/lint-format/SKILL.md +20 -0
  10. pyramid_sa-0.1.0/.cursor/skills/quality-assurance/SKILL.md +73 -0
  11. pyramid_sa-0.1.0/.cursor/skills/run-tests/SKILL.md +30 -0
  12. pyramid_sa-0.1.0/.cursor/skills/write-pytest/SKILL.md +377 -0
  13. pyramid_sa-0.1.0/.devcontainer/devcontainer.json +29 -0
  14. pyramid_sa-0.1.0/.github/workflows/ci.yml +67 -0
  15. pyramid_sa-0.1.0/.gitignore +12 -0
  16. pyramid_sa-0.1.0/PKG-INFO +168 -0
  17. pyramid_sa-0.1.0/README.md +153 -0
  18. pyramid_sa-0.1.0/docs/index.md +5 -0
  19. pyramid_sa-0.1.0/knowledge/architecture.md +27 -0
  20. pyramid_sa-0.1.0/knowledge/concepts.md +26 -0
  21. pyramid_sa-0.1.0/knowledge/decisions.md +41 -0
  22. pyramid_sa-0.1.0/mkdocs.yml +5 -0
  23. pyramid_sa-0.1.0/pyproject.toml +53 -0
  24. pyramid_sa-0.1.0/src/pyramid_sa/__init__.py +43 -0
  25. pyramid_sa-0.1.0/src/pyramid_sa/meta.py +99 -0
  26. pyramid_sa-0.1.0/src/pyramid_sa/renderer.py +15 -0
  27. pyramid_sa-0.1.0/src/pyramid_sa/scripts/__init__.py +0 -0
  28. pyramid_sa-0.1.0/src/pyramid_sa/scripts/alembic.py +35 -0
  29. pyramid_sa-0.1.0/src/pyramid_sa/scripts/cli.py +65 -0
  30. pyramid_sa-0.1.0/src/pyramid_sa/session.py +23 -0
  31. pyramid_sa-0.1.0/src/pyramid_sa/tween.py +31 -0
  32. pyramid_sa-0.1.0/testing/pyproject.toml +24 -0
  33. pyramid_sa-0.1.0/testing/src/pyramid_sa_testing/__init__.py +67 -0
  34. pyramid_sa-0.1.0/tests/__init__.py +0 -0
  35. pyramid_sa-0.1.0/tests/conftest.py +65 -0
  36. pyramid_sa-0.1.0/tests/test_includeme.py +87 -0
  37. pyramid_sa-0.1.0/tests/test_meta.py +99 -0
  38. pyramid_sa-0.1.0/tests/test_renderer.py +64 -0
  39. pyramid_sa-0.1.0/tests/test_testing.py +80 -0
  40. pyramid_sa-0.1.0/tests/test_tween.py +65 -0
  41. pyramid_sa-0.1.0/uv.lock +981 -0
@@ -0,0 +1,46 @@
1
+ ---
2
+ description: Ask the user at the start of every new chat whether to follow the full development workflow
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Chat-Start Triage
7
+
8
+ At the **very beginning** of every new chat, before doing anything else, check for in-progress work:
9
+
10
+ 1. Run `git branch --show-current`
11
+ 2. If the branch is **not** `main`, `master`, or `develop`, use the **Resume-Aware Triage**.
12
+ 3. Otherwise, use the **Standard Triage**.
13
+
14
+ ## Standard Triage
15
+
16
+ Use the `AskQuestion` tool:
17
+
18
+ title: "Chat Mode"
19
+ prompt: "Should this chat follow the full development workflow?"
20
+ options:
21
+ - id: full
22
+ label: "Yes — full dev workflow (planning, branching, PRs, quality checks)"
23
+ - id: quick
24
+ label: "No — quick task / exploration (skip workflow steps, keep code quality rules)"
25
+
26
+ ## Resume-Aware Triage
27
+
28
+ Use the `AskQuestion` tool, including the detected branch name:
29
+
30
+ title: "Chat Mode"
31
+ prompt: "You're on branch `<branch-name>`. Want to continue this work or start something new?"
32
+ options:
33
+ - id: continue
34
+ label: "Continue current work (resume dev workflow on this branch)"
35
+ - id: full
36
+ label: "Start a new dev workflow (different issue)"
37
+ - id: quick
38
+ label: "Quick task / exploration (skip workflow steps, keep code quality rules)"
39
+
40
+ ## Behavior Based on Answer
41
+
42
+ **Continue current work** (`continue`): Read `.cursor/skills/dev-workflow/SKILL.md` and follow its **Resume** section — the agent will extract the issue from the branch name, fetch context, and pick up where the previous chat left off. Also enforce all rules from `.cursor/rules/quality.mdc`.
43
+
44
+ **Full dev workflow** (`full`): Read and follow `.cursor/skills/dev-workflow/SKILL.md` from Step 1 — planning before coding, feature branches, incremental commits, PR process. Also enforce all rules from `.cursor/rules/quality.mdc`.
45
+
46
+ **Quick task / exploration** (`quick`): Skip the structured workflow steps (mandatory planning phase, feature branches, PRs, release process). Still enforce all code quality rules defined in `.cursor/rules/quality.mdc`.
@@ -0,0 +1,28 @@
1
+ ---
2
+ description: Directs the AI to use the knowledge/ directory for project context
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # Project Knowledge Base
7
+
8
+ This project maintains a `knowledge/` directory with context for AI assistants.
9
+
10
+ ## Before making design or architectural decisions
11
+
12
+ Read these files for context:
13
+
14
+ - `knowledge/architecture.md` — system overview, components, and data flow
15
+ - `knowledge/decisions.md` — past architectural decisions and their rationale
16
+ - `knowledge/concepts.md` — domain terminology, mental models, and invariants
17
+
18
+ ## When new decisions are made
19
+
20
+ Update `knowledge/decisions.md` with a new entry following the ADR template in that file.
21
+
22
+ ## When new domain concepts emerge
23
+
24
+ Update `knowledge/concepts.md` with new terms, mental models, or invariants.
25
+
26
+ ## Important
27
+
28
+ The `knowledge/` directory is for AI context. Human-facing documentation belongs in `docs/`.
@@ -0,0 +1,38 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ # Knowledge Directory
6
+
7
+ The `knowledge/` directory contains AI-facing living documentation — one markdown file per feature area describing its current state, design decisions, API surface, and gotchas.
8
+
9
+ ## Two Audiences
10
+
11
+ - **`docs/` and `README.md`** are for humans — developers, users, contributors. Focus on clarity, examples, and getting-started guidance.
12
+ - **`knowledge/`** is for the AI — the agent reads these files to understand the codebase. Focus on precision, design decisions, API surface, gotchas, and non-obvious learnings. Conciseness matters more than prose quality.
13
+ - Both must stay in sync. When a feature changes, update both.
14
+
15
+ ## Structure
16
+
17
+ One markdown file per feature area (e.g., `knowledge/auth.md`, `knowledge/billing.md`, `knowledge/architecture.md`). Each file follows a consistent structure:
18
+
19
+ 1. **Overview** — What this area does, in one or two sentences.
20
+ 2. **Design Decisions** — Why it works the way it does. Trade-offs, constraints, alternatives considered.
21
+ 3. **API Surface** — Key classes, functions, types, and their relationships.
22
+ 4. **Key Learnings / Gotchas** — Non-obvious behaviors, edge cases, things that broke before.
23
+
24
+ ## When to Update
25
+
26
+ - After completing a new feature — create or extend the relevant file.
27
+ - After fixing a significant bug that revealed something non-obvious — add to Key Learnings.
28
+ - After making an architectural change — update the affected files.
29
+
30
+ ## What Does NOT Belong
31
+
32
+ - Task lists, progress tracking, or backlog items.
33
+ - Changelogs or timestamps — knowledge files describe the present, not the history.
34
+ - Documentation for end users — that lives in `docs/`.
35
+
36
+ ## Reading Before Writing
37
+
38
+ Before making changes to a feature area, read the relevant `knowledge/*.md` file first. It contains context that may affect your approach.
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: Python project conventions for pyramid-sa
3
+ globs: "**/*.py"
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Python Conventions
8
+
9
+ ## Project layout
10
+
11
+ - Source code lives in `src/pyramid_sa/`
12
+ - Testing package lives in `testing/src/pyramid_sa_testing/`
13
+ - Tests live in `tests/`
14
+ - Always use the `src` layout; never put package code at the repository root
15
+
16
+ ## Imports
17
+
18
+ - All imports at the top of the module, never inside functions or methods
19
+ - Use absolute imports: `from pyramid_sa.module import thing`
20
+ - Import order enforced by ruff (isort rules): stdlib, third-party, local
21
+
22
+ ## Formatting and linting
23
+
24
+ - Formatter: black (line length 88)
25
+ - Linter: ruff
26
+ - Run before committing: `uv run ruff check .` and `uv run black .`
27
+
28
+ ## Testing
29
+
30
+ - Framework: pytest
31
+ - Test files: `tests/test_*.py`
32
+ - Run: `uv run pytest`
33
+ - Avoid mocks unless absolutely necessary; prefer real objects and integration tests
34
+
35
+ ## Forbidden
36
+
37
+ - Never use pydantic
38
+ - Never use FastAPI
39
+ - Never add imports inside functions or methods
40
+
41
+ ## Style
42
+
43
+ Follow the Zen of Python. Prefer:
44
+ - Simple over complex
45
+ - Explicit over implicit
46
+ - Flat over nested
47
+ - Readable over clever
@@ -0,0 +1,21 @@
1
+ ---
2
+ alwaysApply: true
3
+ ---
4
+
5
+ # Code Quality Rules
6
+
7
+ These rules apply to **every** chat, regardless of whether the full dev workflow is active.
8
+
9
+ ## Code Quality
10
+
11
+ ### Type Hints
12
+
13
+ Use type hints for all function signatures and class attributes.
14
+
15
+ ### No Obvious Comments
16
+
17
+ Do not add comments that merely narrate what the code does. Comments should explain non-obvious intent, trade-offs, or constraints that the code itself cannot convey.
18
+
19
+ ### Clean Formatting
20
+
21
+ Run the project's formatter and linter before committing. All pre-commit checks must pass.
@@ -0,0 +1,68 @@
1
+ ---
2
+ description: Enforce pytest testing patterns for Pyramid applications
3
+ globs: **/tests/**/*.py, **/test_*.py
4
+ alwaysApply: false
5
+ ---
6
+
7
+ # Pytest Testing Patterns
8
+
9
+ These rules apply whenever you create or modify test files.
10
+
11
+ ## Strict Rules
12
+
13
+ - **No conditional logic in tests**: no `if/else`, `try/except`, `for`, `while`, ternary operators
14
+ - **No class-based tests**: always use plain pytest functions
15
+ - **No imports inside functions**: all imports at module level
16
+ - **No standalone helper functions for test setup**: use `@pytest.fixture` in `conftest.py`
17
+ - **No mocking unless absolutely necessary**: prefer `responses` for HTTP, real code for everything else. `unittest.mock.patch` is a last resort (gRPC clients only)
18
+ - **No test files over ~200 lines**: split by concern (`_api`, `_service`, `_integration`, `_security`)
19
+
20
+ ## Testing Priority
21
+
22
+ 1. Real integrations and real code paths
23
+ 2. `responses` library for external HTTP calls (`@responses.activate`)
24
+ 3. `factory-boy` for test data generation (`SQLAlchemyModelFactory`)
25
+ 4. Pytest fixtures for reusable setup
26
+ 5. `unittest.mock.patch` only as absolute last resort
27
+
28
+ ## Test Structure
29
+
30
+ - Mirror source structure in `tests/` directory
31
+ - One test file per module: `test_<module_name>.py`
32
+ - Descriptive function names: `test_<action>_<scenario>`
33
+ - One test, one purpose
34
+ - Brief docstring on each test function
35
+
36
+ ## Mandatory Security Tests
37
+
38
+ If the endpoint under test is protected (has `factory=`, `permission=`, `__acl__`, JWT logic), you MUST include:
39
+
40
+ - **Wrong/invalid token** test (expect 401 or 403)
41
+ - **Wrong permission scope** test (expect 403)
42
+ - **Missing authentication** test (expect 403)
43
+ - **Wrong credentials** test where applicable (expect 401)
44
+
45
+ Never ask whether to include these. If the endpoint is protected, they are required.
46
+
47
+ ## Avoid Duplication
48
+
49
+ - Use `@pytest.mark.parametrize` with clear `ids` when tests share the same logic but differ in input/output
50
+ - Use `@pytest.fixture` for repeated setup logic (never standalone helper functions)
51
+ - Use `hypothesis` (`@given()`) for property-based testing of validators and numeric logic
52
+
53
+ ## Factory-Boy
54
+
55
+ - Use `SQLAlchemyModelFactory` with `sqlalchemy_session_persistence = "flush"`
56
+ - Use `factory.Faker` for realistic data
57
+ - Use `factory.SubFactory` for relationships
58
+ - Use `factory.LazyFunction` for computed fields
59
+
60
+ ## Forbidden
61
+
62
+ - Never use FastAPI or pydantic
63
+ - Never use mocks when `responses` or real integrations work
64
+ - Never write conditional logic inside test functions
65
+
66
+ ## Full Workflow
67
+
68
+ For writing complete test suites from scratch, use the **write-pytest** skill which provides a guided research-discuss-write flow.
@@ -0,0 +1,272 @@
1
+ ---
2
+ name: dev-workflow
3
+ description: Automate the full development cycle from issue to pull request using GitHub Issues. Use when the user wants to work on a feature, fix a bug, start a dev task, or says things like "let's work on", "implement", or "fix".
4
+ ---
5
+
6
+ # Dev Workflow (GitHub Issues)
7
+
8
+ Guide the developer through the full cycle: issue -> branch -> plan -> implement -> PR -> release.
9
+
10
+ ## Resume (Continuing from a Previous Chat)
11
+
12
+ If resuming an in-progress workflow (the user selected "Continue current work" from the chat triage), follow these steps instead of starting from Step 1:
13
+
14
+ 1. Get the current branch name:
15
+
16
+ ```bash
17
+ git branch --show-current
18
+ ```
19
+
20
+ 2. Extract the issue number from the branch name. Branches follow the pattern `<type>/<issue-number>-<slug>` (e.g., `fix/42-login-timeout` → issue `42`).
21
+
22
+ 3. Fetch the issue details and comments:
23
+
24
+ ```bash
25
+ gh issue view <number> --json title,body,labels,number,comments
26
+ ```
27
+
28
+ 4. Search the issue comments for an **Implementation Plan**. If found:
29
+ - Parse the plan tasks
30
+ - Cross-reference with the git log (`git log main..HEAD --oneline`) to determine which tasks are likely completed
31
+ - Create TodoWrite entries: mark completed tasks as `completed`, set the next unfinished task to `in_progress`, rest as `pending`
32
+ - Tell the user what was found and which task you'll resume from
33
+ - Continue from **Step 5: Execute**
34
+
35
+ 5. If no plan is found in the comments:
36
+ - Tell the user the issue context and that no plan was stored yet
37
+ - Continue from **Step 3: Plan**
38
+
39
+ ---
40
+
41
+ ## Step 1: Issue
42
+
43
+ Use AskQuestion:
44
+
45
+ ```
46
+ prompt: "Do you already have a GitHub issue for this work?"
47
+ options:
48
+ - Yes, I have an issue URL
49
+ - No, let's create one
50
+ ```
51
+
52
+ ### If the user has an issue
53
+
54
+ Ask for the issue URL or number. Fetch the issue details:
55
+
56
+ ```bash
57
+ gh issue view <number> --json title,body,labels,number
58
+ ```
59
+
60
+ Parse the title, description, and labels for context.
61
+
62
+ ### If the user does not have an issue
63
+
64
+ Discuss the work with the user to define:
65
+ - **Title**: concise summary
66
+ - **Description**: what needs to happen and why
67
+ - **Labels**: bug, feature, enhancement, etc.
68
+
69
+ When the issue is well-defined, create it:
70
+
71
+ ```bash
72
+ gh issue create --title "<title>" --body "<description>" --label "<labels>"
73
+ ```
74
+
75
+ Capture the issue number from the output.
76
+
77
+ ## Step 2: Branch
78
+
79
+ Determine the branch type from labels or context:
80
+ - `bug` label -> `fix/`
81
+ - `feature` or `enhancement` label -> `feat/`
82
+ - otherwise -> `task/`
83
+
84
+ Create a slug from the issue title (lowercase, hyphens, max 40 chars).
85
+
86
+ ```bash
87
+ git checkout -b <type>/<issue-number>-<slug>
88
+ git push -u origin HEAD
89
+ ```
90
+
91
+ Example: `fix/42-login-timeout`
92
+
93
+ ## Step 3: Plan
94
+
95
+ Tell the user: "Switching to plan mode to design the implementation."
96
+
97
+ Use the SwitchMode tool to enter plan mode. Then create an implementation plan by:
98
+ 1. Reading the issue description
99
+ 2. Exploring the relevant parts of the codebase
100
+ 3. Drafting a step-by-step plan with specific files and changes
101
+
102
+ The plan should include:
103
+ - A summary of the approach
104
+ - Ordered list of tasks (each should be a concrete, testable unit of work)
105
+ - Files to create or modify per task
106
+ - Test strategy
107
+
108
+ Wait for the user to review and approve the plan.
109
+
110
+ ## Step 4: Store Plan
111
+
112
+ Once the plan is approved:
113
+
114
+ 1. Post the plan as a comment on the issue:
115
+
116
+ ```bash
117
+ gh issue comment <number> --body "$(cat <<'EOF'
118
+ ## Implementation Plan
119
+
120
+ <paste the approved plan here>
121
+
122
+ EOF
123
+ )"
124
+ ```
125
+
126
+ 2. Create TodoWrite entries for each task in the plan. Set the first task to `in_progress`, the rest to `pending`.
127
+
128
+ ## Step 5: Execute
129
+
130
+ Switch back to agent mode using the SwitchMode tool.
131
+
132
+ Work through the tasks sequentially:
133
+ 1. Pick the current `in_progress` task
134
+ 2. Implement the changes
135
+ 3. Run tests if applicable
136
+ 4. Mark the task as `completed` in TodoWrite
137
+ 5. Move the next task to `in_progress`
138
+
139
+ After completing each task, post a progress comment on the issue:
140
+
141
+ ```bash
142
+ gh issue comment <number> --body "Completed: <task description>"
143
+ ```
144
+
145
+ ## Step 6: Sync
146
+
147
+ Throughout execution, keep the issue and TodoWrite aligned:
148
+ - When a task is completed locally, comment on the issue
149
+ - If the plan needs adjustment mid-execution, update both the TodoWrite list and post an updated plan comment on the issue
150
+ - If new tasks emerge, add them to both TodoWrite and the issue
151
+
152
+ ## Step 7: Update Knowledge
153
+
154
+ Before creating the PR, update the project's knowledge files:
155
+
156
+ 1. Check if the changes affect a feature area that has an existing `knowledge/*.md` file — if so, read the file and update any sections that are now stale. Rewrite sections to reflect the current state rather than appending notes.
157
+ 2. If a new feature area was introduced and no knowledge file exists, create one following the structure in `.cursor/rules/knowledge.mdc` (Overview, Design Decisions, API Surface, Key Learnings / Gotchas).
158
+ 3. If the changes affect the overall architecture, update `knowledge/architecture.md`.
159
+ 4. Commit knowledge updates separately:
160
+
161
+ ```bash
162
+ git add knowledge/
163
+ git commit -m "docs: update knowledge for <feature>"
164
+ ```
165
+
166
+ ## Step 8: Pull Request
167
+
168
+ When all tasks are complete:
169
+
170
+ 1. Ensure all changes are committed
171
+ 2. Push the branch: `git push`
172
+ 3. Create the PR:
173
+
174
+ ```bash
175
+ gh pr create --title "<issue-title>" --body "$(cat <<'EOF'
176
+ ## Summary
177
+ <1-3 bullet points describing what was done>
178
+
179
+ Closes #<issue-number>
180
+
181
+ ## Test plan
182
+ <checklist of how to verify the changes>
183
+
184
+ EOF
185
+ )"
186
+ ```
187
+
188
+ 4. Tell the user the PR is ready for review and provide the PR URL.
189
+
190
+ ## Step 9: Review & Merge
191
+
192
+ After the PR is created, ask the user:
193
+
194
+ ```
195
+ prompt: "The PR is open. What would you like to do?"
196
+ options:
197
+ - Check review status now
198
+ - Come back later — I'll request a review myself
199
+ ```
200
+
201
+ ### If "Check review status now"
202
+
203
+ 1. Check CI status and review state:
204
+
205
+ ```bash
206
+ gh pr checks
207
+ gh pr view --json reviewDecision,reviews,statusCheckRollup
208
+ ```
209
+
210
+ 2. Summarize the current state:
211
+ - CI checks: passing / failing / pending
212
+ - Review status: approved / changes requested / pending / no reviewers
213
+
214
+ 3. **If checks pass and reviews are approved**, ask:
215
+
216
+ ```
217
+ prompt: "PR is approved and checks pass. Merge it?"
218
+ options:
219
+ - Yes, squash and merge
220
+ - Yes, merge commit
221
+ - Yes, rebase and merge
222
+ - No, not yet
223
+ ```
224
+
225
+ 4. If the user selects a merge strategy:
226
+
227
+ ```bash
228
+ gh pr merge --<strategy> --delete-branch
229
+ git checkout main && git pull
230
+ ```
231
+
232
+ 5. If checks are failing or reviews are not yet approved, tell the user what is pending and suggest coming back later.
233
+
234
+ ### If "Come back later"
235
+
236
+ Tell the user they can resume this step by asking to check the PR status or merge. End the current session here — the Release step runs after the PR is merged.
237
+
238
+ ## Step 10: Release
239
+
240
+ > This step only applies to projects with a release flow.
241
+
242
+ After the PR is merged:
243
+
244
+ 1. Detect the latest release tag:
245
+
246
+ ```bash
247
+ gh release list --limit 1
248
+ ```
249
+
250
+ 2. Determine the next version using semantic versioning:
251
+ - Bug fix -> patch bump (1.0.0 -> 1.0.1)
252
+ - Feature -> minor bump (1.0.0 -> 1.1.0)
253
+ - Breaking change -> major bump (1.0.0 -> 2.0.0)
254
+
255
+ Use the issue labels and nature of changes to decide.
256
+
257
+ 3. Create the release:
258
+
259
+ ```bash
260
+ gh release create v<version> --generate-notes --title "v<version>"
261
+ ```
262
+
263
+ 4. Tell the user the release has been created and provide the URL.
264
+
265
+ ## Step 11: End
266
+
267
+ Summarize what was accomplished:
268
+ - Issue number and title
269
+ - Branch name
270
+ - Number of commits
271
+ - PR URL
272
+ - Release version (if applicable)
@@ -0,0 +1,107 @@
1
+ ---
2
+ name: knowledge-management
3
+ description: Create or update knowledge files for a feature area. Use when the user says "update knowledge", "create knowledge file for X", "document this feature", or after completing a feature that needs knowledge documentation.
4
+ ---
5
+
6
+ # Knowledge Management
7
+
8
+ This skill guides you through creating or updating files in the `knowledge/` directory. Follow the conventions defined in `.cursor/rules/knowledge.mdc`.
9
+
10
+ ## Step 1: Determine the Action
11
+
12
+ Use AskQuestion:
13
+
14
+ ```
15
+ prompt: "What would you like to do?"
16
+ options:
17
+ - Create a new knowledge file for a feature area
18
+ - Update an existing knowledge file
19
+ - Review all knowledge files for staleness
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Creating a New Knowledge File
25
+
26
+ ### Step 2a: Identify the Feature Area
27
+
28
+ Ask the user which feature area to document, or infer it from the conversation context. The file should be named after the feature area in lowercase with underscores (e.g., `knowledge/billing.md`, `knowledge/auth.md`).
29
+
30
+ ### Step 3a: Explore the Codebase
31
+
32
+ Read the source code for the feature area thoroughly:
33
+ 1. Identify the key modules, classes, and functions
34
+ 2. Trace the main code paths and data flow
35
+ 3. Note design decisions that are not obvious from the code alone
36
+ 4. Look for edge cases, gotchas, and non-obvious behaviors
37
+
38
+ Also read `knowledge/architecture.md` to understand how this area fits into the overall system.
39
+
40
+ ### Step 4a: Draft the Knowledge File
41
+
42
+ Write the file following this structure:
43
+
44
+ ```markdown
45
+ # <Feature Area Name>
46
+
47
+ <One or two sentences describing what this area does.>
48
+
49
+ ## Design Decisions
50
+
51
+ <Why it works the way it does. Trade-offs, constraints, alternatives considered. Use a heading per decision if there are several.>
52
+
53
+ ## API Surface
54
+
55
+ <Key classes, functions, types, and their relationships. Focus on what another developer (or the AI) needs to know to work in this area correctly.>
56
+
57
+ ## Key Learnings / Gotchas
58
+
59
+ <Non-obvious behaviors, edge cases, things that broke before, common mistakes to avoid.>
60
+ ```
61
+
62
+ ### Step 5a: Write and Confirm
63
+
64
+ Write the file to `knowledge/<feature-area>.md`. Tell the user what was created and suggest they review it.
65
+
66
+ ---
67
+
68
+ ## Updating an Existing Knowledge File
69
+
70
+ ### Step 2b: Identify What Changed
71
+
72
+ Determine which knowledge file needs updating. This can come from:
73
+ - The user specifying a file directly
74
+ - A feature that was just implemented or modified
75
+ - A bug fix that revealed a non-obvious behavior
76
+
77
+ ### Step 3b: Read Current State
78
+
79
+ Read the existing knowledge file and the relevant source code. Identify which sections are stale or incomplete.
80
+
81
+ ### Step 4b: Rewrite Affected Sections
82
+
83
+ Update only the sections that need changes. Knowledge files describe the **present state** — rewrite sections entirely rather than appending notes or changelogs. Keep the same structure (Design Decisions, API Surface, Key Learnings / Gotchas).
84
+
85
+ ### Step 5b: Write and Confirm
86
+
87
+ Write the updated file. Tell the user what was changed and why.
88
+
89
+ ---
90
+
91
+ ## Reviewing All Knowledge Files
92
+
93
+ ### Step 2c: Scan for Staleness
94
+
95
+ For each file in `knowledge/`:
96
+ 1. Read the knowledge file
97
+ 2. Check if the source code it describes has changed significantly since the file was last written
98
+ 3. Flag files that appear outdated
99
+
100
+ ### Step 3c: Report
101
+
102
+ Present a summary listing each knowledge file with its status:
103
+ - **Current** — the file accurately reflects the source code
104
+ - **Needs update** — the source code has diverged; explain what looks stale
105
+ - **Missing** — a significant feature area has source code but no knowledge file
106
+
107
+ Ask the user which files to update, then follow the update flow above for each.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: lint-format
3
+ description: Lint and format code for pyramid-sa. Use when the user asks to lint, format, check style, or fix code style.
4
+ ---
5
+
6
+ # Lint and Format
7
+
8
+ ## Check (no changes)
9
+
10
+ ```bash
11
+ uv run ruff check .
12
+ uv run black --check .
13
+ ```
14
+
15
+ ## Fix
16
+
17
+ ```bash
18
+ uv run ruff check . --fix
19
+ uv run black .
20
+ ```