Skip to content

AndrewBrown-USDA/aigb-skills-usda / skills/rubber-ducking

rubber-ducking

Verified

Interactive guided walkthrough of code, line by line, where the agent reflects back your explanations without analysis. Use when debugging, reviewing, or understanding code by forced articulation.

scripts/README.md

View on GitHub
# Scripts

Executable utilities for rubber-ducking implementation.

## Language Detection

**Script**: `language_detect.py`

Detects programming language from code snippet via pattern matching.

```bash
python3 language_detect.py [file]
cat code.py | python3 language_detect.py
# Output: Python (confidence: 0.56)
```

**Returns**: Language name + confidence (0.0-1.0)

**Supported**: Python, JavaScript, TypeScript, R, Java, C, C++, Go, Rust, SQL, Bash, YAML

**Tests**: Run `python3 test_language_detect.py`

**Docs**: See `language_detect.md`

---

## AST Chunking

**Script**: `ast_chunking.py`

Breaks code into logical chunks (functions, loops, conditionals, statements).

```bash
python3 ast_chunking.py [file]
cat code.py | python3 ast_chunking.py
# Output:
# Lines   1-  3 (function    ): def foo(...)
# Lines   4-  8 (loop        ): for ...
# Lines   9- 10 (statement   ): return result
```

**Returns**: List of chunks with:
- Start line (1-indexed)
- End line (1-indexed)
- Chunk type (function, class, loop, conditional, statement, exception)
- Description

**Supported**: Python, JavaScript, TypeScript, Java (others fall back to generic statement-per-line)

**Tests**: Run `python3 test_ast_chunking.py`

**Docs**: See `ast_chunking.md`

---

## Usage Notes

- Both scripts are deterministic (no randomness, same input -> same output)
- Language detection confidence is heuristic-based; may be low for ambiguous code
- Chunking respects logical structure (don't split function from body)
- Nested structures inside functions treated as single chunk (use "step" to zoom in)

## Integration

Agents implementing rubber-ducking should:

1. Use `language_detect()` to identify code language
2. Use `chunk_code()` to get initial chunks
3. For "step" navigation, re-run `chunk_code()` on sub-range or implement recursive stepping
4. Both functions available as importable Python modules:

```python
from language_detect import detect_language
from ast_chunking import chunk_code

lang, conf = detect_language(user_code)
chunks = chunk_code(user_code)
```
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall