Skip to content

Commit e98dc97

Browse files
docs: add power user guides (#524)
* docs: add power user guides Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> * docs: enhance power user guides with cross-references and Factory App integration - Add Power User group to sidebar navigation - Add Factory App callouts and cross-links to all guides - Remove time estimates from setup checklist - Add multiple memory capture trigger options (# prefix, phrases) - Add implementation alternatives (hooks, skills, slash commands) - Add rule enforcement automation section - Fix hook matcher (Edit|Create → Edit|Write) - Fix FACTORY_PROJECT_DIR usage in hook examples - Add cross-references to related documentation Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com> --------- Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent ba6ec1a commit e98dc97

File tree

7 files changed

+319
-69
lines changed

7 files changed

+319
-69
lines changed

docs/docs.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@
188188
{
189189
"tab": "Guides",
190190
"groups": [
191+
{
192+
"group": "Power User",
193+
"pages": [
194+
"guides/power-user/setup-checklist",
195+
"guides/power-user/memory-management",
196+
"guides/power-user/rules-conventions",
197+
"guides/power-user/prompt-crafting",
198+
"guides/power-user/token-efficiency"
199+
]
200+
},
191201
{
192202
"group": "Building",
193203
"pages": [

docs/guides/power-user/memory-management.mdx

Lines changed: 147 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ keywords: ['memory', 'context', 'preferences', 'persistent', 'sessions', 'histor
66

77
Droid doesn't have built-in memory between sessions, but you can create a powerful memory system using markdown files, AGENTS.md references, and hooks. This guide shows you how to build memory that persists and grows.
88

9+
<Info>
10+
**Works with Factory App:** These memory patterns work identically in both CLI and [Factory App](/web/getting-started/overview)—just ensure your working directory is set to your repository root.
11+
</Info>
12+
913
---
1014

1115
## The Memory System Architecture
@@ -220,63 +224,112 @@ Create a hook that helps you capture memories as you work.
220224

221225
When you say "remember this:" followed by content, automatically append to memories.
222226

223-
Create `~/.factory/hooks/memory-capture.py`:
224-
225-
```python
226-
#!/usr/bin/env python3
227-
"""
228-
Captures "remember this:" statements and appends to memories.md
229-
"""
230-
import json
231-
import sys
232-
import os
233-
from datetime import datetime
234-
235-
def main():
236-
try:
237-
data = json.load(sys.stdin)
238-
prompt = data.get('prompt', '').lower()
239-
240-
# Check for memory trigger phrases
241-
triggers = ['remember this:', 'remember:', 'note:', 'save this:']
242-
243-
for trigger in triggers:
244-
if trigger in prompt.lower():
245-
# Extract the content after the trigger
246-
idx = prompt.lower().index(trigger)
247-
content = data.get('prompt', '')[idx + len(trigger):].strip()
227+
You can trigger memory capture with either **special characters** or **phrases**. Choose based on your preference:
228+
229+
<Tabs>
230+
<Tab title="# prefix trigger">
231+
Trigger with `#` at the start of your message for quick capture.
232+
233+
**Usage:**
234+
- "#we use the repository pattern"
235+
- "##I prefer early returns" (double `##` for personal)
236+
237+
Create `~/.factory/hooks/memory-capture.py`:
238+
239+
```python
240+
#!/usr/bin/env python3
241+
"""Captures messages starting with # and appends to memories.md"""
242+
import json, sys, os
243+
from datetime import datetime
244+
245+
def main():
246+
try:
247+
data = json.load(sys.stdin)
248+
prompt = data.get('prompt', '').strip()
249+
250+
if not prompt.startswith('#'):
251+
return
252+
253+
# ## = personal, # = project
254+
if prompt.startswith('##'):
255+
content = prompt[2:].strip()
256+
mem_file = os.path.expanduser('~/.factory/memories.md')
257+
else:
258+
content = prompt[1:].strip()
259+
project_dir = os.environ.get('FACTORY_PROJECT_DIR', os.getcwd())
260+
project_factory = os.path.join(project_dir, '.factory')
261+
if os.path.exists(project_factory):
262+
mem_file = os.path.join(project_factory, 'memories.md')
263+
else:
264+
mem_file = os.path.expanduser('~/.factory/memories.md')
265+
266+
if content:
267+
timestamp = datetime.now().strftime('%Y-%m-%d')
268+
with open(mem_file, 'a') as f:
269+
f.write(f"\n- [{timestamp}] {content}\n")
248270

249-
if content:
250-
# Determine which memories file to use
251-
if 'personal' in prompt.lower() or 'my preference' in prompt.lower():
252-
mem_file = os.path.expanduser('~/.factory/memories.md')
253-
else:
254-
# Default to project memories if .factory exists
255-
project_mem = '.factory/memories.md'
256-
if os.path.exists('.factory'):
257-
mem_file = project_mem
258-
else:
259-
mem_file = os.path.expanduser('~/.factory/memories.md')
260-
261-
# Append the memory
262-
timestamp = datetime.now().strftime('%Y-%m-%d')
263-
entry = f"\n- [{timestamp}] {content}\n"
271+
print(json.dumps({'systemMessage': f'✓ Saved to {mem_file}'}))
272+
except:
273+
pass
274+
275+
if __name__ == '__main__':
276+
main()
277+
```
278+
</Tab>
279+
280+
<Tab title="Phrase trigger">
281+
Trigger with phrases like "remember this:", "note:", etc.
282+
283+
**Usage:**
284+
- "Remember this: we use the repository pattern"
285+
- "Note: auth tokens expire after 24 hours"
286+
287+
Create `~/.factory/hooks/memory-capture.py`:
288+
289+
```python
290+
#!/usr/bin/env python3
291+
"""Captures 'remember this:' statements and appends to memories.md"""
292+
import json, sys, os
293+
from datetime import datetime
294+
295+
def main():
296+
try:
297+
data = json.load(sys.stdin)
298+
prompt = data.get('prompt', '')
299+
300+
triggers = ['remember this:', 'remember:', 'note:', 'save this:']
301+
302+
for trigger in triggers:
303+
if trigger in prompt.lower():
304+
idx = prompt.lower().index(trigger)
305+
content = prompt[idx + len(trigger):].strip()
264306

265-
with open(mem_file, 'a') as f:
266-
f.write(entry)
267-
268-
# Signal to Droid that we captured the memory
269-
print(json.dumps({
270-
'systemMessage': f'✓ Saved to {mem_file}'
271-
}))
272-
break
273-
except Exception as e:
274-
# Don't fail the prompt on memory errors
275-
pass
276-
277-
if __name__ == '__main__':
278-
main()
279-
```
307+
if content:
308+
# Personal if specified, otherwise project
309+
if 'personal' in prompt.lower():
310+
mem_file = os.path.expanduser('~/.factory/memories.md')
311+
else:
312+
project_dir = os.environ.get('FACTORY_PROJECT_DIR', os.getcwd())
313+
project_factory = os.path.join(project_dir, '.factory')
314+
if os.path.exists(project_factory):
315+
mem_file = os.path.join(project_factory, 'memories.md')
316+
else:
317+
mem_file = os.path.expanduser('~/.factory/memories.md')
318+
319+
timestamp = datetime.now().strftime('%Y-%m-%d')
320+
with open(mem_file, 'a') as f:
321+
f.write(f"\n- [{timestamp}] {content}\n")
322+
323+
print(json.dumps({'systemMessage': f'✓ Saved to {mem_file}'}))
324+
break
325+
except:
326+
pass
327+
328+
if __name__ == '__main__':
329+
main()
330+
```
331+
</Tab>
332+
</Tabs>
280333

281334
Make it executable and configure the hook:
282335

@@ -304,10 +357,47 @@ Add to your hooks configuration via `/hooks`:
304357
}
305358
```
306359

307-
Now you can say things like:
360+
**With # prefix:**
361+
- "#we decided to use Zustand for state management"
362+
- "##I prefer early returns" (double `##` saves to personal)
363+
364+
**With phrase triggers:**
308365
- "Remember this: we decided to use Zustand for state management"
309366
- "Note: the auth module uses JWT with 24-hour expiration"
310-
- "Remember (personal): I prefer early returns"
367+
368+
### Alternative: Memory Capture Skill
369+
370+
Instead of a hook, you can use a [skill](/cli/configuration/skills) that Droid invokes when you ask to remember something. This gives you more interactive control over categorization.
371+
372+
See the [memory-capture skill example](https://github.com/Factory-AI/factory/tree/main/examples/power-user-skills/memory-capture) for a ready-to-use implementation.
373+
374+
### Alternative: Custom Slash Command
375+
376+
For quick manual capture, create a [custom slash command](/cli/configuration/custom-slash-commands):
377+
378+
Create `~/.factory/commands/remember.md`:
379+
380+
```markdown
381+
---
382+
description: Save a memory to your memories file
383+
argument-hint: <what to remember>
384+
---
385+
386+
Add this to my memories file (~/.factory/memories.md):
387+
388+
$ARGUMENTS
389+
390+
Format it appropriately based on whether it's a preference, decision, or learning. Include today's date.
391+
```
392+
393+
Then use `/remember we chose PostgreSQL for better ACID compliance` to capture memories on demand.
394+
395+
<Info>
396+
**Which approach to choose?**
397+
- **Hook** — Best for automatic capture without extra steps
398+
- **Skill** — Best when you want Droid to help categorize and format
399+
- **Slash Command** — Best for quick manual capture with consistent formatting
400+
</Info>
311401

312402
---
313403

docs/guides/power-user/prompt-crafting.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ keywords: ['prompts', 'prompting', 'claude', 'gpt', 'opus', 'sonnet', 'technique
66

77
Different AI models respond better to different prompting styles. This guide covers model-specific techniques and provides ready-to-use prompt refiner skills.
88

9+
<Info>
10+
**Works everywhere:** These prompting techniques apply to both CLI and [Factory App](/web/getting-started/overview).
11+
</Info>
12+
913
---
1014

1115
## Universal Prompting Principles
@@ -98,6 +102,10 @@ Claude models excel with structured, explicit instructions and respond particula
98102
</Step>
99103
</Steps>
100104

105+
<Tip>
106+
Ready-to-use prompt refiner skills are available in the [examples folder](https://github.com/Factory-AI/factory/tree/main/examples/power-user-skills). Copy them to `~/.factory/skills/` to use them. Learn more about skills in the [Skills documentation](/cli/configuration/skills).
107+
</Tip>
108+
101109
### Claude Prompt Refiner Skill
102110

103111
Create `~/.factory/skills/prompt-refiner-claude/SKILL.md`:

docs/guides/power-user/rules-conventions.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ keywords: ['rules', 'conventions', 'standards', 'coding style', 'guidelines', 't
66

77
Rules are codified standards that Droid follows every time. Unlike memories (which capture decisions and context), rules define how code should be written. This guide shows you how to organize rules effectively for individuals and teams.
88

9+
<Info>
10+
**Works with Factory App:** These conventions work identically in both CLI and [Factory App](/web/getting-started/overview)—Droid reads the same `.factory/rules/` files regardless of interface.
11+
</Info>
12+
913
---
1014

1115
## Rules vs Other Configuration
@@ -588,6 +592,60 @@ When a rule becomes outdated:
588592

589593
---
590594

595+
## Enforcing Rules Automatically
596+
597+
While Droid follows rules from your `.factory/rules/` files, you can add automated enforcement with [hooks](/cli/configuration/hooks-guide).
598+
599+
### Run Linters After Edits
600+
601+
Add a PostToolUse hook to run your linter after every file edit:
602+
603+
```json
604+
{
605+
"hooks": {
606+
"PostToolUse": [
607+
{
608+
"matcher": "Edit|Write",
609+
"hooks": [
610+
{
611+
"type": "command",
612+
"command": "cd \"$FACTORY_PROJECT_DIR\" && npm run lint -- --fix 2>/dev/null || true"
613+
}
614+
]
615+
}
616+
]
617+
}
618+
}
619+
```
620+
621+
### Validate Code Style
622+
623+
Run Prettier or your formatter automatically:
624+
625+
```json
626+
{
627+
"hooks": {
628+
"PostToolUse": [
629+
{
630+
"matcher": "Edit|Write",
631+
"hooks": [
632+
{
633+
"type": "command",
634+
"command": "cd \"$FACTORY_PROJECT_DIR\" && npx prettier --write \"$(jq -r '.tool_input.file_path')\" 2>/dev/null || true"
635+
}
636+
]
637+
}
638+
]
639+
}
640+
}
641+
```
642+
643+
<Tip>
644+
See [Auto-formatting hooks](/guides/hooks/auto-formatting) and [Code Validation hooks](/guides/hooks/code-validation) for more examples.
645+
</Tip>
646+
647+
---
648+
591649
## Quick Reference
592650

593651
### File Locations

0 commit comments

Comments
 (0)