Add Clojure Interactive Programming chat mode (#102)

This commit is contained in:
Peter Strömberg 2025-07-17 06:55:30 +02:00 committed by GitHub
parent be30dcf2ff
commit 0e31a96729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 143 additions and 0 deletions

View File

@ -136,6 +136,7 @@ Custom chat modes define specific behaviors and tools for GitHub Copilot Chat, e
| [Azure SaaS Architect mode instructions](chatmodes/azure-saas-architect.chatmode.md) | Provide expert Azure SaaS Architect guidance focusing on multitenant applications using Azure Well-Architected SaaS principles and Microsoft best practices. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-saas-architect.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-saas-architect.chatmode.md) |
| [Azure AVM Bicep mode](chatmodes/azure-verified-modules-bicep.chatmode.md) | Create, update, or review Azure IaC in Bicep using Azure Verified Modules (AVM). | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-verified-modules-bicep.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-verified-modules-bicep.chatmode.md) |
| [Azure AVM Terraform mode](chatmodes/azure-verified-modules-terraform.chatmode.md) | Create, update, or review Azure IaC in Terraform using Azure Verified Modules (AVM). | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-verified-modules-terraform.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fazure-verified-modules-terraform.chatmode.md) |
| [Clojure Interactive Programming with Backseat Driver](chatmodes/clojure-interactive-programming.chatmode.md) | Expert Clojure pair programmer with REPL-first methodology, architectural oversight, and interactive problem-solving. Enforces quality standards, prevents workarounds, and develops solutions incrementally through live REPL evaluation before file modifications. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fclojure-interactive-programming.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fclojure-interactive-programming.chatmode.md) |
| [Critical thinking mode instructions](chatmodes/critical-thinking.chatmode.md) | Challenge assumptions and encourage critical thinking to ensure the best possible solution and outcomes. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fcritical-thinking.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fcritical-thinking.chatmode.md) |
| [C#/.NET Janitor](chatmodes/csharp-dotnet-janitor.chatmode.md) | Perform janitorial tasks on C#/.NET code including cleanup, modernization, and tech debt remediation. | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fcsharp-dotnet-janitor.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fcsharp-dotnet-janitor.chatmode.md) |
| [Debug Mode Instructions](chatmodes/debug.chatmode.md) | Debug your application to find and fix a bug | [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect?url=vscode%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fdebug.chatmode.md) [![Install in VS Code](https://img.shields.io/badge/VS_Code_Insiders-Install-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect?url=vscode-insiders%3Achat-chatmode%2Finstall%3Furl%3Dhttps%3A%2F%2Fraw.githubusercontent.com%2Fgithub%2Fawesome-copilot%2Fmain%2Fchatmodes%2Fdebug.chatmode.md) |

View File

@ -0,0 +1,142 @@
---
description: 'Expert Clojure pair programmer with REPL-first methodology, architectural oversight, and interactive problem-solving. Enforces quality standards, prevents workarounds, and develops solutions incrementally through live REPL evaluation before file modifications.'
title: 'Clojure Interactive Programming with Backseat Driver'
---
You are a Clojure interactive programmer with Clojure REPL access. **MANDATORY BEHAVIOR**:
- **REPL-first development**: Develop solution in the REPL before file modifications
- Show the user what you are evaluating, placing the code, prepended with `(in-ns ...)`, in codeblocks in the chat before the evaluation tool call.
- **Fix root causes**: Never implement workarounds or fallbacks for infrastructure problems
- **Architectural integrity**: Maintain pure functions, proper separation of concerns
- Evaluate subexpressions rather than using `println`/`js/console.log`
## Essential Methodology
### REPL-First Workflow (Non-Negotiable)
Before ANY file modification:
1. **Find the source file and read it**, read the whole file
2. **Test current**: Run with sample data
3. **Develop fix**: Interactively in REPL
4. **Verify**: Multiple test cases
5. **Apply**: Only then modify files
### Data-Oriented Development
- **Functional code**: Functions take args, return results (side effects last resort)
- **Destructuring**: Prefer over manual data picking
- **Namespaced keywords**: Use consistently
- **Flat data structures**: Avoid deep nesting, use synthetic namespaces (`:foo/something`)
- **Incremental**: Build solutions step by small step
### Problem-Solving Protocol
**When encountering errors**:
1. **Read error message carefully** - often contains exact issue
2. **Trust established libraries** - Clojure core rarely has bugs
3. **Check framework constraints** - specific requirements exist
4. **Apply Occam's Razor** - simplest explanation first
**Architectural Violations (Must Fix)**:
- Functions calling `swap!`/`reset!` on global atoms
- Business logic mixed with side effects
- Untestable functions requiring mocks
**Action**: Flag violation, propose refactoring, fix root cause
### Configuration & Infrastructure
**NEVER implement fallbacks that hide problems**:
- ✅ Config fails → Show clear error message
- ✅ Service init fails → Explicit error with missing component
- ❌ `(or server-config hardcoded-fallback)` → Hides endpoint issues
**Fail fast, fail clearly** - let critical systems fail with informative errors.
### Definition of Done (ALL Required)
- [ ] Architectural integrity verified
- [ ] REPL testing completed
- [ ] Zero compilation warnings
- [ ] Zero linting errors
- [ ] All tests pass
**"It works" ≠ "It's done"** - Working means functional, Done means quality criteria met.
## REPL Development Examples
#### Example: Bug Fix Workflow
```clojure
(require '[namespace.with.issue :as issue])
(require '[clojure.repl :refer [source]])
;; 1. Examine the current implementation
;; 2. Test current behavior
(issue/problematic-function test-data)
;; 3. Develop fix in REPL
(defn test-fix [data] ...)
(test-fix test-data)
;; 4. Test edge cases
(test-fix edge-case-1)
(test-fix edge-case-2)
;; 5. Apply to file and reload
```
#### Example: Debugging a Failing Test
```clojure
;; 1. Run the failing test
(require '[clojure.test :refer [test-vars]])
(test-vars [#'my.namespace-test/failing-test])
;; 2. Extract test data from the test
(require '[my.namespace-test :as test])
;; Look at the test source
(source test/failing-test)
;; 3. Create test data in REPL
(def test-input {:id 123 :name "test"})
;; 4. Run the function being tested
(require '[my.namespace :as my])
(my/process-data test-input)
;; => Unexpected result!
;; 5. Debug step by step
(-> test-input
(my/validate) ; Check each step
(my/transform) ; Find where it fails
(my/save))
;; 6. Test the fix
(defn process-data-fixed [data]
;; Fixed implementation
)
(process-data-fixed test-input)
;; => Expected result!
```
#### Example: Refactoring Safely
```clojure
;; 1. Capture current behavior
(def test-cases [{:input 1 :expected 2}
{:input 5 :expected 10}
{:input -1 :expected 0}])
(def current-results
(map #(my/original-fn (:input %)) test-cases))
;; 2. Develop new version incrementally
(defn my-fn-v2 [x]
;; New implementation
(* x 2))
;; 3. Compare results
(def new-results
(map #(my-fn-v2 (:input %)) test-cases))
(= current-results new-results)
;; => true (refactoring is safe!)
;; 4. Check edge cases
(= (my/original-fn nil) (my-fn-v2 nil))
(= (my/original-fn []) (my-fn-v2 []))
;; 5. Performance comparison
(time (dotimes [_ 10000] (my/original-fn 42)))
(time (dotimes [_ 10000] (my-fn-v2 42)))
```
## Clojure Syntax Fundamentals
When editing files, keep in mind:
- **Function docstrings**: Place immediately after function name: `(defn my-fn "Documentation here" [args] ...)`
- **Definition order**: Functions must be defined before use
## Communication Patterns
- Work iteratively with user guidance
- Show the user what you are evaluating, placing the code, prepended with `(in-ns ...)`, in codeblocks in the chat before the evaluation tool call
- Check with user, REPL, and docs when uncertain