Project Section Identification Workflow
Purpose
Analyze a software project to identify and categorize its logical sections (backend API, frontend, database layer, CLI, domain logic, etc.). This enables:
- Context scoping: Focus agent work on specific project areas
- Architecture documentation: Generate structured overview
- Dependency analysis: Understand how sections relate
- Instruction optimization: Input for optimizing prompt/skill context
When to Use
- Starting work on an unfamiliar codebase
- Need to scope work to a specific layer (e.g., "just the API")
- Generating architecture documentation
- Preparing context for focused implementation
- Input for
agent-ops-context-map or instruction optimization
Section Types
| Section Type |
Description |
Common Indicators |
api |
REST/GraphQL endpoints, route handlers |
/api/, /routes/, controllers/, OpenAPI specs |
frontend |
UI components, pages, client-side code |
/components/, /pages/, .tsx, .vue, .svelte |
backend |
Server-side logic, services |
/services/, /handlers/, server entry points |
database |
Data access, migrations, models |
/models/, /migrations/, /repositories/, ORM files |
cli |
Command-line interface |
/cli/, __main__.py, bin/, Typer/Click/Commander |
domain |
Business logic, core entities |
/domain/, /core/, /entities/, pure logic |
infrastructure |
Cloud, deployment, CI/CD |
/infra/, /deploy/, terraform/, docker/ |
tests |
Test suites |
/tests/, *.test.*, *.spec.* |
config |
Configuration files |
/config/, .env*, *.config.*, settings.* |
docs |
Documentation |
/docs/, *.md, OpenAPI, JSDoc |
scripts |
Build/utility scripts |
/scripts/, Makefile, package.json scripts |
shared |
Shared utilities, types, constants |
/shared/, /common/, /utils/, /types/ |
Procedure
Phase 1: Project Discovery
- Scan root directory for high-level structure
- Identify project type from indicators:
package.json → Node.js/JavaScript
pyproject.toml / setup.py → Python
*.csproj / *.sln → .NET
go.mod → Go
Cargo.toml → Rust
- Read existing documentation (README, constitution.md) for hints
- Check for monorepo patterns (workspaces, multiple packages)
Phase 2: Section Identification
For each top-level directory and key subdirectories:
- Analyze directory name against section type patterns
- Sample file contents (2-3 files per directory)
- Look for imports/dependencies that indicate purpose
- Classify into section type
Classification heuristics:
IF contains route definitions AND HTTP methods → api
IF contains React/Vue/Svelte components → frontend
IF contains ORM models OR SQL → database
IF contains CLI decorators (Typer/Click) → cli
IF contains pure business logic, no I/O → domain
IF contains test files → tests
Phase 3: Dependency Mapping
For each identified section:
- Trace imports to other sections
- Identify shared dependencies
- Build dependency graph
api → domain → database
↘ shared ↗
frontend → api (HTTP)
cli → domain
Phase 4: Generate Output
Produce structured output in two formats:
Format A: Summary Table
## Project Sections
| Section | Type | Root Path | Key Files | Dependencies |
|---------|------|-----------|-----------|--------------|
| API Routes | api | src/api/ | routes.py, handlers/ | domain, database |
| Web Frontend | frontend | web/ | App.tsx, components/ | api (HTTP) |
| Data Layer | database | src/models/ | user.py, migrations/ | — |
| CLI | cli | src/cli/ | __main__.py, commands/ | domain |
| Business Logic | domain | src/domain/ | entities/, services/ | shared |
| Utilities | shared | src/shared/ | utils.py, types.py | — |
Format B: Detailed Map
## Section: API Routes
**Type:** api
**Root:** src/api/
**Purpose:** REST API endpoints for issue management
### Key Files
- `routes.py` — Route definitions
- `handlers/issues.py` — Issue CRUD handlers
- `handlers/focus.py` — Focus endpoint
### Dependencies
- `domain` — Business logic for issue operations
- `database` — Data persistence
- `shared` — Common types and utilities
### Entry Points
- `app.py` — FastAPI application instance
### Notes
- Uses FastAPI framework
- OpenAPI spec auto-generated
Output Locations
| Output |
Location |
Purpose |
| Summary |
Console / focus.md |
Quick reference |
| Detailed map |
.agent/sections.md |
Persistent reference |
| JSON export |
.agent/sections.json |
Programmatic access |
Integration Points
| Skill |
How It Uses Section Data |
agent-ops-context-map |
Includes section summary in map.md |
agent-ops-planning |
Scopes implementation to specific sections |
agent-ops-implementation |
Focuses context on relevant section |
agent-ops-critical-review |
Reviews by section |
Scoped Context Mode
After sections are identified, agent can work in scoped mode:
`agent-scope` api
This loads only files from the api section into context, reducing noise for focused work.
Scope commands:
/agent-scope <section> — Focus on one section
/agent-scope <section1>,<section2> — Focus on multiple sections
/agent-scope clear — Return to full project context
Completion Criteria
Anti-patterns (avoid)
- ❌ Classifying every directory (focus on meaningful sections)
- ❌ Ignoring test directories (they provide insight into structure)
- ❌ Assuming single project type (projects can be hybrid)
- ❌ Missing hidden config (
.env, .config/)
- ❌ Treating
node_modules/venv as sections (they're dependencies)
Examples
Example 1: Python FastAPI Project
Input: Scan tools/agent-ops-cli/
Output:
## Project Sections: agent-ops-cli
| Section | Type | Root Path | Key Files |
|---------|------|-----------|-----------|
| Issues CLI | cli | src/agent_ops_cli/issues/cli.py | commands, queries |
| Issues Core | domain | src/agent_ops_cli/issues/core/ | parser, models |
| TUI | frontend | src/agent_ops_cli/tui/ | app.py, views/ |
| API Server | api | src/agent_ops_cli/api/ | routes/, server.py |
| Knowledge Graph | domain | src/agent_ops_cli/kg/ | graph, query, llm |
| Notifications | infrastructure | src/agent_ops_cli/notify/ | slack, server |
| Tests | tests | tests/ | test_*.py |
Example 2: Scoped Work
User: "I need to fix a bug in the API"
Agent:
Scoping to `api` section...
Loaded context:
- src/agent_ops_cli/api/routes/issues.py
- src/agent_ops_cli/api/routes/focus.py
- src/agent_ops_cli/api/routes/websocket.py
- src/agent_ops_cli/api/server.py
What's the bug you're seeing?
1---2name: agent-ops-project-sections3description: Identify and map different sections of a software project (API, frontend, database, CLI, domain). Use for context scoping and architecture documentation.4license: MIT5---67# Project Section Identification Workflow89## Purpose1011Analyze a software project to identify and categorize its logical sections (backend API, frontend, database layer, CLI, domain logic, etc.). This enables:1213- **Context scoping**: Focus agent work on specific project areas14- **Architecture documentation**: Generate structured overview15- **Dependency analysis**: Understand how sections relate16- **Instruction optimization**: Input for optimizing prompt/skill context1718## When to Use1920- Starting work on an unfamiliar codebase21- Need to scope work to a specific layer (e.g., "just the API")22- Generating architecture documentation23- Preparing context for focused implementation24- Input for `agent-ops-context-map` or instruction optimization2526## Section Types2728| Section Type | Description | Common Indicators |29|--------------|-------------|-------------------|30| `api` | REST/GraphQL endpoints, route handlers | `/api/`, `/routes/`, `controllers/`, OpenAPI specs |31| `frontend` | UI components, pages, client-side code | `/components/`, `/pages/`, `.tsx`, `.vue`, `.svelte` |32| `backend` | Server-side logic, services | `/services/`, `/handlers/`, server entry points |33| `database` | Data access, migrations, models | `/models/`, `/migrations/`, `/repositories/`, ORM files |34| `cli` | Command-line interface | `/cli/`, `__main__.py`, `bin/`, Typer/Click/Commander |35| `domain` | Business logic, core entities | `/domain/`, `/core/`, `/entities/`, pure logic |36| `infrastructure` | Cloud, deployment, CI/CD | `/infra/`, `/deploy/`, `terraform/`, `docker/` |37| `tests` | Test suites | `/tests/`, `*.test.*`, `*.spec.*` |38| `config` | Configuration files | `/config/`, `.env*`, `*.config.*`, `settings.*` |39| `docs` | Documentation | `/docs/`, `*.md`, OpenAPI, JSDoc |40| `scripts` | Build/utility scripts | `/scripts/`, `Makefile`, `package.json` scripts |41| `shared` | Shared utilities, types, constants | `/shared/`, `/common/`, `/utils/`, `/types/` |4243## Procedure4445### Phase 1: Project Discovery46471. **Scan root directory** for high-level structure482. **Identify project type** from indicators:49 - `package.json` → Node.js/JavaScript50 - `pyproject.toml` / `setup.py` → Python51 - `*.csproj` / `*.sln` → .NET52 - `go.mod` → Go53 - `Cargo.toml` → Rust543. **Read existing documentation** (README, constitution.md) for hints554. **Check for monorepo patterns** (workspaces, multiple packages)5657### Phase 2: Section Identification5859For each top-level directory and key subdirectories:60611. **Analyze directory name** against section type patterns622. **Sample file contents** (2-3 files per directory)633. **Look for imports/dependencies** that indicate purpose644. **Classify into section type**6566**Classification heuristics:**6768```69IF contains route definitions AND HTTP methods → api70IF contains React/Vue/Svelte components → frontend 71IF contains ORM models OR SQL → database72IF contains CLI decorators (Typer/Click) → cli73IF contains pure business logic, no I/O → domain74IF contains test files → tests75```7677### Phase 3: Dependency Mapping7879For each identified section:80811. **Trace imports** to other sections822. **Identify shared dependencies**833. **Build dependency graph**8485```86api → domain → database87 ↘ shared ↗88frontend → api (HTTP)89cli → domain90```9192### Phase 4: Generate Output9394Produce structured output in two formats:9596#### Format A: Summary Table9798```markdown99## Project Sections100101| Section | Type | Root Path | Key Files | Dependencies |102|---------|------|-----------|-----------|--------------|103| API Routes | api | src/api/ | routes.py, handlers/ | domain, database |104| Web Frontend | frontend | web/ | App.tsx, components/ | api (HTTP) |105| Data Layer | database | src/models/ | user.py, migrations/ | — |106| CLI | cli | src/cli/ | __main__.py, commands/ | domain |107| Business Logic | domain | src/domain/ | entities/, services/ | shared |108| Utilities | shared | src/shared/ | utils.py, types.py | — |109```110111#### Format B: Detailed Map112113```markdown114## Section: API Routes115116**Type:** api117**Root:** src/api/118**Purpose:** REST API endpoints for issue management119120### Key Files121- `routes.py` — Route definitions122- `handlers/issues.py` — Issue CRUD handlers123- `handlers/focus.py` — Focus endpoint124125### Dependencies126- `domain` — Business logic for issue operations127- `database` — Data persistence128- `shared` — Common types and utilities129130### Entry Points131- `app.py` — FastAPI application instance132133### Notes134- Uses FastAPI framework135- OpenAPI spec auto-generated136```137138## Output Locations139140| Output | Location | Purpose |141|--------|----------|---------|142| Summary | Console / focus.md | Quick reference |143| Detailed map | `.agent/sections.md` | Persistent reference |144| JSON export | `.agent/sections.json` | Programmatic access |145146## Integration Points147148| Skill | How It Uses Section Data |149|-------|-------------------------|150| `agent-ops-context-map` | Includes section summary in map.md |151| `agent-ops-planning` | Scopes implementation to specific sections |152| `agent-ops-implementation` | Focuses context on relevant section |153| `agent-ops-critical-review` | Reviews by section |154155## Scoped Context Mode156157After sections are identified, agent can work in **scoped mode**:158159```160`agent-scope` api161```162163This loads only files from the `api` section into context, reducing noise for focused work.164165**Scope commands:**166- `/agent-scope <section>` — Focus on one section167- `/agent-scope <section1>,<section2>` — Focus on multiple sections168- `/agent-scope clear` — Return to full project context169170## Completion Criteria171172- [ ] All major directories classified173- [ ] Section types assigned appropriately174- [ ] Key files identified per section175- [ ] Dependencies mapped between sections176- [ ] Output generated (summary + detailed)177- [ ] Monorepo sub-projects handled (if applicable)178179## Anti-patterns (avoid)180181- ❌ Classifying every directory (focus on meaningful sections)182- ❌ Ignoring test directories (they provide insight into structure)183- ❌ Assuming single project type (projects can be hybrid)184- ❌ Missing hidden config (`.env`, `.config/`)185- ❌ Treating `node_modules`/`venv` as sections (they're dependencies)186187## Examples188189### Example 1: Python FastAPI Project190191**Input:** Scan `tools/agent-ops-cli/`192193**Output:**194```markdown195## Project Sections: agent-ops-cli196197| Section | Type | Root Path | Key Files |198|---------|------|-----------|-----------|199| Issues CLI | cli | src/agent_ops_cli/issues/cli.py | commands, queries |200| Issues Core | domain | src/agent_ops_cli/issues/core/ | parser, models |201| TUI | frontend | src/agent_ops_cli/tui/ | app.py, views/ |202| API Server | api | src/agent_ops_cli/api/ | routes/, server.py |203| Knowledge Graph | domain | src/agent_ops_cli/kg/ | graph, query, llm |204| Notifications | infrastructure | src/agent_ops_cli/notify/ | slack, server |205| Tests | tests | tests/ | test_*.py |206```207208### Example 2: Scoped Work209210**User:** "I need to fix a bug in the API"211212**Agent:**213```214Scoping to `api` section...215216Loaded context:217- src/agent_ops_cli/api/routes/issues.py218- src/agent_ops_cli/api/routes/focus.py219- src/agent_ops_cli/api/routes/websocket.py220- src/agent_ops_cli/api/server.py221222What's the bug you're seeing?223```