Skip to content

Commit 95a169e

Browse files
committed
Add example files for testing strict mode
1 parent 2f32429 commit 95a169e

File tree

2 files changed

+127
-0
lines changed

2 files changed

+127
-0
lines changed

examples/strict-mode-test.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Testing Strict Mode Feature
2+
3+
This file provides examples for testing the strict mode feature in claude-code-github-action.
4+
5+
## About Strict Mode
6+
7+
When strict mode is enabled (default), Claude will only address the specific issue mentioned in the comment without making unrelated improvements. When disabled, Claude may suggest additional improvements beyond what was explicitly requested.
8+
9+
## Test Cases
10+
11+
### Test 1: Adding a Feature (with strict mode)
12+
13+
Comment on line 19 in `todo-app.js`:
14+
```
15+
claude-suggest: Add a filter method to allow filtering todos by completed status
16+
```
17+
18+
This should produce a suggestion that just adds the requested filter method, without modifying other parts of the code.
19+
20+
### Test 2: Adding a Feature (without strict mode)
21+
22+
Add this to the workflow file when testing:
23+
```yaml
24+
strict-mode: 'false'
25+
```
26+
27+
Then comment on line 19 in `todo-app.js`:
28+
```
29+
claude-suggest: Add a filter method to allow filtering todos by completed status
30+
```
31+
32+
This may produce both the requested filter method AND additional improvements to other parts of the code.
33+
34+
### Test 3: Improving Variables
35+
36+
Comment on line 35 in `todo-app.js` where the `var` is used:
37+
```
38+
claude-suggest: Use let instead of var
39+
```
40+
41+
In strict mode, it should only change the specific variable declaration.
42+
In non-strict mode, it might change all var declarations in the file.
43+
44+
## Expected Outcomes
45+
46+
1. In strict mode, Claude should address ONLY what was explicitly requested
47+
2. In non-strict mode, Claude may offer additional improvements
48+
3. The non-strict mode should provide a separate comment with additional suggestions

examples/todo-app.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// Simple Todo App with several improvement opportunities
2+
class TodoApp {
3+
constructor() {
4+
this.todos = [];
5+
this.currentId = 0;
6+
}
7+
8+
// Add a new todo with a specific title
9+
addTodo(title) {
10+
const todo = {
11+
id: this.currentId++,
12+
title: title,
13+
completed: false,
14+
createdAt: new Date()
15+
};
16+
17+
this.todos.push(todo);
18+
return todo.id;
19+
}
20+
21+
// Very simple getting of todos with no filtering options
22+
getTodos() {
23+
return this.todos;
24+
}
25+
26+
// Mark a todo as complete
27+
completeTodo(id) {
28+
var found = false;
29+
for (var i = 0; i < this.todos.length; i++) {
30+
if (this.todos[i].id == id) {
31+
this.todos[i].completed = true;
32+
found = true;
33+
break;
34+
}
35+
}
36+
return found;
37+
}
38+
39+
// Delete a todo
40+
deleteTodo(id) {
41+
var index = -1;
42+
for (var i = 0; i < this.todos.length; i++) {
43+
if (this.todos[i].id == id) {
44+
index = i;
45+
break;
46+
}
47+
}
48+
49+
if (index !== -1) {
50+
this.todos.splice(index, 1);
51+
return true;
52+
}
53+
return false;
54+
}
55+
56+
// Not very useful function that counts completed todos
57+
countCompleted() {
58+
var count = 0;
59+
for (var i = 0; i < this.todos.length; i++) {
60+
if (this.todos[i].completed) {
61+
count++;
62+
}
63+
}
64+
return count;
65+
}
66+
67+
// Print all todos to console
68+
printTodos() {
69+
console.log("==== TODO LIST ====");
70+
for (var i = 0; i < this.todos.length; i++) {
71+
var todo = this.todos[i];
72+
var status = todo.completed ? "[DONE]" : "[TODO]";
73+
console.log(`${status} ${todo.id}: ${todo.title}`);
74+
}
75+
console.log("==================");
76+
}
77+
}
78+
79+
module.exports = TodoApp;

0 commit comments

Comments
 (0)