mongomock-ng 7.0.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 (91) hide show
  1. mongomock_ng-7.0.0/.agents/skills/cavecrew/README.md +41 -0
  2. mongomock_ng-7.0.0/.agents/skills/cavecrew/SKILL.md +82 -0
  3. mongomock_ng-7.0.0/.agents/skills/caveman/README.md +48 -0
  4. mongomock_ng-7.0.0/.agents/skills/caveman/SKILL.md +74 -0
  5. mongomock_ng-7.0.0/.agents/skills/caveman-commit/README.md +44 -0
  6. mongomock_ng-7.0.0/.agents/skills/caveman-commit/SKILL.md +65 -0
  7. mongomock_ng-7.0.0/.agents/skills/caveman-compress/README.md +163 -0
  8. mongomock_ng-7.0.0/.agents/skills/caveman-compress/SECURITY.md +31 -0
  9. mongomock_ng-7.0.0/.agents/skills/caveman-compress/SKILL.md +111 -0
  10. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/__init__.py +9 -0
  11. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/__main__.py +4 -0
  12. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/benchmark.py +79 -0
  13. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/cli.py +87 -0
  14. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/compress.py +263 -0
  15. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/detect.py +157 -0
  16. mongomock_ng-7.0.0/.agents/skills/caveman-compress/scripts/validate.py +214 -0
  17. mongomock_ng-7.0.0/.agents/skills/caveman-help/README.md +38 -0
  18. mongomock_ng-7.0.0/.agents/skills/caveman-help/SKILL.md +59 -0
  19. mongomock_ng-7.0.0/.agents/skills/caveman-review/README.md +33 -0
  20. mongomock_ng-7.0.0/.agents/skills/caveman-review/SKILL.md +55 -0
  21. mongomock_ng-7.0.0/.agents/skills/caveman-stats/README.md +30 -0
  22. mongomock_ng-7.0.0/.agents/skills/caveman-stats/SKILL.md +10 -0
  23. mongomock_ng-7.0.0/.github/references/MYPY_PROBLEMS_REFERENCE.md +238 -0
  24. mongomock_ng-7.0.0/.github/references/ONE_PAGE_SUMMARY.md +214 -0
  25. mongomock_ng-7.0.0/.github/references/REAL_MONGODB_VALIDATION.md +377 -0
  26. mongomock_ng-7.0.0/.github/references/TEST_HIERARCHY_AND_CLASSES.md +370 -0
  27. mongomock_ng-7.0.0/.github/workflows/copilot-instructions.md +80 -0
  28. mongomock_ng-7.0.0/.github/workflows/lint-and-test.yml +107 -0
  29. mongomock_ng-7.0.0/.github/workflows/publish.yml +30 -0
  30. mongomock_ng-7.0.0/.gitignore +18 -0
  31. mongomock_ng-7.0.0/.pre-commit-config.yaml +13 -0
  32. mongomock_ng-7.0.0/.rtk/filters.toml +13 -0
  33. mongomock_ng-7.0.0/.ruff_defaults.toml +557 -0
  34. mongomock_ng-7.0.0/CHANGELOG.md +62 -0
  35. mongomock_ng-7.0.0/Dockerfile +19 -0
  36. mongomock_ng-7.0.0/LICENSE +15 -0
  37. mongomock_ng-7.0.0/Makefile +88 -0
  38. mongomock_ng-7.0.0/Missing_Features.rst +43 -0
  39. mongomock_ng-7.0.0/PKG-INFO +342 -0
  40. mongomock_ng-7.0.0/README.rst +295 -0
  41. mongomock_ng-7.0.0/contributing.md +206 -0
  42. mongomock_ng-7.0.0/docker-compose.yml +21 -0
  43. mongomock_ng-7.0.0/hatch.toml +47 -0
  44. mongomock_ng-7.0.0/mongomock_ng/__init__.py +149 -0
  45. mongomock_ng-7.0.0/mongomock_ng/__init__.pyi +33 -0
  46. mongomock_ng-7.0.0/mongomock_ng/__version__.py +4 -0
  47. mongomock_ng-7.0.0/mongomock_ng/aggregate.py +1754 -0
  48. mongomock_ng-7.0.0/mongomock_ng/codec_options.py +134 -0
  49. mongomock_ng-7.0.0/mongomock_ng/collection.py +2477 -0
  50. mongomock_ng-7.0.0/mongomock_ng/command_cursor.py +37 -0
  51. mongomock_ng-7.0.0/mongomock_ng/database.py +267 -0
  52. mongomock_ng-7.0.0/mongomock_ng/filtering.py +587 -0
  53. mongomock_ng-7.0.0/mongomock_ng/gridfs.py +70 -0
  54. mongomock_ng-7.0.0/mongomock_ng/helpers.py +459 -0
  55. mongomock_ng-7.0.0/mongomock_ng/mongo_client.py +215 -0
  56. mongomock_ng-7.0.0/mongomock_ng/not_implemented.py +36 -0
  57. mongomock_ng-7.0.0/mongomock_ng/object_id.py +24 -0
  58. mongomock_ng-7.0.0/mongomock_ng/patch.py +95 -0
  59. mongomock_ng-7.0.0/mongomock_ng/py.typed +0 -0
  60. mongomock_ng-7.0.0/mongomock_ng/read_concern.py +21 -0
  61. mongomock_ng-7.0.0/mongomock_ng/read_preferences.py +40 -0
  62. mongomock_ng-7.0.0/mongomock_ng/results.py +131 -0
  63. mongomock_ng-7.0.0/mongomock_ng/store.py +188 -0
  64. mongomock_ng-7.0.0/mongomock_ng/thread.py +93 -0
  65. mongomock_ng-7.0.0/mongomock_ng/write_concern.py +41 -0
  66. mongomock_ng-7.0.0/pyproject.toml +144 -0
  67. mongomock_ng-7.0.0/skills-lock.json +47 -0
  68. mongomock_ng-7.0.0/tests/__init__.py +0 -0
  69. mongomock_ng-7.0.0/tests/connection_string/test/valid-auth.json +330 -0
  70. mongomock_ng-7.0.0/tests/connection_string/test/valid-host_identifiers.json +154 -0
  71. mongomock_ng-7.0.0/tests/connection_string/test/valid-options.json +42 -0
  72. mongomock_ng-7.0.0/tests/connection_string/test/valid-unix_socket-absolute.json +251 -0
  73. mongomock_ng-7.0.0/tests/connection_string/test/valid-unix_socket-relative.json +271 -0
  74. mongomock_ng-7.0.0/tests/connection_string/test/valid-warnings.json +68 -0
  75. mongomock_ng-7.0.0/tests/diff.py +116 -0
  76. mongomock_ng-7.0.0/tests/multicollection.py +164 -0
  77. mongomock_ng-7.0.0/tests/test__bulk_operations.py +266 -0
  78. mongomock_ng-7.0.0/tests/test__client_api.py +182 -0
  79. mongomock_ng-7.0.0/tests/test__collection_api.py +8284 -0
  80. mongomock_ng-7.0.0/tests/test__database_api.py +292 -0
  81. mongomock_ng-7.0.0/tests/test__diff.py +33 -0
  82. mongomock_ng-7.0.0/tests/test__gridfs.py +220 -0
  83. mongomock_ng-7.0.0/tests/test__helpers.py +169 -0
  84. mongomock_ng-7.0.0/tests/test__mongomock.py +5293 -0
  85. mongomock_ng-7.0.0/tests/test__not_implemented.py +40 -0
  86. mongomock_ng-7.0.0/tests/test__patch.py +135 -0
  87. mongomock_ng-7.0.0/tests/test__readme_doctest.py +11 -0
  88. mongomock_ng-7.0.0/tests/test__thread.py +20 -0
  89. mongomock_ng-7.0.0/tests/types/__init__.py +0 -0
  90. mongomock_ng-7.0.0/tests/types/patch.py +9 -0
  91. mongomock_ng-7.0.0/tests/utils.py +11 -0
@@ -0,0 +1,41 @@
1
+ # cavecrew
2
+
3
+ Decision guide. When to delegate to caveman subagents instead of doing the work inline.
4
+
5
+ ## What it does
6
+
7
+ Tells the main thread when to spawn a caveman-style subagent versus the vanilla equivalent. The win: subagent tool-results inject back into main context verbatim, and caveman output is roughly 1/3 the size of vanilla prose. Across 20 delegations in one session, that is the difference between context exhaustion and finishing the task.
8
+
9
+ Three subagents:
10
+
11
+ | Subagent | Job | Use when |
12
+ |----------|-----|----------|
13
+ | `cavecrew-investigator` | Locate code (read-only) | "Where is X defined / what calls Y / list uses of Z" |
14
+ | `cavecrew-builder` | Surgical edit, 1-2 files | Scope is obvious, ≤2 files. Refuses 3+ file scope. |
15
+ | `cavecrew-reviewer` | Diff/file review | One-line findings with severity emoji |
16
+
17
+ Use vanilla `Explore` or `Code Reviewer` when you want prose, architecture commentary, or rationale. Use main thread directly for one-line answers and 3+ file refactors.
18
+
19
+ This skill is a decision guide, not a slash command. It activates when the conversation mentions delegation.
20
+
21
+ ## How to invoke
22
+
23
+ Triggers on phrases like "delegate to subagent", "use cavecrew", "spawn investigator", "save context", "compressed agent output".
24
+
25
+ ## Example chaining
26
+
27
+ Locate → fix → verify (most common):
28
+
29
+ 1. `cavecrew-investigator` returns site list (`path:line — symbol — note`)
30
+ 2. Main thread picks 1-2 sites, hands paths to `cavecrew-builder`
31
+ 3. `cavecrew-reviewer` audits the resulting diff
32
+
33
+ Parallel scout: spawn 2-3 `cavecrew-investigator` calls in one message with different angles (defs, callers, tests). Aggregate in main.
34
+
35
+ ## See also
36
+
37
+ - [`SKILL.md`](./SKILL.md) — full decision matrix and output contracts
38
+ - [`agents/cavecrew-investigator.md`](../../agents/cavecrew-investigator.md)
39
+ - [`agents/cavecrew-builder.md`](../../agents/cavecrew-builder.md)
40
+ - [`agents/cavecrew-reviewer.md`](../../agents/cavecrew-reviewer.md)
41
+ - [Caveman README](../../README.md) — repo overview
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: cavecrew
3
+ description: >
4
+ Decision guide for delegating to caveman-style subagents. Tells the main
5
+ thread WHEN to spawn `cavecrew-investigator` (locate code), `cavecrew-builder`
6
+ (1-2 file edit), or `cavecrew-reviewer` (diff review) instead of doing the
7
+ work inline or using vanilla `Explore`. Subagent output is caveman-compressed
8
+ so the tool-result injected back into main context is ~60% smaller — main
9
+ context lasts longer across long sessions.
10
+ Trigger: "delegate to subagent", "use cavecrew", "spawn investigator/builder/reviewer",
11
+ "save context", "compressed agent output".
12
+ ---
13
+
14
+ Cavecrew = three subagent presets that emit caveman output. Same job as Anthropic defaults (`Explore`, edit-style agents, reviewer); difference is the tool-result they return is compressed, so main context shrinks per delegation.
15
+
16
+ ## When to use cavecrew vs alternatives
17
+
18
+ | Task | Use |
19
+ |---|---|
20
+ | "Where is X defined / what calls Y / list uses of Z" | `cavecrew-investigator` |
21
+ | Same but you also want suggestions/architecture commentary | `Explore` (vanilla) |
22
+ | Surgical edit, ≤2 files, scope obvious | `cavecrew-builder` |
23
+ | New feature / 3+ files / cross-cutting refactor | Main thread or `feature-dev:code-architect` |
24
+ | Review diff, branch, or file for bugs | `cavecrew-reviewer` |
25
+ | Deep code review with rationale + alternatives | `Code Reviewer` (vanilla) |
26
+ | One-line answer you already know | Main thread, no subagent |
27
+
28
+ Rule of thumb: **if you'd want the subagent's output in 1/3 the tokens, pick cavecrew. If you'd want prose, pick vanilla.**
29
+
30
+ ## Why this exists (the real win)
31
+
32
+ Subagent tool results get injected into main context verbatim. A vanilla `Explore` that returns 2k tokens of prose costs 2k tokens of main-context budget every time. The same finding from `cavecrew-investigator` returns ~700 tokens. Across 20 delegations in one session that's the difference between context exhaustion and finishing the task.
33
+
34
+ ## Output contracts
35
+
36
+ What main thread can rely on per agent:
37
+
38
+ **`cavecrew-investigator`**
39
+ ```
40
+ <Header>:
41
+ - path:line — `symbol` — short note
42
+ totals: <counts>.
43
+ ```
44
+ Or `No match.` Always file-path-first, line-number-attached, backticked symbols. Safe to grep with `path:\d+`.
45
+
46
+ **`cavecrew-builder`**
47
+ ```
48
+ <path:line-range> — <change ≤10 words>.
49
+ verified: <re-read OK | mismatch @ path:line>.
50
+ ```
51
+ Or one of: `too-big.` / `needs-confirm.` / `ambiguous.` / `regressed.` (terminal first token).
52
+
53
+ **`cavecrew-reviewer`**
54
+ ```
55
+ path:line: <emoji> <severity>: <problem>. <fix>.
56
+ totals: N🔴 N🟡 N🔵 N❓
57
+ ```
58
+ Or `No issues.` Findings sorted file → line ascending.
59
+
60
+ ## Chaining patterns
61
+
62
+ **Locate → fix → verify** (most common):
63
+ 1. `cavecrew-investigator` returns site list.
64
+ 2. Main thread picks 1-2 sites, hands paths to `cavecrew-builder`.
65
+ 3. `cavecrew-reviewer` audits the diff.
66
+
67
+ **Parallel scout** (when investigation is broad):
68
+ Spawn 2-3 `cavecrew-investigator` calls in one message (different angles: defs vs callers vs tests). Aggregate in main thread.
69
+
70
+ **Single-shot edit** (when site is already known):
71
+ Skip investigator. Hand exact path:line to `cavecrew-builder` directly.
72
+
73
+ ## What NOT to do
74
+
75
+ - Don't use `cavecrew-builder` when you don't already know the file. Spawn investigator first or main thread will eat tokens passing context.
76
+ - Don't chain `cavecrew-investigator → cavecrew-builder` for a 5-file refactor. Builder will return `too-big.` and you'll have wasted a turn.
77
+ - Don't ask `cavecrew-reviewer` for "general feedback" — it returns findings only, no architecture opinions. Use `Code Reviewer` for that.
78
+ - Don't expect prose. Cavecrew output is structured, sometimes terse to the point of cryptic. If a human will read it directly, paraphrase.
79
+
80
+ ## Auto-clarity (inherited)
81
+
82
+ Subagents drop caveman → normal English for security warnings, irreversible-action confirmations, and any output where fragment ambiguity could be misread. Resume caveman after.
@@ -0,0 +1,48 @@
1
+ # caveman
2
+
3
+ Talk like smart caveman. Same brain, fewer tokens.
4
+
5
+ ## What it does
6
+
7
+ Compress every model response to caveman-style prose. Drops articles, filler, pleasantries, and hedging. Keeps every technical detail, code block, error string, and symbol exact. Cuts ~65-75% of output tokens with full accuracy preserved. Mode persists for the whole session until changed or stopped.
8
+
9
+ Six intensity levels:
10
+
11
+ | Level | What change |
12
+ |-------|-------------|
13
+ | `lite` | Drop filler/hedging. Sentences stay full. Professional but tight. |
14
+ | `full` | Default. Drop articles, fragments OK, short synonyms. |
15
+ | `ultra` | Bare fragments. Abbreviations (DB, auth, fn). Arrows for causality. |
16
+ | `wenyan-lite` | Classical Chinese register, light compression. |
17
+ | `wenyan-full` | Maximum 文言文. 80-90% character reduction. |
18
+ | `wenyan-ultra` | Extreme classical compression. |
19
+
20
+ Auto-clarity rule: caveman drops to normal prose for security warnings, irreversible-action confirmations, multi-step sequences where fragment ambiguity risks misread, and when user repeats a question. Resumes after the clear part.
21
+
22
+ ## How to invoke
23
+
24
+ ```
25
+ /caveman # full mode (default)
26
+ /caveman lite # lighter compression
27
+ /caveman ultra # extreme compression
28
+ /caveman wenyan # classical Chinese
29
+ stop caveman # back to normal prose
30
+ ```
31
+
32
+ ## Example output
33
+
34
+ Question: "Why does my React component re-render?"
35
+
36
+ Normal prose:
37
+ > Your component re-renders because you create a new object reference each render. Wrapping it in `useMemo` will fix the issue.
38
+
39
+ Caveman (full):
40
+ > New object ref each render. Inline object prop = new ref = re-render. Wrap in `useMemo`.
41
+
42
+ Caveman (ultra):
43
+ > Inline obj prop → new ref → re-render. `useMemo`.
44
+
45
+ ## See also
46
+
47
+ - [`SKILL.md`](./SKILL.md) — full LLM-facing instructions
48
+ - [Caveman README](../../README.md) — repo overview, install, benchmarks
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: caveman
3
+ description: >
4
+ Ultra-compressed communication mode. Cuts token usage ~75% by speaking like caveman
5
+ while keeping full technical accuracy. Supports intensity levels: lite, full (default), ultra,
6
+ wenyan-lite, wenyan-full, wenyan-ultra.
7
+ Use when user says "caveman mode", "talk like caveman", "use caveman", "less tokens",
8
+ "be brief", or invokes /caveman. Also auto-triggers when token efficiency is requested.
9
+ ---
10
+
11
+ Respond terse like smart caveman. All technical substance stay. Only fluff die.
12
+
13
+ ## Persistence
14
+
15
+ ACTIVE EVERY RESPONSE. No revert after many turns. No filler drift. Still active if unsure. Off only: "stop caveman" / "normal mode".
16
+
17
+ Default: **full**. Switch: `/caveman lite|full|ultra`.
18
+
19
+ ## Rules
20
+
21
+ Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course/happy to), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). Technical terms exact. Code blocks unchanged. Errors quoted exact.
22
+
23
+ Pattern: `[thing] [action] [reason]. [next step].`
24
+
25
+ Not: "Sure! I'd be happy to help you with that. The issue you're experiencing is likely caused by..."
26
+ Yes: "Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:"
27
+
28
+ ## Intensity
29
+
30
+ | Level | What change |
31
+ |-------|------------|
32
+ | **lite** | No filler/hedging. Keep articles + full sentences. Professional but tight |
33
+ | **full** | Drop articles, fragments OK, short synonyms. Classic caveman |
34
+ | **ultra** | Abbreviate prose words (DB/auth/config/req/res/fn/impl), strip conjunctions, arrows for causality (X → Y), one word when one word enough. Code symbols, function names, API names, error strings: never abbreviate |
35
+ | **wenyan-lite** | Semi-classical. Drop filler/hedging but keep grammar structure, classical register |
36
+ | **wenyan-full** | Maximum classical terseness. Fully 文言文. 80-90% character reduction. Classical sentence patterns, verbs precede objects, subjects often omitted, classical particles (之/乃/為/其) |
37
+ | **wenyan-ultra** | Extreme abbreviation while keeping classical Chinese feel. Maximum compression, ultra terse |
38
+
39
+ Example — "Why React component re-render?"
40
+ - lite: "Your component re-renders because you create a new object reference each render. Wrap it in `useMemo`."
41
+ - full: "New object ref each render. Inline object prop = new ref = re-render. Wrap in `useMemo`."
42
+ - ultra: "Inline obj prop → new ref → re-render. `useMemo`."
43
+ - wenyan-lite: "組件頻重繪,以每繪新生對象參照故。以 useMemo 包之。"
44
+ - wenyan-full: "物出新參照,致重繪。useMemo .Wrap之。"
45
+ - wenyan-ultra: "新參照→重繪。useMemo Wrap。"
46
+
47
+ Example — "Explain database connection pooling."
48
+ - lite: "Connection pooling reuses open connections instead of creating new ones per request. Avoids repeated handshake overhead."
49
+ - full: "Pool reuse open DB connections. No new connection per request. Skip handshake overhead."
50
+ - ultra: "Pool = reuse DB conn. Skip handshake → fast under load."
51
+ - wenyan-full: "池reuse open connection。不每req新開。skip handshake overhead。"
52
+ - wenyan-ultra: "池reuse conn。skip handshake → fast。"
53
+
54
+ ## Auto-Clarity
55
+
56
+ Drop caveman when:
57
+ - Security warnings
58
+ - Irreversible action confirmations
59
+ - Multi-step sequences where fragment order or omitted conjunctions risk misread
60
+ - Compression itself creates technical ambiguity (e.g., `"migrate table drop column backup first"` — order unclear without articles/conjunctions)
61
+ - User asks to clarify or repeats question
62
+
63
+ Resume caveman after clear part done.
64
+
65
+ Example — destructive op:
66
+ > **Warning:** This will permanently delete all rows in the `users` table and cannot be undone.
67
+ > ```sql
68
+ > DROP TABLE users;
69
+ > ```
70
+ > Caveman resume. Verify backup exist first.
71
+
72
+ ## Boundaries
73
+
74
+ Code/commits/PRs: write normal. "stop caveman" or "normal mode": revert. Level persist until changed or session end.
@@ -0,0 +1,44 @@
1
+ # caveman-commit
2
+
3
+ Terse Conventional Commits. Why over what.
4
+
5
+ ## What it does
6
+
7
+ Generates commit messages in Conventional Commits format. Subject ≤50 chars, hard cap 72. Imperative mood. Body only when the *why* is non-obvious or there are breaking changes. No AI attribution, no "this commit does X", no emoji unless the project uses them. Body always required for breaking changes, security fixes, data migrations, and reverts — future debuggers need the context.
8
+
9
+ Outputs only the message. Does not stage, commit, or amend.
10
+
11
+ ## How to invoke
12
+
13
+ ```
14
+ /caveman-commit
15
+ ```
16
+
17
+ Also triggers on phrases like "write a commit", "commit message", "generate commit".
18
+
19
+ ## Example output
20
+
21
+ Diff: new endpoint for user profile.
22
+
23
+ ```
24
+ feat(api): add GET /users/:id/profile
25
+
26
+ Mobile client needs profile data without the full user payload
27
+ to reduce LTE bandwidth on cold-launch screens.
28
+
29
+ Closes #128
30
+ ```
31
+
32
+ Diff: breaking API rename.
33
+
34
+ ```
35
+ feat(api)!: rename /v1/orders to /v1/checkout
36
+
37
+ BREAKING CHANGE: clients on /v1/orders must migrate to /v1/checkout
38
+ before 2026-06-01. Old route returns 410 after that date.
39
+ ```
40
+
41
+ ## See also
42
+
43
+ - [`SKILL.md`](./SKILL.md) — full LLM-facing instructions
44
+ - [Caveman README](../../README.md) — repo overview
@@ -0,0 +1,65 @@
1
+ ---
2
+ name: caveman-commit
3
+ description: >
4
+ Ultra-compressed commit message generator. Cuts noise from commit messages while preserving
5
+ intent and reasoning. Conventional Commits format. Subject ≤50 chars, body only when "why"
6
+ isn't obvious. Use when user says "write a commit", "commit message", "generate commit",
7
+ "/commit", or invokes /caveman-commit. Auto-triggers when staging changes.
8
+ ---
9
+
10
+ Write commit messages terse and exact. Conventional Commits format. No fluff. Why over what.
11
+
12
+ ## Rules
13
+
14
+ **Subject line:**
15
+ - `<type>(<scope>): <imperative summary>` — `<scope>` optional
16
+ - Types: `feat`, `fix`, `refactor`, `perf`, `docs`, `test`, `chore`, `build`, `ci`, `style`, `revert`
17
+ - Imperative mood: "add", "fix", "remove" — not "added", "adds", "adding"
18
+ - ≤50 chars when possible, hard cap 72
19
+ - No trailing period
20
+ - Match project convention for capitalization after the colon
21
+
22
+ **Body (only if needed):**
23
+ - Skip entirely when subject is self-explanatory
24
+ - Add body only for: non-obvious *why*, breaking changes, migration notes, linked issues
25
+ - Wrap at 72 chars
26
+ - Bullets `-` not `*`
27
+ - Reference issues/PRs at end: `Closes #42`, `Refs #17`
28
+
29
+ **What NEVER goes in:**
30
+ - "This commit does X", "I", "we", "now", "currently" — the diff says what
31
+ - "As requested by..." — use Co-authored-by trailer
32
+ - "Generated with Claude Code" or any AI attribution
33
+ - Emoji (unless project convention requires)
34
+ - Restating the file name when scope already says it
35
+
36
+ ## Examples
37
+
38
+ Diff: new endpoint for user profile with body explaining the why
39
+ - ❌ "feat: add a new endpoint to get user profile information from the database"
40
+ - ✅
41
+ ```
42
+ feat(api): add GET /users/:id/profile
43
+
44
+ Mobile client needs profile data without the full user payload
45
+ to reduce LTE bandwidth on cold-launch screens.
46
+
47
+ Closes #128
48
+ ```
49
+
50
+ Diff: breaking API change
51
+ - ✅
52
+ ```
53
+ feat(api)!: rename /v1/orders to /v1/checkout
54
+
55
+ BREAKING CHANGE: clients on /v1/orders must migrate to /v1/checkout
56
+ before 2026-06-01. Old route returns 410 after that date.
57
+ ```
58
+
59
+ ## Auto-Clarity
60
+
61
+ Always include body for: breaking changes, security fixes, data migrations, anything reverting a prior commit. Never compress these into subject-only — future debuggers need the context.
62
+
63
+ ## Boundaries
64
+
65
+ Only generates the commit message. Does not run `git commit`, does not stage files, does not amend. Output the message as a code block ready to paste. "stop caveman-commit" or "normal mode": revert to verbose commit style.
@@ -0,0 +1,163 @@
1
+ <p align="center">
2
+ <img src="https://em-content.zobj.net/source/apple/391/rock_1faa8.png" width="80" />
3
+ </p>
4
+
5
+ <h1 align="center">caveman-compress</h1>
6
+
7
+ <p align="center">
8
+ <strong>shrink memory file. save token every session.</strong>
9
+ </p>
10
+
11
+ ---
12
+
13
+ A Claude Code skill that compresses your project memory files (`CLAUDE.md`, todos, preferences) into caveman format — so every session loads fewer tokens automatically.
14
+
15
+ Claude read `CLAUDE.md` on every session start. If file big, cost big. Caveman make file small. Cost go down forever.
16
+
17
+ ## What It Do
18
+
19
+ ```
20
+ /caveman-compress CLAUDE.md
21
+ ```
22
+
23
+ ```
24
+ CLAUDE.md ← compressed (Claude reads this — fewer tokens every session)
25
+ CLAUDE.original.md ← human-readable backup (you edit this)
26
+ ```
27
+
28
+ Original never lost. You can read and edit `.original.md`. Run skill again to re-compress after edits.
29
+
30
+ ## Benchmarks
31
+
32
+ Real results on real project files:
33
+
34
+ | File | Original | Compressed | Saved |
35
+ |------|----------:|----------:|------:|
36
+ | `claude-md-preferences.md` | 706 | 285 | **59.6%** |
37
+ | `project-notes.md` | 1145 | 535 | **53.3%** |
38
+ | `claude-md-project.md` | 1122 | 636 | **43.3%** |
39
+ | `todo-list.md` | 627 | 388 | **38.1%** |
40
+ | `mixed-with-code.md` | 888 | 560 | **36.9%** |
41
+ | **Average** | **898** | **481** | **46%** |
42
+
43
+ All validations passed ✅ — headings, code blocks, URLs, file paths preserved exactly.
44
+
45
+ ## Before / After
46
+
47
+ <table>
48
+ <tr>
49
+ <td width="50%">
50
+
51
+ ### 📄 Original (706 tokens)
52
+
53
+ > "I strongly prefer TypeScript with strict mode enabled for all new code. Please don't use `any` type unless there's genuinely no way around it, and if you do, leave a comment explaining the reasoning. I find that taking the time to properly type things catches a lot of bugs before they ever make it to runtime."
54
+
55
+ </td>
56
+ <td width="50%">
57
+
58
+ ### 🪨 Caveman (285 tokens)
59
+
60
+ > "Prefer TypeScript strict mode always. No `any` unless unavoidable — comment why if used. Proper types catch bugs early."
61
+
62
+ </td>
63
+ </tr>
64
+ </table>
65
+
66
+ **Same instructions. 60% fewer tokens. Every. Single. Session.**
67
+
68
+ ## Security
69
+
70
+ `caveman-compress` is flagged as Snyk High Risk due to subprocess and file I/O patterns detected by static analysis. This is a false positive — see [SECURITY.md](./SECURITY.md) for a full explanation of what the skill does and does not do.
71
+
72
+ ## Install
73
+
74
+ Compress is built in with the `caveman` plugin. Install `caveman` once, then use `/caveman-compress`.
75
+
76
+ If you need local files, the compress skill lives at:
77
+
78
+ ```bash
79
+ caveman-compress/
80
+ ```
81
+
82
+ **Requires:** Python 3.10+
83
+
84
+ ## Usage
85
+
86
+ ```
87
+ /caveman-compress <filepath>
88
+ ```
89
+
90
+ Examples:
91
+ ```
92
+ /caveman-compress CLAUDE.md
93
+ /caveman-compress docs/preferences.md
94
+ /caveman-compress todos.md
95
+ ```
96
+
97
+ ### What files work
98
+
99
+ | Type | Compress? |
100
+ |------|-----------|
101
+ | `.md`, `.txt`, `.rst`, `.typ`, `.typst`, `.tex` | ✅ Yes |
102
+ | Extensionless natural language | ✅ Yes |
103
+ | `.py`, `.js`, `.ts`, `.json`, `.yaml` | ❌ Skip (code/config) |
104
+ | `*.original.md` | ❌ Skip (backup files) |
105
+
106
+ ## How It Work
107
+
108
+ ```
109
+ /caveman-compress CLAUDE.md
110
+
111
+ detect file type (no tokens)
112
+
113
+ Claude compresses (tokens — one call)
114
+
115
+ validate output (no tokens)
116
+ checks: headings, code blocks, URLs, file paths, bullets
117
+
118
+ if errors: Claude fixes cherry-picked issues only (tokens — targeted fix)
119
+ does NOT recompress — only patches broken parts
120
+
121
+ retry up to 2 times
122
+
123
+ write compressed → CLAUDE.md
124
+ write original → CLAUDE.original.md
125
+ ```
126
+
127
+ Only two things use tokens: initial compression + targeted fix if validation fails. Everything else is local Python.
128
+
129
+ ## What Is Preserved
130
+
131
+ Caveman compress natural language. It never touch:
132
+
133
+ - Code blocks (` ``` ` fenced or indented)
134
+ - Inline code (`` `backtick content` ``)
135
+ - URLs and links
136
+ - File paths (`/src/components/...`)
137
+ - Commands (`npm install`, `git commit`)
138
+ - Technical terms, library names, API names
139
+ - Headings (exact text preserved)
140
+ - Tables (structure preserved, cell text compressed)
141
+ - Dates, version numbers, numeric values
142
+
143
+ ## Why This Matter
144
+
145
+ `CLAUDE.md` loads on **every session start**. A 1000-token project memory file costs tokens every single time you open a project. Over 100 sessions that's 100,000 tokens of overhead — just for context you already wrote.
146
+
147
+ Caveman cut that by ~46% on average. Same instructions. Same accuracy. Less waste.
148
+
149
+ ```
150
+ ┌────────────────────────────────────────────┐
151
+ │ TOKEN SAVINGS PER FILE █████ 46% │
152
+ │ SESSIONS THAT BENEFIT ██████████ 100% │
153
+ │ INFORMATION PRESERVED ██████████ 100% │
154
+ │ SETUP TIME █ 1x │
155
+ └────────────────────────────────────────────┘
156
+ ```
157
+
158
+ ## Part of Caveman
159
+
160
+ This skill is part of the [caveman](https://github.com/JuliusBrussee/caveman) toolkit — making Claude use fewer tokens without losing accuracy.
161
+
162
+ - **caveman** — make Claude *speak* like caveman (cuts response tokens ~65%)
163
+ - **caveman-compress** — make Claude *read* less (cuts context tokens ~46%)
@@ -0,0 +1,31 @@
1
+ # Security
2
+
3
+ ## Snyk High Risk Rating
4
+
5
+ `caveman-compress` receives a Snyk High Risk rating due to static analysis heuristics. This document explains what the skill does and does not do.
6
+
7
+ ### What triggers the rating
8
+
9
+ 1. **subprocess usage**: The skill calls the `claude` CLI via `subprocess.run()` as a fallback when `ANTHROPIC_API_KEY` is not set. The subprocess call uses a fixed argument list — no shell interpolation occurs. User file content is passed via stdin, not as a shell argument.
10
+
11
+ 2. **File read/write**: The skill reads the file the user explicitly points it at, compresses it, and writes the result back to the same path. A `.original.md` backup is saved alongside it. No files outside the user-specified path are read or written.
12
+
13
+ ### What the skill does NOT do
14
+
15
+ - Does not execute user file content as code
16
+ - Does not make network requests except to Anthropic's API (via SDK or CLI)
17
+ - Does not access files outside the path the user provides
18
+ - Does not use shell=True or string interpolation in subprocess calls
19
+ - Does not collect or transmit any data beyond the file being compressed
20
+
21
+ ### Auth behavior
22
+
23
+ If `ANTHROPIC_API_KEY` is set, the skill uses the Anthropic Python SDK directly (no subprocess). If not set, it falls back to the `claude` CLI, which uses the user's existing Claude desktop authentication.
24
+
25
+ ### File size limit
26
+
27
+ Files larger than 500KB are rejected before any API call is made.
28
+
29
+ ### Reporting a vulnerability
30
+
31
+ If you believe you've found a genuine security issue, please open a GitHub issue with the label `security`.
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: caveman-compress
3
+ description: >
4
+ Compress natural language memory files (CLAUDE.md, todos, preferences) into caveman format
5
+ to save input tokens. Preserves all technical substance, code, URLs, and structure.
6
+ Compressed version overwrites the original file. Human-readable backup saved as FILE.original.md.
7
+ Trigger: /caveman-compress FILEPATH or "compress memory file"
8
+ ---
9
+
10
+ # Caveman Compress
11
+
12
+ ## Purpose
13
+
14
+ Compress natural language files (CLAUDE.md, todos, preferences) into caveman-speak to reduce input tokens. Compressed version overwrites original. Human-readable backup saved as `<filename>.original.md`.
15
+
16
+ ## Trigger
17
+
18
+ `/caveman-compress <filepath>` or when user asks to compress a memory file.
19
+
20
+ ## Process
21
+
22
+ 1. The compression scripts live in `scripts/` (adjacent to this SKILL.md). If the path is not immediately available, search for `scripts/__main__.py` next to this SKILL.md.
23
+
24
+ 2. From the directory containing this SKILL.md, run:
25
+
26
+ python3 -m scripts <absolute_filepath>
27
+
28
+ 3. The CLI will:
29
+ - detect file type (no tokens)
30
+ - call Claude to compress
31
+ - validate output (no tokens)
32
+ - if errors: cherry-pick fix with Claude (targeted fixes only, no recompression)
33
+ - retry up to 2 times
34
+ - if still failing after 2 retries: report error to user, leave original file untouched
35
+
36
+ 4. Return result to user
37
+
38
+ ## Compression Rules
39
+
40
+ ### Remove
41
+ - Articles: a, an, the
42
+ - Filler: just, really, basically, actually, simply, essentially, generally
43
+ - Pleasantries: "sure", "certainly", "of course", "happy to", "I'd recommend"
44
+ - Hedging: "it might be worth", "you could consider", "it would be good to"
45
+ - Redundant phrasing: "in order to" → "to", "make sure to" → "ensure", "the reason is because" → "because"
46
+ - Connective fluff: "however", "furthermore", "additionally", "in addition"
47
+
48
+ ### Preserve EXACTLY (never modify)
49
+ - Code blocks (fenced ``` and indented)
50
+ - Inline code (`backtick content`)
51
+ - URLs and links (full URLs, markdown links)
52
+ - File paths (`/src/components/...`, `./config.yaml`)
53
+ - Commands (`npm install`, `git commit`, `docker build`)
54
+ - Technical terms (library names, API names, protocols, algorithms)
55
+ - Proper nouns (project names, people, companies)
56
+ - Dates, version numbers, numeric values
57
+ - Environment variables (`$HOME`, `NODE_ENV`)
58
+
59
+ ### Preserve Structure
60
+ - All markdown headings (keep exact heading text, compress body below)
61
+ - Bullet point hierarchy (keep nesting level)
62
+ - Numbered lists (keep numbering)
63
+ - Tables (compress cell text, keep structure)
64
+ - Frontmatter/YAML headers in markdown files
65
+
66
+ ### Compress
67
+ - Use short synonyms: "big" not "extensive", "fix" not "implement a solution for", "use" not "utilize"
68
+ - Fragments OK: "Run tests before commit" not "You should always run tests before committing"
69
+ - Drop "you should", "make sure to", "remember to" — just state the action
70
+ - Merge redundant bullets that say the same thing differently
71
+ - Keep one example where multiple examples show the same pattern
72
+
73
+ CRITICAL RULE:
74
+ Anything inside ``` ... ``` must be copied EXACTLY.
75
+ Do not:
76
+ - remove comments
77
+ - remove spacing
78
+ - reorder lines
79
+ - shorten commands
80
+ - simplify anything
81
+
82
+ Inline code (`...`) must be preserved EXACTLY.
83
+ Do not modify anything inside backticks.
84
+
85
+ If file contains code blocks:
86
+ - Treat code blocks as read-only regions
87
+ - Only compress text outside them
88
+ - Do not merge sections around code
89
+
90
+ ## Pattern
91
+
92
+ Original:
93
+ > You should always make sure to run the test suite before pushing any changes to the main branch. This is important because it helps catch bugs early and prevents broken builds from being deployed to production.
94
+
95
+ Compressed:
96
+ > Run tests before push to main. Catch bugs early, prevent broken prod deploys.
97
+
98
+ Original:
99
+ > The application uses a microservices architecture with the following components. The API gateway handles all incoming requests and routes them to the appropriate service. The authentication service is responsible for managing user sessions and JWT tokens.
100
+
101
+ Compressed:
102
+ > Microservices architecture. API gateway route all requests to services. Auth service manage user sessions + JWT tokens.
103
+
104
+ ## Boundaries
105
+
106
+ - ONLY compress natural language files (.md, .txt, .typ, .typst, .tex, extensionless)
107
+ - NEVER modify: .py, .js, .ts, .json, .yaml, .yml, .toml, .env, .lock, .css, .html, .xml, .sql, .sh
108
+ - If file has mixed content (prose + code), compress ONLY the prose sections
109
+ - If unsure whether something is code or prose, leave it unchanged
110
+ - Original file is backed up as FILE.original.md before overwriting
111
+ - Never compress FILE.original.md (skip it)
@@ -0,0 +1,9 @@
1
+ """Caveman compress scripts.
2
+
3
+ This package provides tools to compress natural language markdown files
4
+ into caveman format to save input tokens.
5
+ """
6
+
7
+ __all__ = ['cli', 'compress', 'detect', 'validate']
8
+
9
+ __version__ = '1.0.0'
@@ -0,0 +1,4 @@
1
+ from .cli import main
2
+
3
+
4
+ main()