Files
Fabric/patterns/create_coding_feature/README.md
Kayvan Sylvan 9b56e0e996 feat: add fabric_code tool and create_coding_feature pattern
This commit introduces the `fabric_code` tool and the `create_coding_feature` pattern, allowing Fabric to modify existing codebases.

## CHANGES

-   add `fabric_code` tool to generate JSON representation of code projects
-   add `create_coding_feature` pattern to apply AI-generated code changes
-   update README with `fabric_code` installation and usage
-   walk file system with maximum depth and ignore list
-   scan directory and return file/dir JSON data for AI model
-   provide usage instructions and examples for `fabric_code`
-   add file management API to system prompt for code changes
2025-03-25 08:04:55 -07:00

1.5 KiB

Create Coding Feature

Generate code change to an existing coding project

Usage

After installing the fabric_code binary

go install github.com/danielmiessler/fabric/plugins/tools/fabric_code@latest

We can use it like this:

fabric_code . "Create a simple Hello World C program in file main.c" | fabric --pattern create_coding_feature

Example Workflow

Input

fabric_code . . "Ensure that all user input is validated and sanitized before being used in the program." | fabric --pattern create_coding_feature
git diff
make check;
git add <changed files>
git commit -s -m "Security fixes: Input validation"

Expected outcome

This feature enables the AI model to apply code changes to the existing project.

Before using this feature, it iss the responsibility of the user to have a clean git repo, so that the user can diff and review the changes.

Summary of the process

The AI working with the fabric tool automates file edits and creation in our project.

  1. Input directory and file contents are given to AI model using a standardized json format.
  2. AI to Generate code changes and produce file change/create annotations.
  3. The fabric CLI will interpret AI output via the file manager API, which will directly create and modify files and directories.
  4. User reviews code and approves changes in SCM of choice.

Suggestions for future improvements

  • Enhance script generation with conditional logic.
  • Include detailed logging for API responses.
  • Consider adding a GUI for ease of use.