{"id":21449539,"url":"https://github.com/peetya/snipforge-cli","last_synced_at":"2025-07-14T20:31:35.087Z","repository":{"id":160672398,"uuid":"634763109","full_name":"peetya/snipforge-cli","owner":"peetya","description":"🤖 AI-powered code snippet generator using ChatGPT. Generate code in various languages based on natural language descriptions!","archived":false,"fork":false,"pushed_at":"2023-05-12T15:36:27.000Z","size":309,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-08T14:52:30.403Z","etag":null,"topics":["ai","artificial-intelligence","chatgpt","cli","code-generator","gpt-3","gpt-4","openai"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peetya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-01T05:50:46.000Z","updated_at":"2024-12-15T04:48:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"af420e7a-1c41-4d94-a647-8f55c077acbc","html_url":"https://github.com/peetya/snipforge-cli","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/peetya/snipforge-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peetya%2Fsnipforge-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peetya%2Fsnipforge-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peetya%2Fsnipforge-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peetya%2Fsnipforge-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peetya","download_url":"https://codeload.github.com/peetya/snipforge-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peetya%2Fsnipforge-cli/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265344831,"owners_count":23750566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","artificial-intelligence","chatgpt","cli","code-generator","gpt-3","gpt-4","openai"],"created_at":"2024-11-23T03:21:31.579Z","updated_at":"2025-07-14T20:31:34.704Z","avatar_url":"https://github.com/peetya.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SnipForge - AI-Powered Code Snippet Generator\n\n![GitHub](https://img.shields.io/github/license/peetya/snipforge-cli)\n\n\u003e **SnipForge** is a powerful command-line interface (CLI) tool that utilizes OpenAI's GPT technology to generate code \n\u003e snippets for various programming and tooling languages based on a given description. It aims to save time and effort \n\u003e for developers by providing a convenient way to generate code on-demand.\n\n![Demo](./docs/demo.gif)\n\n## Table of Contents\n\n- [Features](#features)\n- [Installation](#installation)\n  - [Binary Installation](#binary-installation)\n  - [Local Installation](#local-installation)\n- [Usage](#usage)\n- [Flags](#flags)\n- [Example](#example)\n  - [Basic example](#basic-example)\n  - [Advanced example](#advanced-example)\n- [Important Note on Generated Output](#important-note-on-generated-output)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Features\n\n- Leverages OpenAI's GPT technology for intelligent code snippet generation\n- Supports multiple programming and tooling languages\n- Matches your specific needs with customizable options\n- Guides you through the code generation process in interactive mode step-by-step \n- Outputs code snippets to `stdout` or saves them to a file\n\n## Installation\n\n### Binary Installation\n\n1. Download the appropriate binary for your operating system from the [latest release](https://github.com/peetya/snipforge-cli/releases/latest) page.\n2. Extract the downloaded archive and place the `snipforge` binary in a directory that is included in your system's `PATH`.\n3. Open a terminal and type `snipforge version` to confirm the installation was successful.\n\n### Local Installation\n\nIf you prefer to run SnipForge from source, follow these steps:\n\n1. Clone the repository:\n```bash\n$ git clone https://github.com/peetya/snipforge-cli.git\n```\n\n2. Change into the `snipforge-cli` directory:\n```bash\n$ cd snipforge-cli\n```\n\n3. Install the necessary dependencies:\n```bash\n$ go mod download\n```\n\n4. Run:\n```bash\n$ go run main.go version\n```\n\n## Usage\n\nTo get started with **SnipForge**, install the CLI tool and run the `generate` command, providing the required flags and \noptions. Alternatively, you can start the interactive mode by running the `generate` command without any flags, which \nwill guide you through the code generation process step-by-step.\n\n```bash\n$ snipforge generate [flags]\n```\n\nFor more information on available commands and flags, refer to the help output by running:\n\n```bash\n$ snipforge generate --help\n```\n\n## Flags\n\nHere's a detailed explanation of the available flags for the `generate` command:\n\n```bash\n  -d, --dry-run                      do not generate a code snippet, only print the generated description\n  -g, --goal string                  the functionality description for the code snippet\n  -h, --help                         help for generate\n  -l, --language string              the programming or tooling language to generate code in (e.g. PHP, Golang, etc...)\n  -v, --language-version string      the version of the programming or tooling language to generate code for (if applicable)\n  -k, --openai-key string            the OpenAI API key\n      --openai-max-tokens int        the maximum number of tokens to generate\n  -m, --openai-model string          the OpenAI model to use\n      --openai-temperature float32   the sampling temperature for the OpenAI model (between 0.0 and 2.0)\n  -o, --output string                the output file path for the generated code snippet\n  -q, --quiet                        suppress all output except for the generated code snippet\n      --stdout                       print the generated code snippet to isStdout instead of saving to a file\n\n```\n\n## Example\n\n### Basic example\n\nHere's a basic example of how to use SnipForge to generate a Python code snippet for sorting a list of numbers:\n\n```bash\n$ snipforge generate --language python --language-version 3.11 --goal \"sort a list of numbers\" --output sorted_numbers.py\n```\n\nThis command will generate a Python code snippet in the `sorted_numbers.py` file, with the goal of sorting a list of \nnumbers.\n\n```python\nnumbers = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]\nnumbers.sort()\nprint(numbers)\n```\n\n### Advanced example\n\nHere's an advanced example demonstrating how to use SnipForge to generate a PHP code snippet that fulfills more complex \ngoals. In this example, we'll use SnipForge in interactive mode.\n\n```bash\n$ snipforge generate\n```\n\nFirst, we need to define a set of goals that will be used to generate the snippet.\n\n```\nWhat are your goals?\n\n┃  1 A controller that returns a list of users via the \"/api/v1/users\" endpoint                     \n┃  2 The output format can be changed via content negotiaton                                        \n┃  3 Support pagination using the page and limit query parameters                                   \n┃  4 Read the users from the injected UserRepositoryInterface                                       \n┃  5 The controller must follow PSR-4 and PSR-12 standards                                          \n```\n\nNext, we need to define the programming language and version to generate the snippet for.\n\n```\nWhich programming or tooling language do you want to use?\n\n\u003e Symfony \n```\n\n```\nWhich version of PHP do you want to use? (optional)\n\n\u003e 6 \n```\n\nThen we need to define the output path:\n\n```\nWhere do you want to save the snippet? \n\n\u003e src/Controller/Api/V1/UserController.php \n```\n\nThen it will generate the following code snippet for you in `src/Controller/Api/V1/UserController.php`:\n\n```php\n\u003c?php\n\n// src/Controller/Api/V1/UserController.php\n\nnamespace App\\Controller\\Api\\V1;\n\nuse App\\Repository\\UserRepositoryInterface;\nuse Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n\n#[Route('/api/v1/users')]\nclass UserController extends AbstractController\n{\n    public function __construct(private UserRepositoryInterface $userRepository)\n    {\n    }\n\n    #[Route('', name: 'api_v1_users_index', methods: ['GET'])]\n    public function index(Request $request): Response\n    {\n        $page = $request-\u003equery-\u003egetInt('page', 1);\n        $limit = $request-\u003equery-\u003egetInt('limit', 10);\n\n        $users = $this-\u003euserRepository-\u003egetPaginatedUsers($page, $limit);\n\n        $serializer = $this-\u003econtainer-\u003eget('serializer');\n        $content = $serializer-\u003eserialize(['data' =\u003e $users], $request-\u003egetPreferredFormat(), ['groups' =\u003e ['user']]\n\n        return new Response($content, 200, ['Content-Type' =\u003e $request-\u003egetMimeType($request-\u003egetPreferredFormat())]);\n    }\n}\n```\n\n## Important Note on Generated Output\n\nWhile SnipForge does its best to generate accurate and functional code snippets, it's crucial to review the generated \noutput before using it in your projects. AI-generated code may sometimes contain errors or inconsistencies, so always \ndouble-check the results to ensure correctness.\n\n## Contributing\n\nSnipForge is an open-source project, and we welcome contributions from developers like you! Feel free to submit issues, \nsuggest new features, or create pull requests to help improve the project. We appreciate your support and collaboration. \n:heart:\n\n## License\n\nSnipForge is released under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeetya%2Fsnipforge-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeetya%2Fsnipforge-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeetya%2Fsnipforge-cli/lists"}