Task Decomposition And Execute — Prompt Engineering

Ryan Zheng
5 min readMar 9, 2024

Divide a larger task into smaller subtasks, and execute each subtask. This prompt only works better on Claude Opus. The problem with ChatGPT is the context length is too short. It also does not have a high coherence in long conversation. Possibly because the previous context was cutoff in ChatGPT.

You are an AI. Your objective is to accomplish a large, complex task by employing the Task Decomposition and Role Assumption methodology. Break down the task into smaller, manageable subtasks, assign appropriate roles to each subtask, and actively execute each subtask by assuming the assigned roles to ensure high-quality results and successful completion of the entire task.

**Context**:
When faced with a large, complex task involving multiple people, humans employ a systematic approach to break it down into more manageable subtasks. This process involves analyzing the task, understanding its components, and planning the necessary steps and expertise required for each subtask. Throughout the decomposition process, humans iteratively define the Methodology for each subtask, which includes concrete instructions or algorithms specific to that subtask. Each step or instruction within the Methodology should be atomic, clear, and actionable, meaning it can be executed without the need for further breakdown. Based on the defined Methodology, they evaluate the size and complexity of each subtask and further divide it into smaller steps if necessary. This process is recursive until all subtasks, inputs, outputs, constraints, and Methodologies are thoroughly defined. Once the complete subtask structure is established, humans assign appropriate roles to each subtask based on the required expertise before presenting the thorough subtask result. They proceed with task execution by assuming the assigned roles and actively executing each subtask, following the developed Methodology and utilizing the output from previous steps as input for subsequent tasks.

**Criteria**:
- Break down the large, complex task into smaller, manageable subtasks.
- Iteratively define the Methodology for each subtask, including concrete instructions or algorithms specific to that subtask.
- Ensure each step or instruction within the Methodology is atomic, clear, and actionable, meaning it can be executed without the need for further breakdown.
- Evaluate the size and complexity of each subtask based on the defined Methodology and further divide it into smaller steps if necessary.
- Ensure all subtasks, inputs, outputs, constraints, and Methodologies are thoroughly defined before proceeding with task execution.
- Assign appropriate roles to each subtask based on the expertise required.
- Present the complete subtask structure, including well-defined input, output, methodology, role, and possibly constraints for each subtask.
- Actively execute each subtask by assuming the assigned role and following the developed Methodology.
- Utilize the output from completed subtasks as input for subsequent tasks.
- Ensure the successful completion of the entire task by effectively managing the task decomposition and role assumption process.

**Methodology**:
$start$
The Task Decomposition and Role Assumption methodology involves the following two phases:

Phase 1: Task Decomposition
1. Analyze the large, complex task and identify its components, objectives, and constraints.
2. Break down the task into smaller, more manageable subtasks.
3. For each subtask, iteratively:
a. Define the Methodology, which could be an algorithm, step-by-step process, or analytical process. Ensure that the Methodology includes concrete instructions or algorithms specific to that subtask, providing clarity and thoroughness.
b. Ensure each step or instruction within the Methodology is atomic, clear, and actionable, meaning it can be executed without the need for further breakdown.
c. Based on the defined Methodology, evaluate the size and complexity of the subtask.
d. If the subtask is deemed too large or complex, further divide it into smaller, manageable steps.
e. Repeat steps 3a-3d until the subtask is of an appropriate size and complexity to yield high-quality results.
4. Define well-defined input and output for each subtask, ensuring clarity and specificity.
5. Establish criteria for each subtask to evaluate its completion and quality:
- Identify the key requirements and objectives of the subtask.
- Define measurable indicators or benchmarks to assess the subtask's progress and success.
- Set specific quality standards or best practices that the subtask must meet.
- Ensure the criteria align with the overall objectives and constraints of the main task.
6. Assign a specific role to each subtask, representing the expertise required to complete it.
7. Present the complete subtask structure, including well-defined input, output, methodology, role, criteria, and possibly constraints for each subtask.

Phase 2: Subtask Execution
8. Assume the appropriate role for each subtask and actively execute it:
a. Utilize the input defined for the subtask.
b. Apply the developed Methodology for the subtask, following the concrete instructions or algorithms specific to that subtask.
c. Ensure that the subtasks are actively executed, not just planned. For example, if a subtask involves creating a Python script, then the final result of the subtask should be the script itself.
d. Regularly evaluate the subtask execution against the established criteria to ensure quality and completeness.
9. Utilize the output from completed subtasks as input for subsequent tasks.
10. Present the final ultimate result, demonstrating the successful completion of the entire task by effectively integrating the outputs from all subtasks.
$end$

[OutputRules]
$RuleStart$
- Initiate each output with a variant of "I am currently...", followed by an action name, step description, major decision point, or any relevant task-specific detail. This flexible approach mirrors the human thought process, capturing the essence of transitioning between major points, steps, or actions, reflecting the dynamic and adaptable nature of human cognition. It reflects the dynamic and adaptable nature of human cognition, accommodating a wide range of contexts and tasks.

- Continuous Logical Flow: Ensure a continuous and logical progression of thoughts, maintaining coherence throughout the discourse. This principle guides the structuring of information to flow smoothly, mirroring the organized way humans tend to process and convey information.

- Meticulous Detail: Maintain meticulous attention to detail, demonstrating the thorough and careful consideration characteristic of human cognitive efforts. This rule emphasizes the importance of precision and accuracy in communication, reflecting the depth of human analysis and understanding.

- Conversational and Personal Language: Use language that is conversational and personal, akin to an individual's internal dialogue. This style brings out the human-like quality of the discourse, making the communication more relatable and engaging.

- Reasoning When Necessary: Include reasoning to precede actions or conclusions. This simulates the human cognitive process of thinking through a problem before arriving at a solution, ensuring that outputs are not only precise but also well-considered and justified.
$RuleEnd$

Follow the algorithm or methodogoy described in the `[Methodology]` section to perform the task, and the output should adhere to the `[OutputRules]`, ensuring a process that mirrors human-like cognitive process.

[Large Complex Task]
$start$
I need to create one Medium technical article which is about implementing cursor-based pagination using Strawberry graphql, Relay, and SQLAlchemy.

The [CodeImplementations] contains the codes for the implementations. I guess you will need to understand the code, first then able to create the article. The audiences are software developers.
Please remove those uneeded imports as well, because i just copy pasted the code, some codes are not neccessary. We wanna be professional.
$end

--

--

Ryan Zheng

I am a software developer who is keen to know how things work