[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D2JZ5P0TX8HMCVEPMZ7VX5":3,"skill-same:01M7D2JZ5P0TX8HMCVEPMZ7VX5":44},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":14,"repositoryHtmlUrl":27,"repositoryHomepageUrl":6,"ownerHtmlUrl":28,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":29,"install":30,"resources":43},"01M7D2JZ5P0TX8HMCVEPMZ7VX5","backend-unit-testing",null,"Enforces Skillscope's pytest unit-test conventions for the Python backend. Use when creating, modifying, or reviewing unit tests, domain logic, application use cases, canonical event parsing, test doubles, fixtures, or code under tests\u002Funit.","ganan-s\u002Fskillscope","ganan-s","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F35375634?v=4","01M7D2JD9JNTDC32EMNQK3SZ8K","Ganan","01M7D2JDA79T5R2JXDV9RWEAG3",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002F.cursor\u002Fskills\u002Fbackend-unit-testing\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: backend-unit-testing\ndescription: Enforces Skillscope's pytest unit-test conventions for the Python backend. Use when creating, modifying, or reviewing unit tests, domain logic, application use cases, canonical event parsing, test doubles, fixtures, or code under tests\u002Funit.\n---\n\n# Backend unit testing\n\nApply these conventions to Skillscope backend unit tests. Also apply\n`backend-hexagonal-architecture` when the tested code changes architectural\nboundaries.\n\n## Role in the testing pyramid\n\nUnit tests form the broad base of the test suite. They provide fast,\ndeterministic feedback about one unit of behavior without exercising\ninfrastructure.\n\nA unit test:\n\n- runs entirely in one Python process;\n- performs no filesystem, SQLite, network, subprocess, clock, or environment\n  I\u002FO;\n- does not start FastAPI or use its test client;\n- does not load migrations or production configuration; and\n- finishes independently of test execution order.\n\nIf a test needs a real database, filesystem, HTTP stack, composition root, or\nmultiple concrete adapters, it belongs in the integration or end-to-end suite.\n\n## Framework and location\n\nUse `pytest`.\n\nPlace tests under `tests\u002Funit\u002F`, mirroring the production package:\n\n```text\ntests\u002Funit\u002F\n  domain\u002F\n  application\u002F\n  adapters\u002F\n```\n\nUse `adapters\u002F` only for pure adapter logic such as native-record normalization\nor row\u002FDTO mapping. Tests that open files, SQLite connections, or HTTP clients\nare not unit tests.\n\nName files `test_\u003Csubject>.py`. Name tests:\n\n```text\ntest_\u003Cbehavior>_\u003Ccondition>_\u003Cexpected_outcome>\n```\n\nPrefer test functions. Use classes only to group related scenarios; do not use\ntest-class inheritance.\n\n## What to unit test\n\nPrioritize:\n\n- domain invariants and value-object behavior;\n- application use cases through their ports;\n- ingest eligibility and canonical event classification;\n- idempotency and replacement decisions expressed as pure logic;\n- error translation at application boundaries;\n- source-bucket and path classification;\n- frontmatter and native-record normalization from in-memory values;\n- deterministic DTO mapping; and\n- every bug fix with a focused regression test.\n\nDo not unit-test trivial dataclass construction, framework behavior, Python\nstandard-library behavior, or private implementation details with no observable\ncontract.\n\n## Test shape\n\nUse Arrange–Act–Assert with visual separation:\n\n```python\ndef test_ingest_when_revision_is_unchanged_returns_noop() -> None:\n    repository = FakeConversationRepository(existing_revision=\"revision-1\")\n    use_case = IngestConversation(repository=repository)\n    snapshot = conversation_snapshot(revision=\"revision-1\")\n\n    result = use_case(snapshot)\n\n    assert result.status == IngestStatus.UNCHANGED\n    assert repository.saved_snapshots == []\n```\n\nEach test should communicate one behavior. Multiple assertions are appropriate\nwhen they describe one outcome.\n\nAssert public results, state changes, emitted domain events, or errors. Avoid\nasserting private methods, incidental call order, or the exact sequence of\ninternal helper calls.\n\n## Test doubles\n\nUse small, handwritten fakes for application ports when state matters:\n\n```python\nclass FakeConversationRepository:\n    def __init__(self) -> None:\n        self.saved_snapshots: list[ConversationSnapshot] = []\n\n    def save(self, snapshot: ConversationSnapshot) -> None:\n        self.saved_snapshots.append(snapshot)\n```\n\nFakes must implement the real port and expose only the controls and observations\nneeded by tests.\n\nUse `unittest.mock` sparingly:\n\n- create mocks with `spec_set` against the port;\n- mock only outbound boundaries;\n- use a mock when the interaction itself is the behavior;\n- do not patch domain objects, application internals, or functions merely to\n  make implementation-specific assertions; and\n- do not mock a concrete adapter to test another concrete adapter.\n\nIf a test needs many mocks, reconsider the production boundary or classify the\ntest as integration.\n\n## Fixtures and builders\n\nKeep fixtures local to a test module by default. Move a fixture to\n`tests\u002Funit\u002Fconftest.py` only when it is broadly shared and has one clear\npurpose.\n\nDo not use autouse fixtures for domain or application state.\n\nUse explicit builders for canonical records with sensible valid defaults:\n\n```python\ndef conversation_snapshot(\n    *,\n    conversation_id: str = \"conversation-1\",\n    revision: str = \"revision-1\",\n) -> ConversationSnapshot: ...\n```\n\nOverride only values relevant to the scenario. Builders must not hide I\u002FO,\nrandomness, current time, or database setup.\n\nUse realistic but synthetic values. Never copy personal prompts, email\naddresses, absolute home paths, or raw local transcripts into unit tests.\n\n## Determinism\n\nInject nondeterministic capabilities through ports or explicit parameters:\n\n- clock\u002Ftime;\n- ID generation;\n- source revision;\n- platform;\n- home and workspace roots; and\n- ordering inputs.\n\nUse fixed UTC datetimes and stable IDs. Never use `sleep`, retry loops,\nunseeded randomness, the current machine's home directory, or test-order\ndependencies.\n\nDo not use `tmp_path` in unit tests. Pass in-memory records or path strings to\npure functions; filesystem behavior belongs in integration tests.\n\n## Parametrization\n\nUse `pytest.mark.parametrize` for the same behavior across meaningful inputs,\nespecially:\n\n- exact `SKILL.md` positive cases;\n- negative filename, glob, directory, shell, grep, and edit cases;\n- supported source buckets;\n- readiness states;\n- malformed frontmatter; and\n- error mappings.\n\nGive complex cases readable IDs. Do not compress unrelated behaviors into one\nlarge parameter matrix.\n\n## Exceptions and diagnostics\n\nUse `pytest.raises` around only the operation expected to fail:\n\n```python\nwith pytest.raises(InvalidSnapshotError) as raised:\n    validate_snapshot(snapshot)\n\nassert raised.value.code == \"missing_conversation_id\"\n```\n\nPrefer stable error types, codes, and structured fields over full-message\nequality. Assert message text only when wording is part of the public contract.\n\nFor operations that return diagnostics instead of raising, assert the stable\ndiagnostic code and relevant safe fields.\n\n## Boundaries specific to Skillscope\n\n- Test application use cases against harness and repository ports, not Cursor\n  or SQLite implementations.\n- Test Cursor normalization from in-memory native dictionaries. Reading JSONL\n  fixtures from disk is an integration test.\n- Test repository decisions as pure policies when possible; test actual SQL in\n  the integration suite.\n- Test REST mapping as pure functions only. Route registration, validation,\n  middleware, OpenAPI, and status codes belong in integration tests.\n- Confirm unknown or failed read evidence never becomes `skill.activated`.\n- Confirm repeated activations retain distinct stable identities.\n- Confirm missing payloads preserve the path and mark the snapshot unavailable.\n\n## Quality requirements\n\nEvery test must be:\n\n- behavior-focused;\n- deterministic;\n- isolated;\n- readable without opening the implementation;\n- free of production secrets and machine-specific state; and\n- fast enough to run continuously during development.\n\nDo not pursue a coverage percentage by testing incidental lines. New or changed\ndomain and application branches require meaningful unit coverage, including\nnegative and error paths.\n\n## Running the suite\n\nThe canonical command is:\n\n```bash\npytest tests\u002Funit\n```\n\nUnit tests must not require network access, external services, an existing\nSkillscope database, Cursor installation, user hooks, or files outside the\nrepository.\n\n## Review checklist\n\n- The test belongs at the unit layer.\n- It mirrors the production module under `tests\u002Funit`.\n- Its name states behavior, condition, and outcome.\n- It has no I\u002FO or framework startup.\n- It tests public behavior rather than implementation details.\n- Ports use small fakes or narrowly specified mocks.\n- Time, IDs, paths, and revisions are deterministic.\n- Fixtures are explicit and synthetic.\n- Parameterization improves clarity rather than hiding behavior.\n- Error and negative paths are covered.\n- The test passes alone and in any suite order.\n","# Backend unit testing\n\nApply these conventions to Skillscope backend unit tests. Also apply\n`backend-hexagonal-architecture` when the tested code changes architectural\nboundaries.\n\n## Role in the testing pyramid\n\nUnit tests form the broad base of the test suite. They provide fast,\ndeterministic feedback about one unit of behavior without exercising\ninfrastructure.\n\nA unit test:\n\n- runs entirely in one Python process;\n- performs no filesystem, SQLite, network, subprocess, clock, or environment\n  I\u002FO;\n- does not start FastAPI or use its test client;\n- does not load migrations or production configuration; and\n- finishes independently of test execution order.\n\nIf a test needs a real database, filesystem, HTTP stack, composition root, or\nmultiple concrete adapters, it belongs in the integration or end-to-end suite.\n\n## Framework and location\n\nUse `pytest`.\n\nPlace tests under `tests\u002Funit\u002F`, mirroring the production package:\n\n```text\ntests\u002Funit\u002F\n  domain\u002F\n  application\u002F\n  adapters\u002F\n```\n\nUse `adapters\u002F` only for pure adapter logic such as native-record normalization\nor row\u002FDTO mapping. Tests that open files, SQLite connections, or HTTP clients\nare not unit tests.\n\nName files `test_\u003Csubject>.py`. Name tests:\n\n```text\ntest_\u003Cbehavior>_\u003Ccondition>_\u003Cexpected_outcome>\n```\n\nPrefer test functions. Use classes only to group related scenarios; do not use\ntest-class inheritance.\n\n## What to unit test\n\nPrioritize:\n\n- domain invariants and value-object behavior;\n- application use cases through their ports;\n- ingest eligibility and canonical event classification;\n- idempotency and replacement decisions expressed as pure logic;\n- error translation at application boundaries;\n- source-bucket and path classification;\n- frontmatter and native-record normalization from in-memory values;\n- deterministic DTO mapping; and\n- every bug fix with a focused regression test.\n\nDo not unit-test trivial dataclass construction, framework behavior, Python\nstandard-library behavior, or private implementation details with no observable\ncontract.\n\n## Test shape\n\nUse Arrange–Act–Assert with visual separation:\n\n```python\ndef test_ingest_when_revision_is_unchanged_returns_noop() -> None:\n    repository = FakeConversationRepository(existing_revision=\"revision-1\")\n    use_case = IngestConversation(repository=repository)\n    snapshot = conversation_snapshot(revision=\"revision-1\")\n\n    result = use_case(snapshot)\n\n    assert result.status == IngestStatus.UNCHANGED\n    assert repository.saved_snapshots == []\n```\n\nEach test should communicate one behavior. Multiple assertions are appropriate\nwhen they describe one outcome.\n\nAssert public results, state changes, emitted domain events, or errors. Avoid\nasserting private methods, incidental call order, or the exact sequence of\ninternal helper calls.\n\n## Test doubles\n\nUse small, handwritten fakes for application ports when state matters:\n\n```python\nclass FakeConversationRepository:\n    def __init__(self) -> None:\n        self.saved_snapshots: list[ConversationSnapshot] = []\n\n    def save(self, snapshot: ConversationSnapshot) -> None:\n        self.saved_snapshots.append(snapshot)\n```\n\nFakes must implement the real port and expose only the controls and observations\nneeded by tests.\n\nUse `unittest.mock` sparingly:\n\n- create mocks with `spec_set` against the port;\n- mock only outbound boundaries;\n- use a mock when the interaction itself is the behavior;\n- do not patch domain objects, application internals, or functions merely to\n  make implementation-specific assertions; and\n- do not mock a concrete adapter to test another concrete adapter.\n\nIf a test needs many mocks, reconsider the production boundary or classify the\ntest as integration.\n\n## Fixtures and builders\n\nKeep fixtures local to a test module by default. Move a fixture to\n`tests\u002Funit\u002Fconftest.py` only when it is broadly shared and has one clear\npurpose.\n\nDo not use autouse fixtures for domain or application state.\n\nUse explicit builders for canonical records with sensible valid defaults:\n\n```python\ndef conversation_snapshot(\n    *,\n    conversation_id: str = \"conversation-1\",\n    revision: str = \"revision-1\",\n) -> ConversationSnapshot: ...\n```\n\nOverride only values relevant to the scenario. Builders must not hide I\u002FO,\nrandomness, current time, or database setup.\n\nUse realistic but synthetic values. Never copy personal prompts, email\naddresses, absolute home paths, or raw local transcripts into unit tests.\n\n## Determinism\n\nInject nondeterministic capabilities through ports or explicit parameters:\n\n- clock\u002Ftime;\n- ID generation;\n- source revision;\n- platform;\n- home and workspace roots; and\n- ordering inputs.\n\nUse fixed UTC datetimes and stable IDs. Never use `sleep`, retry loops,\nunseeded randomness, the current machine's home directory, or test-order\ndependencies.\n\nDo not use `tmp_path` in unit tests. Pass in-memory records or path strings to\npure functions; filesystem behavior belongs in integration tests.\n\n## Parametrization\n\nUse `pytest.mark.parametrize` for the same behavior across meaningful inputs,\nespecially:\n\n- exact `SKILL.md` positive cases;\n- negative filename, glob, directory, shell, grep, and edit cases;\n- supported source buckets;\n- readiness states;\n- malformed frontmatter; and\n- error mappings.\n\nGive complex cases readable IDs. Do not compress unrelated behaviors into one\nlarge parameter matrix.\n\n## Exceptions and diagnostics\n\nUse `pytest.raises` around only the operation expected to fail:\n\n```python\nwith pytest.raises(InvalidSnapshotError) as raised:\n    validate_snapshot(snapshot)\n\nassert raised.value.code == \"missing_conversation_id\"\n```\n\nPrefer stable error types, codes, and structured fields over full-message\nequality. Assert message text only when wording is part of the public contract.\n\nFor operations that return diagnostics instead of raising, assert the stable\ndiagnostic code and relevant safe fields.\n\n## Boundaries specific to Skillscope\n\n- Test application use cases against harness and repository ports, not Cursor\n  or SQLite implementations.\n- Test Cursor normalization from in-memory native dictionaries. Reading JSONL\n  fixtures from disk is an integration test.\n- Test repository decisions as pure policies when possible; test actual SQL in\n  the integration suite.\n- Test REST mapping as pure functions only. Route registration, validation,\n  middleware, OpenAPI, and status codes belong in integration tests.\n- Confirm unknown or failed read evidence never becomes `skill.activated`.\n- Confirm repeated activations retain distinct stable identities.\n- Confirm missing payloads preserve the path and mark the snapshot unavailable.\n\n## Quality requirements\n\nEvery test must be:\n\n- behavior-focused;\n- deterministic;\n- isolated;\n- readable without opening the implementation;\n- free of production secrets and machine-specific state; and\n- fast enough to run continuously during development.\n\nDo not pursue a coverage percentage by testing incidental lines. New or changed\ndomain and application branches require meaningful unit coverage, including\nnegative and error paths.\n\n## Running the suite\n\nThe canonical command is:\n\n```bash\npytest tests\u002Funit\n```\n\nUnit tests must not require network access, external services, an existing\nSkillscope database, Cursor installation, user hooks, or files outside the\nrepository.\n\n## Review checklist\n\n- The test belongs at the unit layer.\n- It mirrors the production module under `tests\u002Funit`.\n- Its name states behavior, condition, and outcome.\n- It has no I\u002FO or framework startup.\n- It tests public behavior rather than implementation details.\n- Ports use small fakes or narrowly specified mocks.\n- Time, IDs, paths, and revisions are deterministic.\n- Fixtures are explicit and synthetic.\n- Parameterization improves clarity rather than hiding behavior.\n- Error and negative paths are covered.\n- The test passes alone and in any suite order.\n",{"name":5,"description":7},"main","38802a07d3275daa93def8f87bb59ed53b4a2ad7",".cursor\u002Fskills\u002Fbackend-unit-testing","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope","https:\u002F\u002Fgithub.com\u002Fganan-s","2026-09-20 10:11:27",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add ganan-s\u002Fskillscope --skill backend-unit-testing",{"tool":36,"command":37},"bunx","bunx skills add ganan-s\u002Fskillscope --skill backend-unit-testing",{"tool":39,"command":40},"pnpm","pnpm dlx skills add ganan-s\u002Fskillscope --skill backend-unit-testing","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002F.cursor\u002Fskills\u002Fbackend-unit-testing\u002FSKILL.md",true,[],[45,52,57,64,71],{"skillNo":46,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":49,"categories":50,"keywords":51,"publishedAt":19},"01M7D2KBS5S4MG82STB8SG9C6S","skillscope-probe","Benign fixture used to verify Cursor read-hook payloads.","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002Fexperiments\u002Fcursor-hook-probe\u002Ffixtures\u002Fprobe-skill\u002FSKILL.md",[],[],{"skillNo":53,"name":47,"nameZh":6,"description":48,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":19},"01M7D2K91SSKZKFCFJRPWN6C56","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002Fexperiments\u002Fcursor-golden-session\u002Ffixtures\u002Fprobe-skill\u002FSKILL.md",[],[],{"skillNo":58,"name":59,"nameZh":6,"description":60,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":61,"categories":62,"keywords":63,"publishedAt":19},"01M7D2JSWWDGZBENQ96RCKXVNV","backend-integration-testing","Enforces Skillscope's pytest integration-test conventions for the Python backend. Use when testing SQLite repositories and migrations, Cursor transcript and hook adapters, FastAPI routes, CLI wiring, composition roots, filesystem fixtures, or code under tests\u002Fintegration.","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002F.cursor\u002Fskills\u002Fbackend-integration-testing\u002FSKILL.md",[],[],{"skillNo":65,"name":66,"nameZh":6,"description":67,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":68,"categories":69,"keywords":70,"publishedAt":19},"01M7D2JNFN05SGAZV6DWYB2PK6","backend-hexagonal-architecture","Enforces Skillscope's hexagonal Python backend architecture. Use when creating, modifying, or reviewing backend domain models, application services, ports, FastAPI routes, CLI commands, SQLite repositories, harness plugins, composition wiring, or other code under src\u002Fskillscope.","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002F.cursor\u002Fskills\u002Fbackend-hexagonal-architecture\u002FSKILL.md",[],[],{"skillNo":72,"name":73,"nameZh":6,"description":74,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":75,"categories":76,"keywords":77,"publishedAt":19},"01M7D2JGZX7JCC3ZRPMAT2XHV4","backend-e2e-testing","Enforces Skillscope's end-to-end testing conventions for installed wheels, subprocesses, Testcontainers, Docker-compatible runtimes, live HTTP requests, and Playwright. Use when creating or reviewing tests under tests\u002Fe2e or testing packaged service and dashboard workflows.","https:\u002F\u002Fgithub.com\u002Fganan-s\u002Fskillscope\u002Fblob\u002Fmain\u002F.cursor\u002Fskills\u002Fbackend-e2e-testing\u002FSKILL.md",[],[]]