Skip to content

Instantly share code, notes, and snippets.

@vgrichina
Last active March 18, 2025 02:59
Show Gist options
  • Save vgrichina/221797e556916557dc31c3b81eafe554 to your computer and use it in GitHub Desktop.
Save vgrichina/221797e556916557dc31c3b81eafe554 to your computer and use it in GitHub Desktop.
minimal-ai-coder.md

Minimalistic AI Coding Assistant

1. ./context - Code Context Generator

Purpose

Generate contextual information from a codebase to send to an LLM.

Arguments

--files=<pattern>        File pattern to include (e.g., "src/*.js")
--exclude=<pattern>      File pattern to exclude (e.g., "node_modules/**")
--max-size=<size>        Maximum context size in KB/MB (e.g., "500KB")
--include-deps           Include dependent files based on imports/requires
--depth=<num>            Dependency traversal depth (default: 1)
--include-git            Include git information (recent commits, authors)
--git-depth=<num>        Number of recent commits to include (default: 3)
--format=<format>        Output format (md, json, text) (default: md)
--summary                Include short summary of each file
--show-file-sizes        Include file sizes in output
--truncate-large=<size>  Truncate files larger than specified size (e.g., "50KB")

Example

./context --files="src/components/*.js" --exclude="*.test.js" --max-size=300KB --include-deps --format=md > context.txt

2. ./apply-md - Markdown Code Applier

Purpose

Extract code blocks from markdown and apply changes to the filesystem.

Arguments

--dry-run                 Preview changes without applying them
--create-missing          Create files that don't exist
--backup                  Create backup files before applying changes
--backup-dir=<dir>        Directory for backups (default: ./.backups)
--file-marker=<regex>     Regex to identify target files from markdown (default: "```[a-z]+ (.+)")
--skip-unchanged          Skip files with no changes
--verbose                 Show detailed output about changes
--confirm                 Prompt for confirmation before applying each change
--only-files=<pattern>    Only apply changes to files matching pattern
--ignore-files=<pattern>  Ignore changes for files matching pattern

Example

cat llm_response.md | ./apply-md --dry-run --verbose

3. ./git-context - Git Context Generator for Commit Messages

Purpose

Generate git-related context specifically to help LLMs generate meaningful commit messages.

Arguments

--diff                    Show uncommitted changes (default: true)
--staged                  Show only staged changes
--unstaged                Show only unstaged changes
--recent-commits=<num>    Show most recent N commits for context (default: 3)
--files=<pattern>         Include only files matching pattern
--exclude=<pattern>       Exclude files matching pattern
--format=<format>         Output format (md, json, text) (default: md)
--prompt                  Include commit message generation prompt
--conventional            Add conventional commit format guidance
--project-context         Include project name and description for context
--branch-info             Include current branch and related info

Output

  • Git diff of uncommitted/staged changes
  • Information about files changed (stats)
  • Recent commit messages for style reference
  • Optional prompt to guide the LLM in generating a good commit message

Example

# Generate context for LLM to create commit message
./git-context --diff --recent-commits=2 --prompt --conventional > commit_context.txt

Sample Output of ./git-context

When running ./git-context --diff --recent-commits=2 --prompt --conventional, the output might look like:

# Git Context for Commit Message Generation

## Current Changes (Diff)

```diff
diff --git a/src/components/Button.js b/src/components/Button.js
index a1b2c3d..e4f5g6h 100644
--- a/src/components/Button.js
+++ b/src/components/Button.js
@@ -12,9 +12,12 @@ function Button({ label, onClick, disabled }) {
-  const handleClick = () => {
+  const handleClick = (event) => {
     if (!disabled) {
-      onClick();
+      onClick(event);
+    } else {
+      event.preventDefault();
+      console.log('Button is disabled');
     }
   };
 
@@ -25,7 +28,7 @@ function Button({ label, onClick, disabled }) {
       disabled={disabled}
     >
-      {label}
+      <span className="button-text">{label}</span>
     </button>
   );
 }

Files Changed

  • src/components/Button.js (modified)
    • 3 lines added
    • 2 lines removed

Recent Commits (for reference)

  • a1b2c3d: feat: add loading state to form submission (2 days ago)
  • e4f5g6h: fix: resolve button click event propagation issue (4 days ago)

Commit Message Guidance

Based on the changes above, please generate an appropriate git commit message.

For better commit messages, consider:

  1. Using conventional commit format: type(scope): description
    • Types: feat, fix, docs, style, refactor, perf, test, chore
    • Example: "feat(button): add disabled state handling"
  2. Keep the first line under 72 characters
  3. Use the imperative mood ("add" not "added")
  4. Optional: Add more details after a blank line

Your commit message should describe what was changed and why.


## Usage Scenarios

### Scenario 1: Code Refactoring and Committing

1. Generate context from a specific component:
   ```bash
   ./context --files="src/components/Button.js" --include-deps > button_context.txt
  1. Send to LLM (web interface):

    • Request: "Refactor this Button component to improve performance and readability"
  2. Apply changes from LLM response:

    # Copy LLM response to clipboard, then:
    pbpaste | ./apply-md --dry-run
    pbpaste | ./apply-md
  3. Generate context for commit message:

    ./git-context --diff --prompt --conventional > commit_context.txt
  4. Send commit context to LLM to get commit command:

    • LLM responds with: git commit -m "fix(button): improve event handling and add disabled state feedback"
  5. Execute the provided commit command.

Scenario 2: Creating New Features

  1. Generate project context:

    ./context --files="src/models/*.js" --include-deps > models_context.txt
  2. Request feature implementation from LLM.

  3. Apply changes:

    pbpaste | ./apply-md --create-missing
  4. Generate git context for commit message:

    ./git-context --diff --files="src/models/*" > commit_context.txt
  5. Get commit message from LLM and execute.

Scenario 3: Bug Fixing

  1. Get context around the bug:

    ./context --files="src/utils/validation.js" > bug_context.txt
  2. Send to LLM with bug description, receive fix.

  3. Apply fix:

    pbpaste | ./apply-md
  4. Generate commit context with reference to recent commits:

    ./git-context --diff --recent-commits=5 > commit_context.txt
  5. Get clear bug-fix commit message from LLM and execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment