[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7DC08K5RXPSB077RQR0W179":3,"skill-same:01M7DC08K5RXPSB077RQR0W179":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},"01M7DC08K5RXPSB077RQR0W179","python-functions",null,"Style and good practices when implementing or refactoring Python functions and methods","fabiommendes\u002Fcodehood-cli","fabiommendes","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1248626?v=4","01M7B2WVHQWE1G2F5M3BGZ15BV","Fábio Macêdo Mendes","01M7DBZY07P78Y6GNPNSH3E1CE",0,"MIT","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-functions\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: python-functions\ndescription: Style and good practices when implementing or refactoring Python functions and methods\n---\n\n# python-functions\n\nBest practices and style guide for implementing Python functions and methods.\n\n\n## Architecture\n\nAvoid side-effects. Most functions and methods should be pure or at least\nprovide local reasoning. Leave the most egregious side effects either to the\nframework or to an outer layer of the application.\n\nFor reference, the list shows effects from best to worst. \n\n* no side effects, pure function (best).\n* logging.\n* local mutation of self.\n* local mutation of input args.\n* caching.\n* print and input.\n* file I\u002FO, \n* database access.\n* image display, sound, complex rendering of markup.\n* network access.\n* global mutation of application behavior (worst).\n\nTry to keep implementations as high as possible in this list.\n\n## Testing\n\nPure functions should be tested with examples in unit tests. If the function\nrespect some invariant, use property-based testing to generate a wide range of \ninputs. Python's `hypothesis` library is a good choice for this.\n\nFunctions up to \"local mutation of input args\" can be tested with no special setup.\nAlways use property based tests, when an invariant is known. \n\nFunctions that use caching should usually reset the cache before each test.\n\nFunctions with simple IO should capture output using contextlib's \n`redirect_stdout` and `redirect_stderr` and mocking for `input`.\n\nFunctions that read files should use mocking and functions that write files\nshould do so in temporary directories.\n\nFunctions that access databases should use transactions and rollbacks to avoid \nleaving the database in a dirty state. Many frameworks provide built-in support \nfor this via pytest fixtures.\n\nFunctions that produces complex multimedia usually should be tested via approval\ntesting. Python have the approvaltests.Python library for this.\n\nNetwork access should usually be mocked in unit tests and tested in integration \ntests.\n\nWhen a function produces a global mutation of application behavior, it should \nshould also provide a snapshot mechanism that restore the application to its \nprevious state. Ideally it should be done using context managers. Ask the user\nif this mechanism should be exposed as a public API or not.\n\n\n## Coding style\n\nFollow PEP 8. Always type input and output parameters. If the function do not\nchange the input args, prefer abstract types over concrete ones, e.g., use \n\"Iterable\" instead of \"list\", \"Mapping\" instead of \"dict\", etc. Never use \"Any\",\nunless stricly needed. \n\n## Docstrings\n\nUse google style docstrings. Do not repeat the types in the docstring. Document\nany possible exceptions raised by the function. Document the return value, \nunless it is None. \n\nUnless the function is a one-liner, the docstring triple quotes should be on \ntheir own lines. \n\nThe first line of the docstring should be a short summary of the function's\npurpose. If there are more details, they should be included after a blank line.\n\nPublic functions that do not produce side effects should be documented with a\ndoctest example. Skip the test if it is too complex or requires too much\nexternal dependencies or preparation.\n","# python-functions\n\nBest practices and style guide for implementing Python functions and methods.\n\n\n## Architecture\n\nAvoid side-effects. Most functions and methods should be pure or at least\nprovide local reasoning. Leave the most egregious side effects either to the\nframework or to an outer layer of the application.\n\nFor reference, the list shows effects from best to worst. \n\n* no side effects, pure function (best).\n* logging.\n* local mutation of self.\n* local mutation of input args.\n* caching.\n* print and input.\n* file I\u002FO, \n* database access.\n* image display, sound, complex rendering of markup.\n* network access.\n* global mutation of application behavior (worst).\n\nTry to keep implementations as high as possible in this list.\n\n## Testing\n\nPure functions should be tested with examples in unit tests. If the function\nrespect some invariant, use property-based testing to generate a wide range of \ninputs. Python's `hypothesis` library is a good choice for this.\n\nFunctions up to \"local mutation of input args\" can be tested with no special setup.\nAlways use property based tests, when an invariant is known. \n\nFunctions that use caching should usually reset the cache before each test.\n\nFunctions with simple IO should capture output using contextlib's \n`redirect_stdout` and `redirect_stderr` and mocking for `input`.\n\nFunctions that read files should use mocking and functions that write files\nshould do so in temporary directories.\n\nFunctions that access databases should use transactions and rollbacks to avoid \nleaving the database in a dirty state. Many frameworks provide built-in support \nfor this via pytest fixtures.\n\nFunctions that produces complex multimedia usually should be tested via approval\ntesting. Python have the approvaltests.Python library for this.\n\nNetwork access should usually be mocked in unit tests and tested in integration \ntests.\n\nWhen a function produces a global mutation of application behavior, it should \nshould also provide a snapshot mechanism that restore the application to its \nprevious state. Ideally it should be done using context managers. Ask the user\nif this mechanism should be exposed as a public API or not.\n\n\n## Coding style\n\nFollow PEP 8. Always type input and output parameters. If the function do not\nchange the input args, prefer abstract types over concrete ones, e.g., use \n\"Iterable\" instead of \"list\", \"Mapping\" instead of \"dict\", etc. Never use \"Any\",\nunless stricly needed. \n\n## Docstrings\n\nUse google style docstrings. Do not repeat the types in the docstring. Document\nany possible exceptions raised by the function. Document the return value, \nunless it is None. \n\nUnless the function is a one-liner, the docstring triple quotes should be on \ntheir own lines. \n\nThe first line of the docstring should be a short summary of the function's\npurpose. If there are more details, they should be included after a blank line.\n\nPublic functions that do not produce side effects should be documented with a\ndoctest example. Skip the test if it is too complex or requires too much\nexternal dependencies or preparation.\n",{"name":5,"description":7},"main","c739d83b48c0708f55498864294af01123d6c5f2",".claude\u002Fskills\u002Fpython-functions","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli","https:\u002F\u002Fgithub.com\u002Ffabiommendes","2026-11-14 20:55:29",{"source":8,"skillName":5,"commands":31,"prompt":41,"zipAvailable":42},[32,35,38],{"tool":33,"command":34},"npx","npx skills add fabiommendes\u002Fcodehood-cli --skill python-functions",{"tool":36,"command":37},"bunx","bunx skills add fabiommendes\u002Fcodehood-cli --skill python-functions",{"tool":39,"command":40},"pnpm","pnpm dlx skills add fabiommendes\u002Fcodehood-cli --skill python-functions","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-functions\u002FSKILL.md",true,[],[45,52,59,66,73,80],{"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},"01M7DC0N00YJHWNS4MXGPDKX0V","unslop","Cut AI tells from any writing. Must always apply.","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Funslop\u002FSKILL.md",[],[],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":56,"categories":57,"keywords":58,"publishedAt":19},"01M7DC0KSF9JPBVYDEX5JG5CFH","python-publish","Guidelines to publish Python packages","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-publish\u002FSKILL.md",[],[],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":19},"01M7DC0HVE7915R27139YGZ6VE","python-projects","Style and good practices when implementing Python projects","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-projects\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":19},"01M7DC0F1R77HAG40S5B23DDEE","python-paths","Good practices when working with file paths in Python","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-paths\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":77,"categories":78,"keywords":79,"publishedAt":19},"01M7DC0C3H3VTWMJJAWDGMJSB4","python-modules","Style and good practices when implementing or refactoring Python modules","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpython-modules\u002FSKILL.md",[],[],{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M7DC061MX3KX7PXMARDJ4S5R","principle-subtract-before-you-add","Apply when sequencing an addition, refactor, or rewrite. Remove dead weight, redundant validators, and stub references first, then build on the simpler base.","https:\u002F\u002Fgithub.com\u002Ffabiommendes\u002Fcodehood-cli\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fprinciple-subtract-before-you-add\u002FSKILL.md",[],[]]