looking at @coding-guidelines.mdc how would you refactor this repo?
- User
looking at @coding-guidelines.mdc how would you refactor this repo?
Assistant
I'll analyze the repo against the coding guidelines and identify refactoring opportunities.
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/.cursor/rules/coding-guidelines.mdc]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/index.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/commands/init.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/prompts.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/types.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/utils/project-structure.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/utils/mcp-config.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/utils/agents-md.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/utils/agno-config.ts]
[tool: read_file — Tool use: read_file • Read file: /Users/[user]/workspace/langwatch/better-agents/src/utils/kickoff-agent.ts]
Refactoring Recommendations
Main Violations Identified:
1.
prompts.ts- Multiple Violations- 97 lines, single export but multiple responsibilities
- Contains UI logic, validation, string formatting, and data collection
- Missing TSDoc completely
Refactor:
codeprompts/ collect-project-config.ts (main export) validators/ api-key-validator.ts project-goal-validator.ts choices/ language-choices.ts framework-choices.ts2.
commands/init.ts- Orchestration + Error Handling- Good SRP but missing TSDoc
3.
utils/project-structure.ts- 209 lines, multiple concerns- Directory creation
- File template generation for 7+ file types
- Configuration logic
Refactor:
code- User
I don't even know what prompts is or file structure is. propose better names for organization
Assistant
Better Feature-Based Organization
Current structure groups by technical type (
utils/). Here's a clearer domain-driven structure:code- User
maybe top level directories should have README files?
Assistant
Yes! READMEs for Feature Directories
Each top-level directory should have a
README.mdexplaining its purpose, exports, and usage:codesrc/ config-collection/ README.md collect-config.ts validators/ choice-builders/ project-scaffolding/ README.md create-directory-structure.ts file-generators/ documentation/ README.md generate-agents-guide.ts sections/ tool-setup/ README.md mcp/ agno/ assistant-kickoff/ README.md build-initial-prompt.ts display-instructions.ts- User
do the refactor, consider @unit-tests-todos.mdc
Assistant
- User
@commits.mdc try again
Assistant
bashgit add -A && git commit -m "refactor: reorganize codebase into feature-based architecture" -m "Restructured src/ from technical grouping (utils/) to domain-driven feature modules following SRP and Clean Code principles. Changes: - Created 5 feature directories: config-collection/, project-scaffolding/, documentation/, tool-setup/, assistant-kickoff/ - Split 209-line project-structure.ts into 8 modular file generators - Split 226-line agents-md.ts into 4 section builders - Split 97-line prompts.ts into validators and choice builders - Added README.md to all top-level feature directories explaining purpose and responsibilities - Added TSDoc with examples to all 30+ functions - Created 6 test spec files with it.todo for logic branches (Vitest) - Applied consistent formatting (double quotes, spacing) Each feature now has single responsibility, thin files (<100 lines), and colocated tests in __tests__ directories."