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.4---5
6# Project Section Identification Workflow
7
8## Purpose
9
10Analyze a software project to identify and categorize its logical sections (backend API, frontend, database layer, CLI, domain logic, etc.). This enables:
11
12- **Context scoping**: Focus agent work on specific project areas
13- **Architecture documentation**: Generate structured overview
14- **Dependency analysis**: Understand how sections relate
15- **Instruction optimization**: Input for optimizing prompt/skill context
16
17## When to Use
18
19- Starting work on an unfamiliar codebase
20- Need to scope work to a specific layer (e.g., "just the API")
21- Generating architecture documentation
22- Preparing context for focused implementation
23- Input for `agent-ops-context-map` or instruction optimization
24
25## Section Types
26
27| Section Type | Description | Common Indicators |
28|--------------|-------------|-------------------|
29| `api` | REST/GraphQL endpoints, route handlers | `/api/`, `/routes/`, `controllers/`, OpenAPI specs |
30| `frontend` | UI components, pages, client-side code | `/components/`, `/pages/`, `.tsx`, `.vue`, `.svelte` |
31| `backend` | Server-side logic, services | `/services/`, `/handlers/`, server entry points |
32| `database` | Data access, migrations, models | `/models/`, `/migrations/`, `/repositories/`, ORM files |
33| `cli` | Command-line interface | `/cli/`, `__main__.py`, `bin/`, Typer/Click/Commander |
34| `domain` | Business logic, core entities | `/domain/`, `/core/`, `/entities/`, pure logic |
35| `infrastructure` | Cloud, deployment, CI/CD | `/infra/`, `/deploy/`, `terraform/`, `docker/` |
36| `tests` | Test suites | `/tests/`, `*.test.*`, `*.spec.*` |
37| `config` | Configuration files | `/config/`, `.env*`, `*.config.*`, `settings.*` |
38| `docs` | Documentation | `/docs/`, `*.md`, OpenAPI, JSDoc |
39| `scripts` | Build/utility scripts | `/scripts/`, `Makefile`, `package.json` scripts |
40| `shared` | Shared utilities, types, constants | `/shared/`, `/common/`, `/utils/`, `/types/` |
41
42## Procedure
43
44### Phase 1: Project Discovery
45
461. **Scan root directory** for high-level structure
472. **Identify project type** from indicators:
48 - `package.json` → Node.js/JavaScript
49 - `pyproject.toml` / `setup.py` → Python
50 - `*.csproj` / `*.sln` → .NET
51 - `go.mod` → Go
52 - `Cargo.toml` → Rust
533. **Read existing documentation** (README, constitution.md) for hints
544. **Check for monorepo patterns** (workspaces, multiple packages)
55
56### Phase 2: Section Identification
57
58For each top-level directory and key subdirectories:
59
601. **Analyze directory name** against section type patterns
612. **Sample file contents** (2-3 files per directory)
623. **Look for imports/dependencies** that indicate purpose
634. **Classify into section type**
64
65**Classification heuristics:**
66
67```
68IF contains route definitions AND HTTP methods → api
69IF contains React/Vue/Svelte components → frontend
70IF contains ORM models OR SQL → database
71IF contains CLI decorators (Typer/Click) → cli
72IF contains pure business logic, no I/O → domain
73IF contains test files → tests
74```
75
76### Phase 3: Dependency Mapping
77
78For each identified section:
79
801. **Trace imports** to other sections
812. **Identify shared dependencies**
823. **Build dependency graph**
83
84```
85api → domain → database
86 ↘ shared ↗
87frontend → api (HTTP)
88cli → domain
89```
90
91### Phase 4: Generate Output
92
93Produce structured output in two formats:
94
95#### Format A: Summary Table
96
97```markdown
98## Project Sections
99
100| Section | Type | Root Path | Key Files | Dependencies |
101|---------|------|-----------|-----------|--------------|
102| API Routes | api | src/api/ | routes.py, handlers/ | domain, database |
103| Web Frontend | frontend | web/ | App.tsx, components/ | api (HTTP) |
104| Data Layer | database | src/models/ | user.py, migrations/ | — |
105| CLI | cli | src/cli/ | __main__.py, commands/ | domain |
106| Business Logic | domain | src/domain/ | entities/, services/ | shared |
107| Utilities | shared | src/shared/ | utils.py, types.py | — |
108```
109
110#### Format B: Detailed Map
111
112```markdown
113## Section: API Routes
114
115**Type:** api
116**Root:** src/api/
117**Purpose:** REST API endpoints for issue management
118
119### Key Files
120- `routes.py` — Route definitions
121- `handlers/issues.py` — Issue CRUD handlers
122- `handlers/focus.py` — Focus endpoint
123
124### Dependencies
125- `domain` — Business logic for issue operations
126- `database` — Data persistence
127- `shared` — Common types and utilities
128
129### Entry Points
130- `app.py` — FastAPI application instance
131
132### Notes
133- Uses FastAPI framework
134- OpenAPI spec auto-generated
135```
136
137## Output Locations
138
139| Output | Location | Purpose |
140|--------|----------|---------|
141| Summary | Console / focus.md | Quick reference |
142| Detailed map | `.agent/sections.md` | Persistent reference |
143| JSON export | `.agent/sections.json` | Programmatic access |
144
145## Integration Points
146
147| Skill | How It Uses Section Data |
148|-------|-------------------------|
149| `agent-ops-context-map` | Includes section summary in map.md |
150| `agent-ops-planning` | Scopes implementation to specific sections |
151| `agent-ops-implementation` | Focuses context on relevant section |
152| `agent-ops-critical-review` | Reviews by section |
153
154## Scoped Context Mode
155
156After sections are identified, agent can work in **scoped mode**:
157
158```
159/agent-scope api
160```
161
162This loads only files from the `api` section into context, reducing noise for focused work.
163
164**Scope commands:**
165- `/agent-scope <section>` — Focus on one section
166- `/agent-scope <section1>,<section2>` — Focus on multiple sections
167- `/agent-scope clear` — Return to full project context
168
169## Completion Criteria
170
171- [ ] All major directories classified
172- [ ] Section types assigned appropriately
173- [ ] Key files identified per section
174- [ ] Dependencies mapped between sections
175- [ ] Output generated (summary + detailed)
176- [ ] Monorepo sub-projects handled (if applicable)
177
178## Anti-patterns (avoid)
179
180- ❌ Classifying every directory (focus on meaningful sections)
181- ❌ Ignoring test directories (they provide insight into structure)
182- ❌ Assuming single project type (projects can be hybrid)
183- ❌ Missing hidden config (`.env`, `.config/`)
184- ❌ Treating `node_modules`/`venv` as sections (they're dependencies)
185
186## Examples
187
188### Example 1: Python FastAPI Project
189
190**Input:** Scan `tools/agent-ops-cli/`
191
192**Output:**
193```markdown
194## Project Sections: agent-ops-cli
195
196| Section | Type | Root Path | Key Files |
197|---------|------|-----------|-----------|
198| Issues CLI | cli | src/agent_ops_cli/issues/cli.py | commands, queries |
199| Issues Core | domain | src/agent_ops_cli/issues/core/ | parser, models |
200| TUI | frontend | src/agent_ops_cli/tui/ | app.py, views/ |
201| API Server | api | src/agent_ops_cli/api/ | routes/, server.py |
202| Knowledge Graph | domain | src/agent_ops_cli/kg/ | graph, query, llm |
203| Notifications | infrastructure | src/agent_ops_cli/notify/ | slack, server |
204| Tests | tests | tests/ | test_*.py |
205```
206
207### Example 2: Scoped Work
208
209**User:** "I need to fix a bug in the API"
210
211**Agent:**
212```
213Scoping to `api` section...
214
215Loaded context:
216- src/agent_ops_cli/api/routes/issues.py
217- src/agent_ops_cli/api/routes/focus.py
218- src/agent_ops_cli/api/routes/websocket.py
219- src/agent_ops_cli/api/server.py
220
221What's the bug you're seeing?
222```