Skip to content

Commit dce0fcd

Browse files
committed
Add debugging guidelines to AGENTS.md and copilot-instructions.md for improved test-driven development practices
1 parent 7a0392b commit dce0fcd

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

.github/copilot-instructions.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ This repository contains the **Better Together Community Engine** (an isolated R
9292
9393
## Coding Guidelines
9494
95+
### Debugging and Development Practices
96+
- **Never use Rails console or runner for debugging** - These commands don't support our test-driven development approach
97+
- **Debug through comprehensive tests**: Write detailed test scenarios to reproduce, understand, and verify fixes for issues
98+
- **Use test-driven debugging workflow**:
99+
- Create specific tests that reproduce the problematic behavior
100+
- Add debugging assertions in tests to verify intermediate state
101+
- Trace through code by reading files and using grep search
102+
- Validate fixes by ensuring tests pass
103+
- **Leverage RSpec debugging tools**: Use `--format documentation` for detailed output, `fit` for focused testing, `puts` for temporary debug output in tests
104+
- **Analyze logs and error messages**: Examine Rails logs, test output, and stack traces for debugging information
105+
- **Read code systematically**: Use file reading tools to understand code paths and data flow
106+
- **Temporary debug output**: Add debug statements in application code if needed, but remove before committing
107+
95108
### Docker Environment Usage
96109
- **All database-dependent commands must use `bin/dc-run`**: This includes tests, generators, and any command that connects to PostgreSQL, Redis, or Elasticsearch
97110
- **Dummy app commands use `bin/dc-run-dummy`**: For Rails commands that need the dummy app context (console, migrations specific to dummy app)
@@ -102,10 +115,11 @@ This repository contains the **Better Together Community Engine** (an isolated R
102115
- RuboCop: `bin/dc-run bundle exec rubocop`
103116
- **IMPORTANT**: Never use `rspec -v` - this displays version info, not verbose output. Use `--format documentation` for detailed output.
104117
- **Examples of commands requiring `bin/dc-run-dummy`**:
105-
- Rails console: `bin/dc-run-dummy rails console`
118+
- Rails console: `bin/dc-run-dummy rails console` (for administrative tasks only, NOT for debugging)
106119
- Dummy app migrations: `bin/dc-run-dummy rails db:migrate`
107120
- Dummy app database operations: `bin/dc-run-dummy rails db:seed`
108121
- **Commands that don't require bin/dc-run**: File operations, documentation generation (unless database access needed), static analysis tools that don't connect to services
122+
- **CRITICAL**: Rails console and runner are NOT debugging tools in this project - use comprehensive test suites instead
109123
110124
### Security Requirements
111125
- **Run Brakeman before generating code**: `bin/dc-run bundle exec brakeman --quiet --no-pager`

AGENTS.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ Instructions for GitHub Copilot and other automated contributors working in this
1919
- test: `community_engine_test`
2020
- Use `DATABASE_URL` to connect (overrides fallback host in `config/database.yml`).
2121

22+
## Debugging Guidelines
23+
- **Never use Rails console or runner for debugging** - These commands don't align with our test-driven development approach
24+
- **Use comprehensive test suites instead**: Write detailed tests to understand and verify system behavior
25+
- **Debug through tests**: Create specific test scenarios to reproduce and validate fixes for issues
26+
- **Use log analysis**: Examine Rails logs, test output, and error messages for debugging information
27+
- **Add temporary debugging assertions in tests**: Use `expect()` statements to verify intermediate state in tests
28+
- **Use RSpec debugging tools**: Use `--format documentation` for detailed test output, `fit` for focused testing
29+
- **Trace through code by reading files**: Use file reading and grep search to understand code paths
30+
- **Add debug output in application code temporarily** if needed, but remove before committing
31+
- **Validate fixes through test success**: Confirm that issues are resolved by having tests pass
32+
2233
## Commands
2334
- **Tests:** `bin/dc-run bin/ci`
2435
(Equivalent: `bin/dc-run bash -c "cd spec/dummy && bundle exec rspec"`)
@@ -29,7 +40,7 @@ Instructions for GitHub Copilot and other automated contributors working in this
2940
- Multiple specific lines: `bin/dc-run bundle exec rspec spec/file1_spec.rb:123 spec/file2_spec.rb:456`
3041
- **Important**: RSpec does NOT support hyphenated line numbers (e.g., `spec/file_spec.rb:123-456` is INVALID)
3142
- **Do NOT use `-v` flag**: The `-v` flag displays RSpec version information, NOT verbose output. Use `--format documentation` for detailed test descriptions.
32-
- **Rails Console:** `bin/dc-run-dummy rails console` (runs console in the dummy app context)
43+
- **Rails Console:** `bin/dc-run-dummy rails console` (for administrative tasks only - NOT for debugging. Use comprehensive tests for debugging instead)
3344
- **Rails Commands in Dummy App:** `bin/dc-run-dummy rails [command]` for any Rails commands that need the dummy app environment
3445
- **Lint:** `bin/dc-run bundle exec rubocop`
3546
- **Security:** `bin/dc-run bundle exec brakeman --quiet --no-pager` and `bin/dc-run bundle exec bundler-audit --update`

0 commit comments

Comments
 (0)